]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/stored/protos.h
adfdbcfed5f0ece7c158e105cb72df77ef30c3a3
[bacula/bacula] / bacula / src / stored / protos.h
1 /*
2    Bacula(R) - The Network Backup Solution
3
4    Copyright (C) 2000-2016 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  * Protypes for stored
21  *
22  *   Written by Kern Sibbald, MM
23  */
24
25 /* From stored.c */
26 uint32_t new_VolSessionId();
27
28 /* From acquire.c */
29 DCR     *acquire_device_for_append(DCR *dcr);
30 bool     acquire_device_for_read(DCR *dcr);
31 bool     release_device(DCR *dcr);
32 bool     clean_device(DCR *dcr);
33 DCR     *new_dcr(JCR *jcr, DCR *dcr, DEVICE *dev, bool writing=true);
34 void     free_dcr(DCR *dcr);
35
36 /* From append.c */
37 bool send_attrs_to_dir(JCR *jcr, DEV_RECORD *rec);
38
39 /* From askdir.c */
40 enum get_vol_info_rw {
41    GET_VOL_INFO_FOR_WRITE,
42    GET_VOL_INFO_FOR_READ
43 };
44 bool    dir_get_volume_info(DCR *dcr, enum get_vol_info_rw);
45 bool    dir_find_next_appendable_volume(DCR *dcr);
46 bool    dir_update_volume_info(DCR *dcr, bool label, bool update_LastWritten);
47 bool    dir_ask_sysop_to_create_appendable_volume(DCR *dcr);
48 bool    dir_ask_sysop_to_mount_volume(DCR *dcr, bool read_access);
49 bool    dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec);
50 bool    dir_send_job_status(JCR *jcr);
51 bool    dir_create_jobmedia_record(DCR *dcr, bool zero=false);
52 void    create_jobmedia_queue(JCR *jcr);
53 bool    flush_jobmedia_queue(JCR *jcr);
54 bool    dir_update_device(JCR *jcr, DEVICE *dev);
55 bool    dir_update_changer(JCR *jcr, AUTOCHANGER *changer);
56
57 /* authenticate.c */
58 bool    authenticate_director(JCR *jcr);
59 int     authenticate_filed(JCR *jcr, BSOCK *fd, int FDVersion);
60 bool    authenticate_storagedaemon(JCR *jcr);
61
62 /* From autochanger.c */
63 bool     init_autochangers();
64 int      autoload_device(DCR *dcr, bool writing, BSOCK *dir);
65 bool     autochanger_cmd(DCR *dcr, BSOCK *dir, const char *cmd);
66 bool     unload_autochanger(DCR *dcr, int loaded);
67 bool     unload_dev(DCR *dcr, DEVICE *dev);
68 char    *edit_device_codes(DCR *dcr, char *omsg, const char *imsg, const char *cmd);
69 int      get_autochanger_loaded_slot(DCR *dcr);
70
71 /* From block.c */
72 void    dump_block(DEV_BLOCK *b, const char *msg);
73 DEV_BLOCK *new_block(DEVICE *dev);
74 DEV_BLOCK *dup_block(DEV_BLOCK *eblock);
75 void    init_block_write(DEV_BLOCK *block);
76 void    empty_block(DEV_BLOCK *block);
77 void    free_block(DEV_BLOCK *block);
78 void    print_block_read_errors(JCR *jcr, DEV_BLOCK *block);
79 void    ser_block_header(DEV_BLOCK *block);
80 bool    is_block_empty(DEV_BLOCK *block);
81 bool    terminate_writing_volume(DCR *dcr);
82
83 /* From block_util.c */
84 bool    terminate_writing_volume(DCR *dcr);
85 bool    user_volume_size_reached(DCR *dcr, bool quiet);
86 bool    check_for_newvol_or_newfile(DCR *dcr);
87
88 /* From butil.c -- utilities for SD tool programs */
89 void    setup_me();
90 void    print_ls_output(const char *fname, const char *link, int type, struct stat *statp);
91 JCR    *setup_jcr(const char *name, char *dev_name, BSR *bsr,
92                   const char *VolumeName, bool writing, bool read_dedup_data=true);
93 void    display_tape_error_status(JCR *jcr, DEVICE *dev);
94
95
96 /* From dev.c */
97 DEVICE  *init_dev(JCR *jcr, DEVRES *device);
98 bool     can_open_mounted_dev(DEVICE *dev);
99 bool     load_dev(DEVICE *dev);
100 int      write_block(DEVICE *dev);
101 uint32_t status_dev(DEVICE *dev);
102 void     attach_jcr_to_device(DEVICE *dev, JCR *jcr);
103 void     detach_jcr_from_device(DEVICE *dev, JCR *jcr);
104 JCR     *next_attached_jcr(DEVICE *dev, JCR *jcr);
105 void     init_device_wait_timers(DCR *dcr);
106 void     init_jcr_device_wait_timers(JCR *jcr);
107 bool     double_dev_wait_time(DEVICE *dev);
108
109 /* From dvd.c */
110 int     dvd_open_next_part(DCR *dcr);
111 bool    dvd_write_part(DCR *dcr);
112 bool    dvd_close_job(DCR *dcr);
113 void    make_mounted_dvd_filename(DEVICE *dev, POOL_MEM &archive_name);
114 void    make_spooled_dvd_filename(DEVICE *dev, POOL_MEM &archive_name);
115 bool    truncate_dvd(DCR *dcr);
116 bool    check_can_write_on_non_blank_dvd(DCR *dcr);
117 int     find_num_dvd_parts(DCR *dcr);
118 boffset_t   lseek_dvd(DCR *dcr, boffset_t offset, int whence);
119 void    dvd_remove_empty_part(DCR *dcr);
120
121 /* From device.c */
122 bool     open_device(DCR *dcr);
123 bool     first_open_device(DCR *dcr);
124 bool     fixup_device_block_write_error(DCR *dcr, int retries=4);
125 void     set_start_vol_position(DCR *dcr);
126 void     set_new_volume_parameters(DCR *dcr);
127 void     set_new_file_parameters(DCR *dcr);
128
129 /* From dircmd.c */
130 void     *handle_connection_request(void *arg);
131
132
133 /* From fd_cmds.c */
134 void     run_job(JCR *jcr);
135 void     do_fd_commands(JCR *jcr);
136 bool     do_handle_command(JCR *jcr);
137 void     do_client_commands(JCR *jcr);
138
139 /* From job.c */
140 void     stored_free_jcr(JCR *jcr);
141
142 /* From hello.c */
143 bool     validate_dir_hello(JCR* jcr);
144 bool     send_hello_ok(BSOCK *bs);
145 bool     send_sorry(BSOCK *bs);
146 bool     send_hello_sd(JCR *jcr, char *Job);
147 bool     send_hello_client(JCR *jcr, char *Job);
148 bool     read_client_hello(JCR *jcr);
149 bool     is_client_connection(BSOCK *bs);
150 void     handle_client_connection(BSOCK *fd);
151
152 /* From label.c */
153 int      read_dev_volume_label(DCR *dcr);
154 int      read_dvd_volume_label(DCR *dcr, bool write);
155 void     create_session_label(DCR *dcr, DEV_RECORD *rec, int label);
156 void     create_volume_header(DEVICE *dev, const char *VolName, const char *PoolName, bool dvdnow);
157 #define ANSI_VOL_LABEL 0
158 #define ANSI_EOF_LABEL 1
159 #define ANSI_EOV_LABEL 2
160 bool     write_ansi_ibm_labels(DCR *dcr, int type, const char *VolName);
161 int      read_ansi_ibm_label(DCR *dcr);
162 bool     write_session_label(DCR *dcr, int label);
163 void     dump_volume_label(DEVICE *dev);
164 int      dump_label_record(DEVICE *dev, DEV_RECORD *rec, int verbose, bool check_err);
165 bool     unser_volume_label(DEVICE *dev, DEV_RECORD *rec);
166 bool     unser_session_label(SESSION_LABEL *label, DEV_RECORD *rec);
167 bool     write_new_volume_label_to_dev(DCR *dcr, const char *VolName,
168             const char *PoolName, bool relabel, bool dvdnow);
169
170 /* From locks.c */
171 void     _lock_device(const char *file, int line, DEVICE *dev);
172 void     _unlock_device(const char *file, int line, DEVICE *dev);
173 void     _block_device(const char *file, int line, DEVICE *dev, int state);
174 void     _unblock_device(const char *file, int line, DEVICE *dev);
175 void     _steal_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold, int state);
176 void     _give_back_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold);
177
178
179 /* From match_bsr.c */
180 int      match_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec,
181               SESSION_LABEL *sesrec, JCR *jcr);
182 int      match_bsr_block(BSR *bsr, DEV_BLOCK *block);
183 void     position_bsr_block(BSR *bsr, DEV_BLOCK *block);
184 BSR     *find_next_bsr(BSR *root_bsr, DEVICE *dev);
185 bool     is_this_bsr_done(BSR *bsr, DEV_RECORD *rec);
186 uint64_t get_bsr_start_addr(BSR *bsr,
187                             uint32_t *file=NULL,
188                             uint32_t *block=NULL);
189
190
191 /* From mount.c */
192 bool     mount_next_read_volume(DCR *dcr);
193
194 /* From parse_bsr.c */
195 BSR     *parse_bsr(JCR *jcr, char *lf);
196 void     dump_bsr(BSR *bsr, bool recurse);
197 void     free_bsr(BSR *bsr);
198 void     free_restore_volume_list(JCR *jcr);
199 void     create_restore_volume_list(JCR *jcr);
200
201 /* From record.c */
202 const char *FI_to_ascii(char *buf, int fi);
203 const char *stream_to_ascii(char *buf, int stream, int fi);
204 bool        write_record_to_block(DCR *dcr, DEV_RECORD *rec);
205 bool        can_write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec);
206 bool        read_record_from_block(DCR *dcr, DEV_RECORD *rec);
207 DEV_RECORD *new_record();
208 void        free_record(DEV_RECORD *rec);
209 void        empty_record(DEV_RECORD *rec);
210 uint64_t    get_record_address(DEV_RECORD *rec);
211 bool        flush_adata_to_device(DCR *dcr);
212
213 /* From read_record.c */
214 bool read_records(DCR *dcr,
215        bool record_cb(DCR *dcr, DEV_RECORD *rec),
216        bool mount_cb(DCR *dcr));
217
218 /* From reserve.c */
219 void    init_reservations_lock();
220 void    term_reservations_lock();
221 void    send_drive_reserve_messages(JCR *jcr, void sendit(const char *msg, int len, void *sarg), void *arg);
222 bool    find_suitable_device_for_job(JCR *jcr, RCTX &rctx);
223 int     search_res_for_device(RCTX &rctx);
224 void    release_reserve_messages(JCR *jcr);
225
226 extern int reservations_lock_count;
227
228 /* From status.c */
229 void    _dbg_list_one_device(DEVICE *dev, const char *f, int l);
230 #define dbg_list_one_device(x, dev) if (chk_dbglvl(x))     \
231         _dbg_list_one_device(dev, __FILE__, __LINE__)
232
233 /* From vol_mgr.c */
234 void    init_vol_list_lock();
235 void    term_vol_list_lock();
236 VOLRES *reserve_volume(DCR *dcr, const char *VolumeName);
237 bool    free_volume(DEVICE *dev);
238 bool    is_vol_list_empty();
239 dlist  *dup_vol_list(JCR *jcr);
240 void    free_temp_vol_list(dlist *temp_vol_list);
241 bool    volume_unused(DCR *dcr);
242 void    create_volume_lists();
243 void    free_volume_lists();
244 void    list_volumes(void sendit(const char *msg, int len, void *sarg), void *arg);
245 bool    is_volume_in_use(DCR *dcr);
246 extern  int vol_list_lock_count;
247 void    add_read_volume(JCR *jcr, const char *VolumeName);
248 void    remove_read_volume(JCR *jcr, const char *VolumeName);
249
250
251 /* From spool.c */
252 bool    begin_data_spool          (DCR *dcr);
253 bool    discard_data_spool        (DCR *dcr);
254 bool    commit_data_spool         (DCR *dcr);
255 bool    are_attributes_spooled    (JCR *jcr);
256 bool    begin_attribute_spool     (JCR *jcr);
257 bool    discard_attribute_spool   (JCR *jcr);
258 bool    commit_attribute_spool    (JCR *jcr);
259 bool    write_block_to_spool_file (DCR *dcr);
260 void    list_spool_stats          (void sendit(const char *msg, int len, void *sarg), void *arg);
261
262 /* From wait.c */
263 int wait_for_sysop(DCR *dcr);
264 bool wait_for_any_device(JCR *jcr, int &retries);
265 bool wait_for_device(DCR *dcr, int &retries);
266
267 /* stored_conf.c */
268 void store_devtype(LEX *lc, RES_ITEM *item, int index, int pass);
269 void store_maxblocksize(LEX *lc, RES_ITEM *item, int index, int pass);