2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2017 Kern Sibbald
6 The original author of Bacula is Kern Sibbald, with contributions
7 from many others, a complete list can be found in the file AUTHORS.
9 You may use this file and others of this release according to the
10 license defined in the LICENSE file, which includes the Affero General
11 Public License, v3.0 ("AGPLv3") and some additional permissions and
12 terms pursuant to its AGPLv3 Section 7.
14 This notice must be preserved when any source code is
15 conveyed and/or propagated.
17 Bacula(R) is a registered trademark of Kern Sibbald.
23 #ifndef _ALIGNED_DEV_H_
24 #define _ALIGNED_DEV_H_
26 class aligned_dev : public file_dev {
32 boffset_t get_adata_size(DCR *dcr);
33 boffset_t align_adata_addr(DCR *dcr, boffset_t addr);
34 boffset_t get_adata_addr(DCR *dcr);
35 void set_adata_addr(DCR *dcr);
36 void clear_adata_addr();
38 /* DEVICE virtual functions that we redefine */
39 void setVolCatName(const char *name);
40 void setVolCatStatus(const char *status);
41 void free_dcr_blocks(DCR *dcr);
42 void new_dcr_blocks(DCR *dcr);
43 void updateVolCatBytes(uint64_t);
44 void updateVolCatBlocks(uint32_t);
45 void updateVolCatWrites(uint32_t);
46 void updateVolCatReads(uint32_t);
47 void updateVolCatReadBytes(uint64_t);
48 void updateVolCatPadding(uint64_t);
49 bool setVolCatAdataBytes(uint64_t bytes);
50 void updateVolCatHoleBytes(uint64_t bytes);
51 void device_specific_open(DCR *dcr);
52 void set_volcatinfo_from_dcr(DCR *dcr);
53 bool allow_maxbytes_concurrency(DCR *dcr);
54 bool flush_before_eos(DCR *dcr);
61 void device_specific_init(JCR *jcr, DEVRES *device);
63 int d_open(const char *pathname, int flags);
64 int d_ioctl(int fd, ioctl_req_t request, char *mt_com);
65 ssize_t d_read(int fd, void *buffer, size_t count);
66 ssize_t d_write(int, const void *buffer, size_t count);
67 boffset_t lseek(DCR *dcr, off_t offset, int whence);
68 bool rewind(DCR *dcr);
69 bool reposition(DCR *dcr, uint64_t raddr);
70 bool open_device(DCR *dcr, int omode);
71 bool truncate(DCR *dcr);
75 bool update_pos(DCR *dcr);
76 bool mount_file(int mount, int dotimeout);
77 bool is_indexed() { return !adata; };
78 int read_dev_volume_label(DCR *dcr);
79 const char *print_type();
80 DEVICE *get_dev(DCR *dcr);
81 uint32_t get_hi_addr();
82 uint32_t get_low_addr();
83 uint64_t get_full_addr();
84 uint64_t get_full_addr(boffset_t addr);
85 bool do_size_checks(DCR *dcr, DEV_BLOCK *block);
86 bool write_volume_label_to_block(DCR *dcr);
87 bool write_volume_label_to_dev(DCR *dcr,
88 const char *VolName, const char *PoolName,
89 bool relabel, bool no_prelabel);
90 bool write_adata_label(DCR *dcr, DEV_RECORD *rec);
91 void write_adata(DCR *dcr, DEV_RECORD *rec);
92 void write_cont_adata(DCR *dcr, DEV_RECORD *rec);
93 int write_adata_rechdr(DCR *dcr, DEV_RECORD *rec);
94 bool read_adata_record_header(DCR *dcr, DEV_BLOCK *block, DEV_RECORD *rec);
95 void read_adata_block_header(DCR *dcr);
96 int read_adata(DCR *dcr, DEV_RECORD *rec);
97 bool have_adata_header(DCR *dcr, DEV_RECORD *rec, int32_t FileIndex,
98 int32_t Stream, uint32_t VolSessionId);
99 void select_data_stream(DCR *dcr, DEV_RECORD *rec);
100 bool flush_block(DCR *dcr);
101 bool do_pre_write_checks(DCR *dcr, DEV_RECORD *rec);
106 * Locking and blocking calls
108 #ifdef DEV_DEBUG_LOCK
109 void dbg_Lock(const char *, int);
110 void dbg_Unlock(const char *, int);
111 void dbg_rLock(const char *, int, bool locked=false);
112 void dbg_rUnlock(const char *, int);
116 void rLock(bool locked=false);
121 void dbg_Lock_acquire(const char *, int);
122 void dbg_Unlock_acquire(const char *, int);
123 void dbg_Lock_read_acquire(const char *, int);
124 void dbg_Unlock_read_acquire(const char *, int);
125 void dbg_Lock_VolCatInfo(const char *, int);
126 void dbg_Unlock_VolCatInfo(const char *, int);
129 void Unlock_acquire();
130 void Lock_read_acquire();
131 void Unlock_read_acquire();
132 void Lock_VolCatInfo();
133 void Unlock_VolCatInfo();
136 void dblock(int why); /* in lock.c */
137 void dunblock(bool locked=false);
141 #endif /* _ALIGNED_DEV_H_ */