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