#define CAP_MTIOCGET (1<<20) /* Basic support for fileno and blkno */
#define CAP_REQMOUNT (1<<21) /* Require mount to read files back (typically: DVD) */
#define CAP_CHECKLABELS (1<<22) /* Check for ANSI/IBM labels */
+#define CAP_BLOCKCHECKSUM (1<<23) /* Create/test block checksum */
/* Test state */
#define dev_state(dev, st_state) ((dev)->state & (st_state))
int m_fd; /* file descriptor */
int m_blocked; /* set if we must wait (i.e. change tape) */
int m_count; /* Mutex use count -- DEBUG only */
+ int m_num_reserved; /* counter of device reservations */
+ int32_t m_slot; /* slot loaded in drive or -1 if none */
pthread_t m_pid; /* Thread that locked -- DEBUG only */
bool m_unload; /* set when Volume must be unloaded */
bool m_load; /* set when Volume must be loaded */
- int m_num_reserved; /* counter of device reservations */
- int32_t m_slot; /* slot loaded in drive or -1 if none */
public:
DEVICE * volatile swap_dev; /* Swap vol from this device */
dlist *attached_dcrs; /* attached DCR list */
pthread_mutex_t m_mutex; /* access control */
pthread_mutex_t spool_mutex; /* mutex for updating spool_size */
+ pthread_mutex_t acquire_mutex; /* mutex for acquire code */
pthread_cond_t wait; /* thread wait variable */
pthread_cond_t wait_next_vol; /* wait for tape to be mounted */
pthread_t no_wait_id; /* this thread must not wait */
int has_cap(int cap) const { return capabilities & cap; }
void clear_cap(int cap) { capabilities &= ~cap; }
void set_cap(int cap) { capabilities |= cap; }
+ bool do_checksum() const { return (capabilities & CAP_BLOCKCHECKSUM) != 0; }
int is_autochanger() const { return capabilities & CAP_AUTOCHANGER; }
int requires_mount() const { return capabilities & CAP_REQMOUNT; }
int is_removable() const { return capabilities & CAP_REM; }
* Locking and blocking calls
*/
#ifdef SD_DEBUG_LOCK
- void _r_dlock(const char *, int); /* in lock.c */
+ void _r_dlock(const char *, int, bool locked=false); /* in lock.c */
void _r_dunlock(const char *, int); /* in lock.c */
void _dlock(const char *, int); /* in lock.c */
void _dunlock(const char *, int); /* in lock.c */
#else
- void r_dlock(); /* in lock.c */
+ void r_dlock(bool locked=false); /* in lock.c */
void r_dunlock() { dunlock(); }
void dlock() { P(m_mutex); }
void dunlock() { V(m_mutex); }
#endif
void dblock(int why); /* in lock.c */
void dunblock(bool locked=false); /* in lock.c */
+ bool is_device_unmounted(); /* in lock.c */
void set_blocked(int block) { m_blocked = block; };
int blocked() const { return m_blocked; };
bool is_blocked() const { return m_blocked != BST_NOT_BLOCKED; };
void clear_found_in_use() { m_found_in_use = false; };
bool is_reserved() const { return m_reserved; };
bool is_dev_locked() { return m_dev_locked; }
+#ifdef SD_DEBUG_LOCK
+ void _dlock(const char *, int); /* in lock.c */
+ void _dunlock(const char *, int); /* in lock.c */
+#else
void dlock() { dev->dlock(); m_dev_locked = true; }
void dunlock() { m_dev_locked = false; dev->dunlock(); }
+#endif
void dblock(int why) { dev->dblock(why); }