2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2016 Kern Sibbald
6 The original author of Bacula is Kern Sibbald, with contributions
7 from many others, a complete list can be found in the file AUTHORS.
9 You may use this file and others of this release according to the
10 license defined in the LICENSE file, which includes the Affero General
11 Public License, v3.0 ("AGPLv3") and some additional permissions and
12 terms pursuant to its AGPLv3 Section 7.
14 This notice must be preserved when any source code is
15 conveyed and/or propagated.
17 Bacula(R) is a registered trademark of Kern Sibbald.
20 * vtape.h - Emulate the Linux st (scsi tape) driver on file.
21 * for regression and bug hunting purpose
33 void vtape_debug(int level);
37 #define FTAPE_MAX_DRIVE 50
39 #define VTAPE_MAX_BLOCK 20*1024*2048; /* 20GB */
42 VT_READ_EOF, /* Need to read the entire EOF struct */
43 VT_SKIP_EOF /* Have already read the EOF byte */
46 class vtape: public tape_dev {
48 int fd; /* Our file descriptor */
49 int lockfd; /* File descriptor for the lock file */
51 boffset_t file_block; /* size */
54 boffset_t last_FM; /* last file mark (last file) */
55 boffset_t next_FM; /* next file mark (next file) */
56 boffset_t cur_FM; /* current file mark */
58 bool atEOF; /* End of file */
59 bool atEOT; /* End of media */
60 bool atEOD; /* End of data */
61 bool atBOT; /* Begin of tape */
62 bool online; /* volume online */
63 bool needEOF; /* check if last operation need eof */
65 int32_t last_file; /* last file of the volume */
66 int32_t current_file; /* current position */
67 int32_t current_block; /* current position */
68 char * lockfile; /* Name of the lock file */
72 void check_eof() { if(needEOF) weof();};
74 bool read_fm(VT_READ_FM_MODE readfirst);
88 int tape_op(struct mtop *mt_com);
89 int tape_get(struct mtget *mt_com);
90 int tape_pos(struct mtpos *mt_com);
92 /* DEVICE virtual interfaces that we redefine */
94 int d_open(const char *pathname, int flags);
95 int d_ioctl(int fd, ioctl_req_t request, char *op=NULL);
96 ssize_t d_read(int, void *buffer, size_t count);
97 ssize_t d_write(int, const void *buffer, size_t count);
100 boffset_t lseek(DCR *dcr, off_t offset, int whence) { return -1; }
101 boffset_t lseek(int fd, off_t offset, int whence)
102 { return ::lseek(fd, offset, whence); }
106 #else /*!USE_VTAPE */
108 class vtape: public DEVICE {
110 int d_open(const char *pathname, int flags) { return -1; }
111 ssize_t d_read(int fd, void *buffer, size_t count) { return -1; }
112 ssize_t d_write(int fd, const void *buffer, size_t count) { return -1; }
113 int d_close(int) { return -1; }
114 int d_ioctl(int fd, ioctl_req_t request, char *mt=NULL) { return -1; }
115 boffset_t lseek(DCR *dcr, off_t offset, int whence) { return -1; }
118 #endif /* USE_VTAPE */
120 #endif /* !VTAPE_H */