]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/stored/protos.h
- Continue implementing migration.
[bacula/bacula] / bacula / src / stored / protos.h
1 /*
2  * Protypes for stored
3  *
4  *   Version $Id$
5  */
6 /*
7    Copyright (C) 2000-2006 Kern Sibbald
8
9    This program is free software; you can redistribute it and/or
10    modify it under the terms of the GNU General Public License
11    version 2 as amended with additional clauses defined in the
12    file LICENSE in the main source directory.
13
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
17    the file LICENSE for additional details.
18
19  */
20
21 /* From stored.c */
22 uint32_t new_VolSessionId();
23
24 /* From acquire.c */
25 DCR     *acquire_device_for_append(DCR *dcr);
26 DCR     *acquire_device_for_read(DCR *dcr);
27 bool     release_device(DCR *dcr);
28 DCR     *new_dcr(JCR *jcr, DEVICE *dev);
29 void     free_dcr(DCR *dcr);
30
31 /* From askdir.c */
32 enum get_vol_info_rw {
33    GET_VOL_INFO_FOR_WRITE,
34    GET_VOL_INFO_FOR_READ
35 };
36 bool    dir_get_volume_info(DCR *dcr, enum get_vol_info_rw);
37 bool    dir_find_next_appendable_volume(DCR *dcr);
38 bool    dir_update_volume_info(DCR *dcr, bool label);
39 bool    dir_ask_sysop_to_create_appendable_volume(DCR *dcr);
40 bool    dir_ask_sysop_to_mount_volume(DCR *dcr);
41 bool    dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec);
42 bool    dir_send_job_status(JCR *jcr);
43 bool    dir_create_jobmedia_record(DCR *dcr);
44 bool    dir_update_device(JCR *jcr, DEVICE *dev);
45 bool    dir_update_changer(JCR *jcr, AUTOCHANGER *changer);
46
47 /* authenticate.c */
48 int     authenticate_director(JCR *jcr);
49 int     authenticate_filed(JCR *jcr);
50
51 /* From autochanger.c */
52 bool     init_autochangers();
53 int      autoload_device(DCR *dcr, int writing, BSOCK *dir);
54 bool     autochanger_cmd(DCR *dcr, BSOCK *dir, const char *cmd);
55 bool     unload_autochanger(DCR *dcr, int loaded);
56 char    *edit_device_codes(DCR *dcr, char *omsg, const char *imsg, const char *cmd);
57 int      get_autochanger_loaded_slot(DCR *dcr);
58
59 /* From block.c */
60 void    dump_block(DEV_BLOCK *b, const char *msg);
61 DEV_BLOCK *new_block(DEVICE *dev);
62 DEV_BLOCK *dup_block(DEV_BLOCK *eblock);
63 void    init_block_write(DEV_BLOCK *block);
64 void    empty_block(DEV_BLOCK *block);
65 void    free_block(DEV_BLOCK *block);
66 bool    write_block_to_device(DCR *dcr);
67 bool    write_block_to_dev(DCR *dcr);
68 void    print_block_read_errors(JCR *jcr, DEV_BLOCK *block);
69 void    ser_block_header(DEV_BLOCK *block);
70
71 #define CHECK_BLOCK_NUMBERS    true
72 #define NO_BLOCK_NUMBER_CHECK  false
73 bool    read_block_from_device(DCR *dcr, bool check_block_numbers);
74 bool    read_block_from_dev(DCR *dcr, bool check_block_numbers);
75
76 /* From butil.c -- utilities for SD tool programs */
77 void    print_ls_output(const char *fname, const char *link, int type, struct stat *statp);
78 JCR    *setup_jcr(const char *name, char *dev_name, BSR *bsr,
79                   const char *VolumeName, int mode);
80 void    display_tape_error_status(JCR *jcr, DEVICE *dev);
81
82
83 /* From dev.c */
84 DEVICE  *init_dev(JCR *jcr, DEVRES *device);
85 off_t    lseek_dev(DEVICE *dev, off_t offset, int whence);
86 bool     can_open_mounted_dev(DEVICE *dev);
87 bool     truncate_dev(DCR *dcr);
88 void     term_dev(DEVICE *dev);
89 char *   strerror_dev(DEVICE *dev);
90 void     clrerror_dev(DEVICE *dev, int func);
91 bool     update_pos_dev(DEVICE *dev);
92 bool     rewind_dev(DEVICE *dev);
93 bool     load_dev(DEVICE *dev);
94 int      flush_dev(DEVICE *dev);
95 int      weof_dev(DEVICE *dev, int num);
96 int      write_block(DEVICE *dev);
97 uint32_t status_dev(DEVICE *dev);
98 bool     eod_dev(DEVICE *dev);
99 bool     fsf_dev(DEVICE *dev, int num);
100 bool     bsf_dev(DEVICE *dev, int num);
101 bool     bsr_dev(DEVICE *dev, int num);
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 bool     reposition_dev(DEVICE *dev, uint32_t file, uint32_t block);
106 void     init_device_wait_timers(DCR *dcr);
107 void     init_jcr_device_wait_timers(JCR *jcr);
108 bool     double_dev_wait_time(DEVICE *dev);
109
110 /* Get info about device */
111 char *   dev_vol_name(DEVICE *dev);
112 uint32_t dev_block(DEVICE *dev);
113 uint32_t dev_file(DEVICE *dev);
114
115 /* From dvd.c */
116 int  dvd_open_next_part(DCR *dcr);
117 bool dvd_write_part(DCR *dcr); 
118 bool dvd_close_job(DCR *dcr);
119 bool mount_dvd(DEVICE* dev, int timeout);
120 bool unmount_dvd(DEVICE* dev, int timeout);
121 void update_free_space_dev(DEVICE *dev);
122 void make_mounted_dvd_filename(DEVICE *dev, POOL_MEM &archive_name);
123 void make_spooled_dvd_filename(DEVICE *dev, POOL_MEM &archive_name);
124 bool truncate_dvd(DCR *dcr);
125 bool check_can_write_on_non_blank_dvd(DCR *dcr);
126
127 /* From device.c */
128 bool     open_device(DCR *dcr);
129 bool     first_open_device(DCR *dcr);
130 bool     fixup_device_block_write_error(DCR *dcr);
131 void     _lock_device(const char *file, int line, DEVICE *dev);
132 void     _unlock_device(const char *file, int line, DEVICE *dev);
133 void     _block_device(const char *file, int line, DEVICE *dev, int state);
134 void     _unblock_device(const char *file, int line, DEVICE *dev);
135 void     _steal_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold, int state);
136 void     _give_back_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold);
137 void     set_new_volume_parameters(DCR *dcr);
138 void     set_new_file_parameters(DCR *dcr);
139 bool     is_device_unmounted(DEVICE *dev);
140 void     dev_lock(DEVICE *dev);
141 void     dev_unlock(DEVICE *dev);
142
143 /* From dircmd.c */
144 void     *handle_connection_request(void *arg);
145
146
147 /* From fd_cmds.c */
148 void     run_job(JCR *jcr);
149 bool get_bootstrap_file(JCR *jcr, BSOCK *bsock);
150
151 /* From job.c */
152 void     stored_free_jcr(JCR *jcr);
153 void     connection_from_filed(void *arg);
154 void     handle_filed_connection(BSOCK *fd, char *job_name);
155
156 /* From label.c */
157 int      read_dev_volume_label(DCR *dcr);
158 int      read_dvd_volume_label(DCR *dcr, bool write);
159 void     create_session_label(DCR *dcr, DEV_RECORD *rec, int label);
160 void     create_volume_label(DEVICE *dev, const char *VolName, const char *PoolName);
161 bool     write_new_volume_label_to_dev(DCR *dcr, const char *VolName, const char *PoolName);
162 #define ANSI_VOL_LABEL 0
163 #define ANSI_EOF_LABEL 1
164 #define ANSI_EOV_LABEL 2
165 bool     write_ansi_ibm_labels(DCR *dcr, int type, const char *VolName);
166 int      read_ansi_ibm_label(DCR *dcr);
167 bool     write_session_label(DCR *dcr, int label);
168 bool     write_volume_label_to_block(DCR *dcr);
169 bool     rewrite_volume_label(DCR *dcr, bool recycle);
170 void     dump_volume_label(DEVICE *dev);
171 void     dump_label_record(DEVICE *dev, DEV_RECORD *rec, int verbose);
172 bool     unser_volume_label(DEVICE *dev, DEV_RECORD *rec);
173 bool     unser_session_label(SESSION_LABEL *label, DEV_RECORD *rec);
174
175 /* From match_bsr.c */
176 int      match_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec,
177               SESSION_LABEL *sesrec);
178 int      match_bsr_block(BSR *bsr, DEV_BLOCK *block);
179 void     position_bsr_block(BSR *bsr, DEV_BLOCK *block);
180 BSR     *find_next_bsr(BSR *root_bsr, DEVICE *dev);
181 bool     match_set_eof(BSR *bsr, DEV_RECORD *rec);
182
183 /* From mount.c */
184 bool     mount_next_write_volume(DCR *dcr, bool release);
185 bool     mount_next_read_volume(DCR *dcr);
186 void     mark_volume_in_error(DCR *dcr);
187
188 /* From parse_bsr.c */
189 BSR     *parse_bsr(JCR *jcr, char *lf);
190 void     dump_bsr(BSR *bsr, bool recurse);
191 void     free_bsr(BSR *bsr);
192 VOL_LIST *new_restore_volume();
193 int      add_restore_volume(JCR *jcr, VOL_LIST *vol);
194 void     free_restore_volume_list(JCR *jcr);
195 void     create_restore_volume_list(JCR *jcr);
196
197 /* From record.c */
198 const char *FI_to_ascii(char *buf, int fi);
199 const char *stream_to_ascii(char *buf, int stream, int fi);
200 bool        write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec);
201 bool        can_write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec);
202 bool        read_record_from_block(DEV_BLOCK *block, DEV_RECORD *rec);
203 DEV_RECORD *new_record();
204 void        free_record(DEV_RECORD *rec);
205 void        empty_record(DEV_RECORD *rec);
206
207 /* From read_record.c */
208 bool read_records(DCR *dcr,
209        bool record_cb(DCR *dcr, DEV_RECORD *rec),
210        bool mount_cb(DCR *dcr));
211
212 /* From reserve.c */
213 void    release_volume(DCR *dcr);
214 VOLRES *new_volume(DCR *dcr, const char *VolumeName);
215 VOLRES *find_volume(const char *VolumeName);
216 bool    free_volume(DEVICE *dev);
217 void    free_unused_volume(DCR *dcr);
218 void    create_volume_list();
219 void    free_volume_list();
220 void    list_volumes(BSOCK *user);
221 bool    is_volume_in_use(DCR *dcr);
222 void    send_drive_reserve_messages(JCR *jcr, BSOCK *user);
223
224
225 /* From spool.c */
226 bool    begin_data_spool          (DCR *dcr);
227 bool    discard_data_spool        (DCR *dcr);
228 bool    commit_data_spool         (DCR *dcr);
229 bool    are_attributes_spooled    (JCR *jcr);
230 bool    begin_attribute_spool     (JCR *jcr);
231 bool    discard_attribute_spool   (JCR *jcr);
232 bool    commit_attribute_spool    (JCR *jcr);
233 bool    write_block_to_spool_file (DCR *dcr);
234 void    list_spool_stats          (BSOCK *bs);
235
236 /* From wait.c */
237 int wait_for_sysop(DCR *dcr);
238 bool wait_for_device(JCR *jcr, bool first);