/* From stored.c */
uint32_t new_VolSessionId();
+/* From acquire.c */
+int acquire_device_for_append(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
+int acquire_device_for_read(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
+int release_device(JCR *jcr, DEVICE *dev);
+
/* From askdir.c */
-int dir_get_volume_info(JCR *jcr);
+int dir_get_volume_info(JCR *jcr, int writing);
int dir_find_next_appendable_volume(JCR *jcr);
int dir_update_volume_info(JCR *jcr, VOLUME_CAT_INFO *vol, int relabel);
int dir_ask_sysop_to_mount_next_volume(JCR *jcr, DEVICE *dev);
int dir_ask_sysop_to_mount_volume(JCR *jcr, DEVICE *dev);
int dir_update_file_attributes(JCR *jcr, DEV_RECORD *rec);
int dir_send_job_status(JCR *jcr);
-int dir_create_job_media_record(JCR *jcr);
+int dir_create_jobmedia_record(JCR *jcr);
/* authenticate.c */
int authenticate_director(JCR *jcr);
void empty_block(DEV_BLOCK *block);
void free_block(DEV_BLOCK *block);
int write_block_to_device(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
-int write_block_to_dev(DEVICE *dev, DEV_BLOCK *block);
+int write_block_to_dev(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
int read_block_from_device(DEVICE *dev, DEV_BLOCK *block);
int read_block_from_dev(DEVICE *dev, DEV_BLOCK *block);
+/* From butil.c -- utilities for SD tool programs */
+void print_ls_output(char *fname, char *link, int type, struct stat *statp);
+JCR *setup_jcr(char *name, char *device, BSR *bsr);
+DEVICE *setup_to_access_device(JCR *jcr, int read_access);
+void display_error_status(DEVICE *dev);
+DEVRES *find_device_res(char *device_name, int read_access);
+
/* From dev.c */
-DEVICE *init_dev(DEVICE *dev, char *device);
+DEVICE *init_dev(DEVICE *dev, DEVRES *device);
int open_dev(DEVICE *dev, char *VolName, int mode);
void close_dev(DEVICE *dev);
void force_close_dev(DEVICE *dev);
int fsr_dev(DEVICE *dev, int num);
int bsf_dev(DEVICE *dev, int num);
int bsr_dev(DEVICE *dev, int num);
+void attach_jcr_to_device(DEVICE *dev, JCR *jcr);
+void detach_jcr_from_device(DEVICE *dev, JCR *jcr);
+JCR *next_attached_jcr(DEVICE *dev, JCR *jcr);
+
/* Get info about device */
char * dev_name(DEVICE *dev);
/* From device.c */
int open_device(DEVICE *dev);
-int acquire_device_for_append(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
-int acquire_device_for_read(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
-int ready_dev_for_read(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
-int release_device(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
-void block_device(DEVICE *dev, int state);
-void unblock_device(DEVICE *dev);
-void lock_device(DEVICE *dev);
-void unlock_device(DEVICE *dev);
int fixup_device_block_write_error(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
+void _lock_device(char *file, int line, DEVICE *dev);
+void _unlock_device(char *file, int line, DEVICE *dev);
+void _block_device(char *file, int line, DEVICE *dev, int state);
+void _unblock_device(char *file, int line, DEVICE *dev);
+void _steal_device_lock(char *file, int line, DEVICE *dev, bsteal_lock_t *hold, int state);
+void _return_device_lock(char *file, int line, DEVICE *dev, bsteal_lock_t *hold);
+
+/* don't use */
+void _new_lock_device(char *file, int line, DEVICE *dev);
+void _new_lock_device(char *file, int line, DEVICE *dev, int state);
+void _new_unlock_device(char *file, int line, DEVICE *dev);
+void new_steal_device_lock(DEVICE *dev, brwsteal_t *hold, int state);
+void new_return_device_lock(DEVICE *dev, brwsteal_t *hold);
/* From dircmd.c */
void connection_request(void *arg);
int match_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec,
SESSION_LABEL *sesrec);
+/* From mount.c */
+int mount_next_write_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, int release);
+int mount_next_read_volume(JCR *jcr, DEVICE *dev, DEV_BLOCK *block);
+int autoload_device(JCR *jcr, DEVICE *dev, int writing, BSOCK *dir);
+
+
/* From parse_bsr.c */
-extern BSR *parse_bsr(char *lf);
+extern BSR *parse_bsr(JCR *jcr, char *lf);
extern void dump_bsr(BSR *bsr);
extern void free_bsr(BSR *bsr);
extern VOL_LIST *new_vol();
/* From record.c */
char *FI_to_ascii(int fi);
-char *stream_to_ascii(int stream);
+char *stream_to_ascii(int stream, int fi);
int write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec);
+int can_write_record_to_block(DEV_BLOCK *block, DEV_RECORD *rec);
int read_record_from_block(DEV_BLOCK *block, DEV_RECORD *rec);
DEV_RECORD *new_record();
void free_record(DEV_RECORD *rec);
-int read_record(DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *record);
-int write_record_device(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *record);
+
+/* From read_record.c */
+int read_records(JCR *jcr, DEVICE *dev,
+ void record_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block, DEV_RECORD *rec),
+ int mount_cb(JCR *jcr, DEVICE *dev, DEV_BLOCK *block));