} bsteal_lock_t;
struct DEVRES; /* Device resource defined in stored_conf.h */
+int weof_dev(DEVICE *dev, int num);
+bool rewind_dev(DEVICE *dev);
/*
* Device structure definition. There is one of these for
/* New access control in process of being implemented */
brwlock_t lock; /* New mutual exclusion lock */
- int use_count; /* usage count on this device */
+ int use_count; /* usage count on this device 0 or 1 */
int fd; /* file descriptor */
int capabilities; /* capabilities mask */
int state; /* state mask */
int mode; /* read/write modes */
int openmode; /* parameter passed to open_dev (useful to reopen the device) */
bool autoselect; /* Autoselect in autochanger */
+ bool open_nowait; /* If set, don t wait on open */
int label_type; /* Bacula/ANSI/IBM label types */
uint32_t drive_index; /* Autochanger drive index */
- POOLMEM *dev_name; /* device name */
+ POOLMEM *dev_name; /* Physical device name */
+ POOLMEM *prt_name; /* Name used for display purposes */
char *errmsg; /* nicely edited error message */
uint32_t block_num; /* current block number base 0 */
uint32_t file; /* current file number base 0 */
uint64_t max_file_size; /* max file size to put in one file on volume */
uint64_t volume_capacity; /* advisory capacity */
uint64_t max_spool_size; /* maximum spool file size */
- uint64_t spool_size; /* current spool size */
+ uint64_t spool_size; /* current spool size for this device */
uint32_t max_rewind_wait; /* max secs to allow for rewind */
uint32_t max_open_wait; /* max secs to allow for open */
uint32_t max_open_vols; /* max simultaneous open volumes */
VOLUME_CAT_INFO VolCatInfo; /* Volume Catalog Information */
VOLUME_LABEL VolHdr; /* Actual volume label */
+ char pool_name[MAX_NAME_LENGTH]; /* pool name */
+ char pool_type[MAX_NAME_LENGTH]; /* pool type */
+
+
+
+
/* Device wait times ***FIXME*** look at durations */
char BadVolName[MAX_NAME_LENGTH]; /* Last wrong Volume mounted */
int num_wait;
/* Methods */
- int is_tape() const;
- int is_file() const;
- int is_fifo() const;
- int is_dvd() const;
- int is_open() const;
- int is_offline() const;
- int is_labeled() const;
+ int is_tape() const { return state & ST_TAPE; }
+ int is_file() const { return state & ST_FILE; }
+ int is_fifo() const { return state & ST_FIFO; }
+ int is_dvd() const { return state & ST_DVD; }
+ int is_open() const { return state & ST_OPENED; }
+ int is_offline() const { return state & ST_OFFLINE; }
+ int is_labeled() const { return state & ST_LABEL; }
int is_busy() const; /* either reading or writing */
- int at_eof() const;
- int at_eom() const;
- int at_eot() const;
- int can_append() const;
- int can_read() const;
+ int at_eof() const { return state & ST_EOF; }
+ int at_eot() const { return state & ST_EOT; }
+ int at_weot() const { return state & ST_WEOT; }
+ int can_append() const { return state & ST_APPEND; }
+ /*
+ * can_write() is meant for checking at the end of a job to see
+ * if we still have a tape (perhaps not if at end of tape
+ * and the job is canceled).
+ */
+ int can_write() const { return is_open() && can_append() &&
+ is_labeled() && !at_weot(); }
+ int can_read() const { return state & ST_READ; }
+ bool can_steal_lock() const { return dev_blocked &&
+ (dev_blocked == BST_UNMOUNTED ||
+ dev_blocked == BST_WAITING_FOR_SYSOP ||
+ dev_blocked == BST_UNMOUNTED_WAITING_FOR_SYSOP); };
+ bool waiting_for_mount() const { return
+ (dev_blocked == BST_UNMOUNTED ||
+ dev_blocked == BST_WAITING_FOR_SYSOP ||
+ dev_blocked == BST_UNMOUNTED_WAITING_FOR_SYSOP); };
+ bool weof() { return !weof_dev(this, 1); };
+ bool fsr(int num); /* in dev.c */
+ bool rewind() { return rewind_dev(this); };
const char *strerror() const;
const char *archive_name() const;
- void set_eof();
- void set_eot();
- void set_append();
- void set_read();
- void set_offline();
- void clear_append();
- void clear_read();
- void clear_label();
- void clear_offline();
+ const char *name() const;
+ const char *print_name() const; /* Name for display purposes */
+ void set_eof(); /* in dev.c */
+ void set_eot(); /* in dev.c */
+ void set_append() { state |= ST_APPEND; };
+ void set_labeled() { state |= ST_LABEL; };
+ void set_read() { state |= ST_READ; };
+ void set_offline() { state |= ST_OFFLINE; };
+ void clear_append() { state &= ~ST_APPEND; };
+ void clear_read() { state &= ~ST_READ; };
+ void clear_labeled() { state &= ~ST_LABEL; };
+ void clear_offline() { state &= ~ST_OFFLINE; };
+ void clear_eot() { state &= ~ST_EOT; };
+ void clear_eof() { state &= ~ST_EOF; };
+ void block(int why); /* in dev.c */
+ void unblock(); /* in dev.c */
};
/* Note, these return int not bool! */
-inline int DEVICE::is_tape() const { return state & ST_TAPE; }
-inline int DEVICE::is_file() const { return state & ST_FILE; }
-inline int DEVICE::is_fifo() const { return state & ST_FIFO; }
-inline int DEVICE::is_dvd() const { return state & ST_DVD; }
-inline int DEVICE::is_open() const { return state & ST_OPENED; }
-inline int DEVICE::is_offline() const { return state & ST_OFFLINE; }
-inline int DEVICE::is_labeled() const { return state & ST_LABEL; }
-inline int DEVICE::is_busy() const { return state & ST_READ || num_writers; }
-inline int DEVICE::at_eof() const { return state & ST_EOF; }
-inline int DEVICE::at_eot() const { return state & ST_EOT; }
-inline int DEVICE::can_append() const { return state & ST_APPEND; }
-inline int DEVICE::can_read() const { return state & ST_READ; }
-inline void DEVICE::set_append() { state |= ST_APPEND; }
-inline void DEVICE::set_read() { state |= ST_READ; }
-inline void DEVICE::set_offline() { state |= ST_OFFLINE; }
-inline void DEVICE::clear_append() { state &= ~ST_APPEND; }
-inline void DEVICE::clear_read() { state &= ~ST_READ; }
-inline void DEVICE::clear_label() { state &= ~ST_LABEL; }
-inline void DEVICE::clear_offline() { state &= ~ST_OFFLINE; }
+inline int DEVICE::is_busy() const { return state & ST_READ || num_writers || reserved_device; }
inline const char *DEVICE::strerror() const { return errmsg; }
inline const char *DEVICE::archive_name() const { return dev_name; }
+inline const char *DEVICE::print_name() const { return prt_name; }
/*
* Device Context (or Control) Record.
uint32_t StartFile; /* Start write file */
uint32_t StartBlock; /* Start write block */
uint32_t EndBlock; /* Ending block written */
- int64_t spool_size; /* Current spool size */
- int64_t max_spool_size; /* Max job spool size */
+ int64_t job_spool_size; /* Current job spool size */
+ int64_t max_job_spool_size; /* Max job spool size */
char VolumeName[MAX_NAME_LENGTH]; /* Volume name */
char pool_name[MAX_NAME_LENGTH]; /* pool name */
char pool_type[MAX_NAME_LENGTH]; /* pool type */
char media_type[MAX_NAME_LENGTH]; /* media type */
char dev_name[MAX_NAME_LENGTH]; /* dev name */
+ int Copy; /* identical copy number */
+ int Stripe; /* RAIT stripe */
VOLUME_CAT_INFO VolCatInfo; /* Catalog info for desired volume */
};