8 Copyright (C) 2000-2004 Kern Sibbald and John Walker
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 DCR *acquire_device_for_append(JCR *jcr);
32 DCR *acquire_device_for_read(JCR *jcr);
33 bool release_device(JCR *jcr);
34 DCR *new_dcr(JCR *jcr, DEVICE *dev);
35 void free_dcr(DCR *dcr);
38 enum get_vol_info_rw {
39 GET_VOL_INFO_FOR_WRITE,
42 bool dir_get_volume_info(DCR *dcr, enum get_vol_info_rw);
43 bool dir_find_next_appendable_volume(DCR *dcr);
44 bool dir_update_volume_info(DCR *dcr, bool label);
45 bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr);
46 bool dir_ask_sysop_to_mount_volume(DCR *dcr);
47 bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec);
48 bool dir_send_job_status(JCR *jcr);
49 bool dir_create_jobmedia_record(DCR *dcr);
52 int authenticate_director(JCR *jcr);
53 int authenticate_filed(JCR *jcr);
55 /* From autochanger.c */
56 int autoload_device(DCR *dcr, int writing, BSOCK *dir);
57 bool autochanger_list(DCR *dcr, BSOCK *dir);
58 void invalidate_slot_in_catalog(DCR *dcr);
59 char *edit_device_codes(JCR *jcr, char *omsg, const char *imsg, const char *cmd);
62 void dump_block(DEV_BLOCK *b, const char *msg);
63 DEV_BLOCK *new_block(DEVICE *dev);
64 DEV_BLOCK *dup_block(DEV_BLOCK *eblock);
65 void init_block_write(DEV_BLOCK *block);
66 void empty_block(DEV_BLOCK *block);
67 void free_block(DEV_BLOCK *block);
68 bool write_block_to_device(DCR *dcr);
69 bool write_block_to_dev(DCR *dcr);
70 void print_block_read_errors(JCR *jcr, DEV_BLOCK *block);
71 void ser_block_header(DEV_BLOCK *block);
73 #define CHECK_BLOCK_NUMBERS true
74 #define NO_BLOCK_NUMBER_CHECK false
75 bool read_block_from_device(DCR *dcr, bool check_block_numbers);
76 bool read_block_from_dev(DCR *dcr, bool check_block_numbers);
78 /* From butil.c -- utilities for SD tool programs */
79 void print_ls_output(const char *fname, const char *link, int type, struct stat *statp);
80 JCR *setup_jcr(const char *name, char *dev_name, BSR *bsr,
81 const char *VolumeName, int mode);
82 void display_tape_error_status(JCR *jcr, DEVICE *dev);
86 DEVICE *init_dev(DEVICE *dev, DEVRES *device);
87 int open_dev(DEVICE *dev, char *VolName, int mode);
88 void close_dev(DEVICE *dev);
89 void force_close_dev(DEVICE *dev);
90 bool truncate_dev(DEVICE *dev);
91 void term_dev(DEVICE *dev);
92 char * strerror_dev(DEVICE *dev);
93 void clrerror_dev(DEVICE *dev, int func);
94 bool update_pos_dev(DEVICE *dev);
95 bool rewind_dev(DEVICE *dev);
96 bool load_dev(DEVICE *dev);
97 bool offline_dev(DEVICE *dev);
98 int flush_dev(DEVICE *dev);
99 int weof_dev(DEVICE *dev, int num);
100 int write_block(DEVICE *dev);
101 uint32_t status_dev(DEVICE *dev);
102 int eod_dev(DEVICE *dev);
103 bool fsf_dev(DEVICE *dev, int num);
104 bool fsr_dev(DEVICE *dev, int num);
105 bool bsf_dev(DEVICE *dev, int num);
106 bool bsr_dev(DEVICE *dev, int num);
107 void attach_jcr_to_device(DEVICE *dev, JCR *jcr);
108 void detach_jcr_from_device(DEVICE *dev, JCR *jcr);
109 JCR *next_attached_jcr(DEVICE *dev, JCR *jcr);
110 bool dev_can_write(DEVICE *dev);
111 int offline_or_rewind_dev(DEVICE *dev);
112 bool reposition_dev(DEVICE *dev, uint32_t file, uint32_t block);
113 void init_dev_wait_timers(DEVICE *dev);
114 bool double_dev_wait_time(DEVICE *dev);
117 /* Get info about device */
118 char * dev_name(DEVICE *dev);
119 char * dev_vol_name(DEVICE *dev);
120 uint32_t dev_block(DEVICE *dev);
121 uint32_t dev_file(DEVICE *dev);
122 bool dev_is_tape(DEVICE *dev);
125 bool open_device(DCR *dcr);
126 bool first_open_device(DEVICE *dev);
127 bool fixup_device_block_write_error(DCR *dcr);
128 void _lock_device(const char *file, int line, DEVICE *dev);
129 void _unlock_device(const char *file, int line, DEVICE *dev);
130 void _block_device(const char *file, int line, DEVICE *dev, int state);
131 void _unblock_device(const char *file, int line, DEVICE *dev);
132 void _steal_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold, int state);
133 void _give_back_device_lock(const char *file, int line, DEVICE *dev, bsteal_lock_t *hold);
134 void set_new_volume_parameters(DCR *dcr);
135 void set_new_file_parameters(DCR *dcr);
136 bool device_is_unmounted(DEVICE *dev);
137 void dev_lock(DEVICE *dev);
138 void dev_unlock(DEVICE *dev);
139 const char *edit_blocked_reason(DEVICE *dev);
142 void *handle_connection_request(void *arg);
146 void run_job(JCR *jcr);
147 bool bootstrap_cmd(JCR *jcr);
150 void stored_free_jcr(JCR *jcr);
151 void connection_from_filed(void *arg);
152 void handle_filed_connection(BSOCK *fd, char *job_name);
155 int read_dev_volume_label(DCR *dcr);
156 void create_session_label(DCR *dcr, DEV_RECORD *rec, int label);
157 void create_volume_label(DEVICE *dev, const char *VolName, const char *PoolName);
158 bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName, const char *PoolName);
159 bool write_session_label(DCR *dcr, int label);
160 bool write_volume_label_to_block(DCR *dcr);
161 void dump_volume_label(DEVICE *dev);
162 void dump_label_record(DEVICE *dev, DEV_RECORD *rec, int verbose);
163 bool unser_volume_label(DEVICE *dev, DEV_RECORD *rec);
164 bool unser_session_label(SESSION_LABEL *label, DEV_RECORD *rec);
166 /* From match_bsr.c */
167 int match_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec,
168 SESSION_LABEL *sesrec);
169 int match_bsr_block(BSR *bsr, DEV_BLOCK *block);
170 void position_bsr_block(BSR *bsr, DEV_BLOCK *block);
171 BSR *find_next_bsr(BSR *root_bsr, DEVICE *dev);
172 bool match_set_eof(BSR *bsr, DEV_RECORD *rec);
175 bool mount_next_write_volume(DCR *dcr, bool release);
176 bool mount_next_read_volume(DCR *dcr);
177 void release_volume(DCR *ddr);
178 void mark_volume_in_error(DCR *dcr);
180 /* From parse_bsr.c */
181 BSR *parse_bsr(JCR *jcr, char *lf);
182 void dump_bsr(BSR *bsr, bool recurse);
183 void free_bsr(BSR *bsr);
185 int add_vol(JCR *jcr, VOL_LIST *vol);
186 void free_vol_list(JCR *jcr);
187 void create_vol_list(JCR *jcr);
190 const char *FI_to_ascii(int fi);
191 const char *stream_to_ascii(int stream, int fi);
192 bool write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec);
193 bool can_write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec);
194 bool read_record_from_block(DEV_BLOCK *block, DEV_RECORD *rec);
195 DEV_RECORD *new_record();
196 void free_record(DEV_RECORD *rec);
197 void empty_record(DEV_RECORD *rec);
199 /* From read_record.c */
200 bool read_records(DCR *dcr,
201 bool record_cb(DCR *dcr, DEV_RECORD *rec),
202 bool mount_cb(DCR *dcr));
205 bool begin_data_spool (JCR *jcr);
206 bool discard_data_spool (JCR *jcr);
207 bool commit_data_spool (JCR *jcr);
208 bool are_attributes_spooled (JCR *jcr);
209 bool begin_attribute_spool (JCR *jcr);
210 bool discard_attribute_spool (JCR *jcr);
211 bool commit_attribute_spool (JCR *jcr);
212 bool write_block_to_spool_file (DCR *dcr);
213 void list_spool_stats (BSOCK *bs);