8 Copyright (C) 2000-2005 Kern Sibbald
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2 of
13 the License, or (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public
21 License along with this program; if not, write to the Free
22 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
28 uint32_t new_VolSessionId();
31 bool reserve_device_for_append(JCR *jcr, DEVICE *dev);
32 DCR *acquire_device_for_append(JCR *jcr, DEVICE *dev);
33 bool reserve_device_for_read(JCR *jcr, DEVICE *dev);
34 DCR *acquire_device_for_read(JCR *jcr, DEVICE *dev);
35 bool release_device(DCR *dcr);
36 DCR *new_dcr(JCR *jcr, DEVICE *dev);
37 void free_dcr(DCR *dcr);
40 enum get_vol_info_rw {
41 GET_VOL_INFO_FOR_WRITE,
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);
47 bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr);
48 bool dir_ask_sysop_to_mount_volume(DCR *dcr);
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);
54 int authenticate_director(JCR *jcr);
55 int authenticate_filed(JCR *jcr);
57 /* From autochanger.c */
58 int autoload_device(DCR *dcr, int writing, BSOCK *dir);
59 bool autochanger_list(DCR *dcr, BSOCK *dir);
60 void mark_volume_not_inchanger(DCR *dcr);
61 char *edit_device_codes(DCR *dcr, char *omsg, const char *cmd);
64 void dump_block(DEV_BLOCK *b, const char *msg);
65 DEV_BLOCK *new_block(DEVICE *dev);
66 DEV_BLOCK *dup_block(DEV_BLOCK *eblock);
67 void init_block_write(DEV_BLOCK *block);
68 void empty_block(DEV_BLOCK *block);
69 void free_block(DEV_BLOCK *block);
70 bool write_block_to_device(DCR *dcr);
71 bool write_block_to_dev(DCR *dcr);
72 void print_block_read_errors(JCR *jcr, DEV_BLOCK *block);
73 void ser_block_header(DEV_BLOCK *block);
75 #define CHECK_BLOCK_NUMBERS true
76 #define NO_BLOCK_NUMBER_CHECK false
77 bool read_block_from_device(DCR *dcr, bool check_block_numbers);
78 bool read_block_from_dev(DCR *dcr, bool check_block_numbers);
80 /* From butil.c -- utilities for SD tool programs */
81 void print_ls_output(const char *fname, const char *link, int type, struct stat *statp);
82 JCR *setup_jcr(const char *name, char *dev_name, BSR *bsr,
83 const char *VolumeName, int mode);
84 void display_tape_error_status(JCR *jcr, DEVICE *dev);
88 DEVICE *init_dev(JCR *jcr, DEVICE *dev, DEVRES *device);
89 int open_dev(DEVICE *dev, char *VolName, int mode);
90 off_t lseek_dev(DEVICE *dev, off_t offset, int whence);
91 int open_first_part(DEVICE *dev);
92 int open_next_part(DEVICE *dev);
93 int open_guess_name_dev(DEVICE *dev);
94 void close_dev(DEVICE *dev);
95 void force_close_dev(DEVICE *dev);
96 bool truncate_dev(DEVICE *dev);
97 void term_dev(DEVICE *dev);
98 char * strerror_dev(DEVICE *dev);
99 void clrerror_dev(DEVICE *dev, int func);
100 bool update_pos_dev(DEVICE *dev);
101 bool rewind_dev(DEVICE *dev);
102 bool load_dev(DEVICE *dev);
103 bool offline_dev(DEVICE *dev);
104 int flush_dev(DEVICE *dev);
105 int weof_dev(DEVICE *dev, int num);
106 int write_block(DEVICE *dev);
107 uint32_t status_dev(DEVICE *dev);
108 int eod_dev(DEVICE *dev);
109 bool fsf_dev(DEVICE *dev, int num);
110 bool fsr_dev(DEVICE *dev, int num);
111 bool bsf_dev(DEVICE *dev, int num);
112 bool bsr_dev(DEVICE *dev, int num);
113 void attach_jcr_to_device(DEVICE *dev, JCR *jcr);
114 void detach_jcr_from_device(DEVICE *dev, JCR *jcr);
115 JCR *next_attached_jcr(DEVICE *dev, JCR *jcr);
116 bool dev_can_write(DEVICE *dev);
117 bool offline_or_rewind_dev(DEVICE *dev);
118 bool reposition_dev(DEVICE *dev, uint32_t file, uint32_t block);
119 void init_dev_wait_timers(DEVICE *dev);
120 bool double_dev_wait_time(DEVICE *dev);
122 /* Get info about device */
123 char * dev_name(DEVICE *dev);
124 char * dev_vol_name(DEVICE *dev);
125 uint32_t dev_block(DEVICE *dev);
126 uint32_t dev_file(DEVICE *dev);
127 bool dev_is_tape(DEVICE *dev);
130 bool open_device(DCR *dcr);
131 bool first_open_device(DEVICE *dev);
132 bool fixup_device_block_write_error(DCR *dcr);
133 void _lock_device(const char *file, int line, DEVICE *dev);
134 void _unlock_device(const char *file, int line, DEVICE *dev);
135 void _block_device(const char *file, int line, DEVICE *dev, int state);
136 void _unblock_device(const char *file, int line, DEVICE *dev);
137 void _steal_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold, int state);
138 void _give_back_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold);
139 void set_new_volume_parameters(DCR *dcr);
140 void set_new_file_parameters(DCR *dcr);
141 bool device_is_unmounted(DEVICE *dev);
142 void dev_lock(DEVICE *dev);
143 void dev_unlock(DEVICE *dev);
144 const char *edit_blocked_reason(DEVICE *dev);
147 void *handle_connection_request(void *arg);
151 void run_job(JCR *jcr);
152 bool bootstrap_cmd(JCR *jcr);
155 void stored_free_jcr(JCR *jcr);
156 void connection_from_filed(void *arg);
157 void handle_filed_connection(BSOCK *fd, char *job_name);
160 int read_dev_volume_label(DCR *dcr);
161 int read_dev_volume_label_guess(DCR *dcr, bool write);
162 void create_session_label(DCR *dcr, DEV_RECORD *rec, int label);
163 void create_volume_label(DEVICE *dev, const char *VolName, const char *PoolName);
164 bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName, const char *PoolName);
165 bool write_ansi_ibm_label(DCR *dcr, 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);
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);
184 bool mount_next_write_volume(DCR *dcr, bool release);
185 bool mount_next_read_volume(DCR *dcr);
186 void release_volume(DCR *ddr);
187 void mark_volume_in_error(DCR *dcr);
189 /* From parse_bsr.c */
190 BSR *parse_bsr(JCR *jcr, char *lf);
191 void dump_bsr(BSR *bsr, bool recurse);
192 void free_bsr(BSR *bsr);
194 int add_vol(JCR *jcr, VOL_LIST *vol);
195 void free_vol_list(JCR *jcr);
196 void create_vol_list(JCR *jcr);
199 const char *FI_to_ascii(int fi);
200 const char *stream_to_ascii(int stream, int fi);
201 bool write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec);
202 bool can_write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec);
203 bool read_record_from_block(DEV_BLOCK *block, DEV_RECORD *rec);
204 DEV_RECORD *new_record();
205 void free_record(DEV_RECORD *rec);
206 void empty_record(DEV_RECORD *rec);
208 /* From read_record.c */
209 bool read_records(DCR *dcr,
210 bool record_cb(DCR *dcr, DEV_RECORD *rec),
211 bool mount_cb(DCR *dcr));
214 bool begin_data_spool (DCR *dcr);
215 bool discard_data_spool (DCR *dcr);
216 bool commit_data_spool (DCR *dcr);
217 bool are_attributes_spooled (JCR *jcr);
218 bool begin_attribute_spool (JCR *jcr);
219 bool discard_attribute_spool (JCR *jcr);
220 bool commit_attribute_spool (JCR *jcr);
221 bool write_block_to_spool_file (DCR *dcr);
222 void list_spool_stats (BSOCK *bs);