]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/stored/aligned_dev.h
Apply patches from bugs #2325 and #2326 to fix FIFO bugs
[bacula/bacula] / bacula / src / stored / aligned_dev.h
1 /*
2    Bacula(R) - The Network Backup Solution
3
4    Copyright (C) 2000-2017 Kern Sibbald
5
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.
8
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.
13
14    This notice must be preserved when any source code is
15    conveyed and/or propagated.
16
17    Bacula(R) is a registered trademark of Kern Sibbald.
18 */
19 /*
20  * Inspired by vtape.h
21  */
22
23 #ifndef _ALIGNED_DEV_H_
24 #define _ALIGNED_DEV_H_
25
26 class aligned_dev : public file_dev {
27 public:
28
29    aligned_dev();
30    ~aligned_dev();
31
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();
37
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);
55    void set_nospace();
56    void set_append();
57    void set_read();
58    void clear_nospace();
59    void clear_append();
60    void clear_read();
61    void device_specific_init(JCR *jcr, DEVRES *device);
62    int d_close(int fd);
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);
72    bool close(DCR *dcr);
73    void term(DCR *dcr);
74    bool eod(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);
102
103
104
105    /*
106     * Locking and blocking calls
107     */
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);
113 #else
114    void Lock();
115    void Unlock();
116    void rLock(bool locked=false);
117    void rUnlock();
118 #endif
119
120 #ifdef  SD_DEBUG_LOCK
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);
127 #else
128    void Lock_acquire();
129    void Unlock_acquire();
130    void Lock_read_acquire();
131    void Unlock_read_acquire();
132    void Lock_VolCatInfo();
133    void Unlock_VolCatInfo();
134 #endif
135
136    void dblock(int why);                  /* in lock.c */
137    void dunblock(bool locked=false);
138
139 };
140
141 #endif /* _ALIGNED_DEV_H_ */