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);
52 bool dir_update_device(JCR *jcr, DEVICE *dev);
53 bool dir_update_changer(JCR *jcr, AUTOCHANGER *changer);
56 int authenticate_director(JCR *jcr);
57 int authenticate_filed(JCR *jcr);
59 /* From autochanger.c */
60 int autoload_device(DCR *dcr, int writing, BSOCK *dir);
61 bool autochanger_cmd(DCR *dcr, BSOCK *dir, const char *cmd);
62 void mark_volume_not_inchanger(DCR *dcr);
63 char *edit_device_codes(DCR *dcr, char *omsg, const char *cmd);
66 void dump_block(DEV_BLOCK *b, const char *msg);
67 DEV_BLOCK *new_block(DEVICE *dev);
68 DEV_BLOCK *dup_block(DEV_BLOCK *eblock);
69 void init_block_write(DEV_BLOCK *block);
70 void empty_block(DEV_BLOCK *block);
71 void free_block(DEV_BLOCK *block);
72 bool write_block_to_device(DCR *dcr);
73 bool write_block_to_dev(DCR *dcr);
74 void print_block_read_errors(JCR *jcr, DEV_BLOCK *block);
75 void ser_block_header(DEV_BLOCK *block);
77 #define CHECK_BLOCK_NUMBERS true
78 #define NO_BLOCK_NUMBER_CHECK false
79 bool read_block_from_device(DCR *dcr, bool check_block_numbers);
80 bool read_block_from_dev(DCR *dcr, bool check_block_numbers);
82 /* From butil.c -- utilities for SD tool programs */
83 void print_ls_output(const char *fname, const char *link, int type, struct stat *statp);
84 JCR *setup_jcr(const char *name, char *dev_name, BSR *bsr,
85 const char *VolumeName, int mode);
86 void display_tape_error_status(JCR *jcr, DEVICE *dev);
90 DEVICE *init_dev(JCR *jcr, DEVICE *dev, DEVRES *device);
91 int open_dev(DEVICE *dev, char *VolName, int mode);
92 off_t lseek_dev(DEVICE *dev, off_t offset, int whence);
93 int open_first_part(DEVICE *dev);
94 int open_next_part(DEVICE *dev);
95 int open_guess_name_dev(DEVICE *dev);
96 void close_dev(DEVICE *dev);
97 void force_close_dev(DEVICE *dev);
98 bool truncate_dev(DEVICE *dev);
99 void term_dev(DEVICE *dev);
100 char * strerror_dev(DEVICE *dev);
101 void clrerror_dev(DEVICE *dev, int func);
102 bool update_pos_dev(DEVICE *dev);
103 bool rewind_dev(DEVICE *dev);
104 bool load_dev(DEVICE *dev);
105 bool offline_dev(DEVICE *dev);
106 int flush_dev(DEVICE *dev);
107 int weof_dev(DEVICE *dev, int num);
108 int write_block(DEVICE *dev);
109 uint32_t status_dev(DEVICE *dev);
110 bool eod_dev(DEVICE *dev);
111 bool fsf_dev(DEVICE *dev, int num);
112 bool fsr_dev(DEVICE *dev, int num);
113 bool bsf_dev(DEVICE *dev, int num);
114 bool bsr_dev(DEVICE *dev, int num);
115 void attach_jcr_to_device(DEVICE *dev, JCR *jcr);
116 void detach_jcr_from_device(DEVICE *dev, JCR *jcr);
117 JCR *next_attached_jcr(DEVICE *dev, JCR *jcr);
118 bool dev_can_write(DEVICE *dev);
119 bool offline_or_rewind_dev(DEVICE *dev);
120 bool reposition_dev(DEVICE *dev, uint32_t file, uint32_t block);
121 void init_dev_wait_timers(DEVICE *dev);
122 bool double_dev_wait_time(DEVICE *dev);
124 /* Get info about device */
125 char * dev_vol_name(DEVICE *dev);
126 uint32_t dev_block(DEVICE *dev);
127 uint32_t dev_file(DEVICE *dev);
128 bool dev_is_tape(DEVICE *dev);
131 bool open_device(DCR *dcr);
132 bool first_open_device(DEVICE *dev);
133 bool fixup_device_block_write_error(DCR *dcr);
134 void _lock_device(const char *file, int line, DEVICE *dev);
135 void _unlock_device(const char *file, int line, DEVICE *dev);
136 void _block_device(const char *file, int line, DEVICE *dev, int state);
137 void _unblock_device(const char *file, int line, DEVICE *dev);
138 void _steal_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold, int state);
139 void _give_back_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold);
140 void set_new_volume_parameters(DCR *dcr);
141 void set_new_file_parameters(DCR *dcr);
142 bool device_is_unmounted(DEVICE *dev);
143 void dev_lock(DEVICE *dev);
144 void dev_unlock(DEVICE *dev);
145 const char *edit_blocked_reason(DEVICE *dev);
148 void *handle_connection_request(void *arg);
152 void run_job(JCR *jcr);
153 bool bootstrap_cmd(JCR *jcr);
156 void stored_free_jcr(JCR *jcr);
157 void connection_from_filed(void *arg);
158 void handle_filed_connection(BSOCK *fd, char *job_name);
161 int read_dev_volume_label(DCR *dcr);
162 int read_dev_volume_label_guess(DCR *dcr, bool write);
163 void create_session_label(DCR *dcr, DEV_RECORD *rec, int label);
164 void create_volume_label(DEVICE *dev, const char *VolName, const char *PoolName);
165 bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName, const char *PoolName);
166 #define ANSI_VOL_LABEL 0
167 #define ANSI_EOF_LABEL 1
168 #define ANSI_EOV_LABEL 2
169 bool write_ansi_ibm_labels(DCR *dcr, int type, const char *VolName);
170 int read_ansi_ibm_label(DCR *dcr);
171 bool write_session_label(DCR *dcr, int label);
172 bool write_volume_label_to_block(DCR *dcr);
173 bool rewrite_volume_label(DCR *dcr, bool recycle);
174 void dump_volume_label(DEVICE *dev);
175 void dump_label_record(DEVICE *dev, DEV_RECORD *rec, int verbose);
176 bool unser_volume_label(DEVICE *dev, DEV_RECORD *rec);
177 bool unser_session_label(SESSION_LABEL *label, DEV_RECORD *rec);
179 /* From match_bsr.c */
180 int match_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec,
181 SESSION_LABEL *sesrec);
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 match_set_eof(BSR *bsr, DEV_RECORD *rec);
188 bool mount_next_write_volume(DCR *dcr, bool release);
189 bool mount_next_read_volume(DCR *dcr);
190 void release_volume(DCR *ddr);
191 void mark_volume_in_error(DCR *dcr);
193 /* From parse_bsr.c */
194 BSR *parse_bsr(JCR *jcr, char *lf);
195 void dump_bsr(BSR *bsr, bool recurse);
196 void free_bsr(BSR *bsr);
198 int add_vol(JCR *jcr, VOL_LIST *vol);
199 void free_vol_list(JCR *jcr);
200 void create_vol_list(JCR *jcr);
203 const char *FI_to_ascii(int fi);
204 const char *stream_to_ascii(int stream, int fi);
205 bool write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec);
206 bool can_write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec);
207 bool read_record_from_block(DEV_BLOCK *block, DEV_RECORD *rec);
208 DEV_RECORD *new_record();
209 void free_record(DEV_RECORD *rec);
210 void empty_record(DEV_RECORD *rec);
212 /* From read_record.c */
213 bool read_records(DCR *dcr,
214 bool record_cb(DCR *dcr, DEV_RECORD *rec),
215 bool mount_cb(DCR *dcr));
218 bool begin_data_spool (DCR *dcr);
219 bool discard_data_spool (DCR *dcr);
220 bool commit_data_spool (DCR *dcr);
221 bool are_attributes_spooled (JCR *jcr);
222 bool begin_attribute_spool (JCR *jcr);
223 bool discard_attribute_spool (JCR *jcr);
224 bool commit_attribute_spool (JCR *jcr);
225 bool write_block_to_spool_file (DCR *dcr);
226 void list_spool_stats (BSOCK *bs);
229 int wait_for_sysop(DCR *dcr);