7 Copyright (C) 2000-2006 Kern Sibbald
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.
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.
22 uint32_t new_VolSessionId();
25 DCR *acquire_device_for_append(DCR *dcr);
26 bool 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 void detach_dcr_from_dev(DCR *dcr);
33 enum get_vol_info_rw {
34 GET_VOL_INFO_FOR_WRITE,
37 bool dir_get_volume_info(DCR *dcr, enum get_vol_info_rw);
38 bool dir_find_next_appendable_volume(DCR *dcr);
39 bool dir_update_volume_info(DCR *dcr, bool label);
40 bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr);
41 bool dir_ask_sysop_to_mount_volume(DCR *dcr);
42 bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec);
43 bool dir_send_job_status(JCR *jcr);
44 bool dir_create_jobmedia_record(DCR *dcr);
45 bool dir_update_device(JCR *jcr, DEVICE *dev);
46 bool dir_update_changer(JCR *jcr, AUTOCHANGER *changer);
49 int authenticate_director(JCR *jcr);
50 int authenticate_filed(JCR *jcr);
52 /* From autochanger.c */
53 bool init_autochangers();
54 int autoload_device(DCR *dcr, int writing, BSOCK *dir);
55 bool autochanger_cmd(DCR *dcr, BSOCK *dir, const char *cmd);
56 bool unload_autochanger(DCR *dcr, int loaded);
57 char *edit_device_codes(DCR *dcr, char *omsg, const char *imsg, const char *cmd);
58 int get_autochanger_loaded_slot(DCR *dcr);
61 void dump_block(DEV_BLOCK *b, const char *msg);
62 DEV_BLOCK *new_block(DEVICE *dev);
63 DEV_BLOCK *dup_block(DEV_BLOCK *eblock);
64 void init_block_write(DEV_BLOCK *block);
65 void empty_block(DEV_BLOCK *block);
66 void free_block(DEV_BLOCK *block);
67 bool write_block_to_device(DCR *dcr);
68 bool write_block_to_dev(DCR *dcr);
69 void print_block_read_errors(JCR *jcr, DEV_BLOCK *block);
70 void ser_block_header(DEV_BLOCK *block);
72 #define CHECK_BLOCK_NUMBERS true
73 #define NO_BLOCK_NUMBER_CHECK false
74 bool read_block_from_device(DCR *dcr, bool check_block_numbers);
75 bool read_block_from_dev(DCR *dcr, bool check_block_numbers);
77 /* From butil.c -- utilities for SD tool programs */
78 void print_ls_output(const char *fname, const char *link, int type, struct stat *statp);
79 JCR *setup_jcr(const char *name, char *dev_name, BSR *bsr,
80 const char *VolumeName, int mode);
81 void display_tape_error_status(JCR *jcr, DEVICE *dev);
85 DEVICE *init_dev(JCR *jcr, DEVRES *device);
86 bool can_open_mounted_dev(DEVICE *dev);
87 bool load_dev(DEVICE *dev);
88 int write_block(DEVICE *dev);
89 uint32_t status_dev(DEVICE *dev);
90 void attach_jcr_to_device(DEVICE *dev, JCR *jcr);
91 void detach_jcr_from_device(DEVICE *dev, JCR *jcr);
92 JCR *next_attached_jcr(DEVICE *dev, JCR *jcr);
93 void init_device_wait_timers(DCR *dcr);
94 void init_jcr_device_wait_timers(JCR *jcr);
95 bool double_dev_wait_time(DEVICE *dev);
97 /* Get info about device */
98 char * dev_vol_name(DEVICE *dev);
101 int dvd_open_next_part(DCR *dcr);
102 bool dvd_write_part(DCR *dcr);
103 bool dvd_close_job(DCR *dcr);
104 bool mount_dvd(DEVICE* dev, int timeout);
105 bool unmount_dvd(DEVICE* dev, int timeout);
106 bool update_free_space_dev(DEVICE *dev);
107 void make_mounted_dvd_filename(DEVICE *dev, POOL_MEM &archive_name);
108 void make_spooled_dvd_filename(DEVICE *dev, POOL_MEM &archive_name);
109 bool truncate_dvd(DCR *dcr);
110 bool check_can_write_on_non_blank_dvd(DCR *dcr);
111 int find_num_dvd_parts(DCR *dcr);
112 off_t lseek_dvd(DCR *dcr, off_t offset, int whence);
113 void dvd_remove_empty_part(DCR *dcr);
116 bool open_device(DCR *dcr);
117 bool first_open_device(DCR *dcr);
118 bool fixup_device_block_write_error(DCR *dcr);
119 void _lock_device(const char *file, int line, DEVICE *dev);
120 void _unlock_device(const char *file, int line, DEVICE *dev);
121 void _block_device(const char *file, int line, DEVICE *dev, int state);
122 void _unblock_device(const char *file, int line, DEVICE *dev);
123 void _steal_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold, int state);
124 void _give_back_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold);
125 void set_new_volume_parameters(DCR *dcr);
126 void set_new_file_parameters(DCR *dcr);
127 bool is_device_unmounted(DEVICE *dev);
128 void dev_lock(DEVICE *dev);
129 void dev_unlock(DEVICE *dev);
132 void *handle_connection_request(void *arg);
136 void run_job(JCR *jcr);
137 bool get_bootstrap_file(JCR *jcr, BSOCK *bsock);
140 void stored_free_jcr(JCR *jcr);
141 void connection_from_filed(void *arg);
142 void handle_filed_connection(BSOCK *fd, char *job_name);
145 int read_dev_volume_label(DCR *dcr);
146 int read_dvd_volume_label(DCR *dcr, bool write);
147 void create_session_label(DCR *dcr, DEV_RECORD *rec, int label);
148 void create_volume_label(DEVICE *dev, const char *VolName, const char *PoolName, bool dvdnow);
149 bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName,
150 const char *PoolName, bool relabel, bool dvdnow);
151 #define ANSI_VOL_LABEL 0
152 #define ANSI_EOF_LABEL 1
153 #define ANSI_EOV_LABEL 2
154 bool write_ansi_ibm_labels(DCR *dcr, int type, const char *VolName);
155 int read_ansi_ibm_label(DCR *dcr);
156 bool write_session_label(DCR *dcr, int label);
157 bool write_volume_label_to_block(DCR *dcr);
158 bool rewrite_volume_label(DCR *dcr, bool recycle);
159 void dump_volume_label(DEVICE *dev);
160 void dump_label_record(DEVICE *dev, DEV_RECORD *rec, int verbose);
161 bool unser_volume_label(DEVICE *dev, DEV_RECORD *rec);
162 bool unser_session_label(SESSION_LABEL *label, DEV_RECORD *rec);
164 /* From match_bsr.c */
165 int match_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec,
166 SESSION_LABEL *sesrec);
167 int match_bsr_block(BSR *bsr, DEV_BLOCK *block);
168 void position_bsr_block(BSR *bsr, DEV_BLOCK *block);
169 BSR *find_next_bsr(BSR *root_bsr, DEVICE *dev);
170 bool is_this_bsr_done(BSR *bsr, DEV_RECORD *rec);
173 bool mount_next_write_volume(DCR *dcr, bool release);
174 bool mount_next_read_volume(DCR *dcr);
175 void mark_volume_in_error(DCR *dcr);
177 /* From parse_bsr.c */
178 BSR *parse_bsr(JCR *jcr, char *lf);
179 void dump_bsr(BSR *bsr, bool recurse);
180 void free_bsr(BSR *bsr);
181 VOL_LIST *new_restore_volume();
182 int add_restore_volume(JCR *jcr, VOL_LIST *vol);
183 void free_restore_volume_list(JCR *jcr);
184 void create_restore_volume_list(JCR *jcr);
187 const char *FI_to_ascii(char *buf, int fi);
188 const char *stream_to_ascii(char *buf, int stream, int fi);
189 bool write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec);
190 bool can_write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec);
191 bool read_record_from_block(DEV_BLOCK *block, DEV_RECORD *rec);
192 DEV_RECORD *new_record();
193 void free_record(DEV_RECORD *rec);
194 void empty_record(DEV_RECORD *rec);
196 /* From read_record.c */
197 bool read_records(DCR *dcr,
198 bool record_cb(DCR *dcr, DEV_RECORD *rec),
199 bool mount_cb(DCR *dcr));
202 void init_reservations_lock();
203 void term_reservations_lock();
204 void lock_reservations();
205 void unlock_reservations();
206 void release_volume(DCR *dcr);
207 VOLRES *new_volume(DCR *dcr, const char *VolumeName);
208 VOLRES *find_volume(const char *VolumeName);
209 bool free_volume(DEVICE *dev);
210 void free_unused_volume(DCR *dcr);
211 void create_volume_list();
212 void free_volume_list();
213 void list_volumes(void sendit(const char *msg, int len, void *sarg), void *arg);
214 bool is_volume_in_use(DCR *dcr);
215 void send_drive_reserve_messages(JCR *jcr, void sendit(const char *msg, int len, void *sarg), void *arg);
216 bool find_suitable_device_for_job(JCR *jcr, RCTX &rctx);
217 int search_res_for_device(RCTX &rctx);
218 void release_msgs(JCR *jcr);
222 bool begin_data_spool (DCR *dcr);
223 bool discard_data_spool (DCR *dcr);
224 bool commit_data_spool (DCR *dcr);
225 bool are_attributes_spooled (JCR *jcr);
226 bool begin_attribute_spool (JCR *jcr);
227 bool discard_attribute_spool (JCR *jcr);
228 bool commit_attribute_spool (JCR *jcr);
229 bool write_block_to_spool_file (DCR *dcr);
230 void list_spool_stats (void sendit(const char *msg, int len, void *sarg), void *arg);
233 int wait_for_sysop(DCR *dcr);
234 bool wait_for_device(JCR *jcr, bool first);