2 Bacula® - The Network Backup Solution
4 Copyright (C) 2008-2014 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from many
7 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 Bacula® is a registered trademark of Kern Sibbald.
17 * vtape.h - Emulate the Linux st (scsi tape) driver on file.
18 * for regression and bug hunting purpose
30 void vtape_debug(int level);
34 #define FTAPE_MAX_DRIVE 50
36 #define VTAPE_MAX_BLOCK 20*1024*2048; /* 20GB */
39 VT_READ_EOF, /* Need to read the entire EOF struct */
40 VT_SKIP_EOF /* Have already read the EOF byte */
43 class vtape: public tape_dev {
45 int fd; /* Our file descriptor */
46 int lockfd; /* File descriptor for the lock file */
48 boffset_t file_block; /* size */
51 boffset_t last_FM; /* last file mark (last file) */
52 boffset_t next_FM; /* next file mark (next file) */
53 boffset_t cur_FM; /* current file mark */
55 bool atEOF; /* End of file */
56 bool atEOT; /* End of media */
57 bool atEOD; /* End of data */
58 bool atBOT; /* Begin of tape */
59 bool online; /* volume online */
60 bool needEOF; /* check if last operation need eof */
62 int32_t last_file; /* last file of the volume */
63 int32_t current_file; /* current position */
64 int32_t current_block; /* current position */
65 char * lockfile; /* Name of the lock file */
69 void check_eof() { if(needEOF) weof();};
71 bool read_fm(VT_READ_FM_MODE readfirst);
85 int tape_op(struct mtop *mt_com);
86 int tape_get(struct mtget *mt_com);
87 int tape_pos(struct mtpos *mt_com);
89 /* DEVICE virtual interfaces that we redefine */
91 int d_open(const char *pathname, int flags);
92 int d_ioctl(int fd, ioctl_req_t request, char *op=NULL);
93 ssize_t d_read(int, void *buffer, size_t count);
94 ssize_t d_write(int, const void *buffer, size_t count);
97 boffset_t lseek(DCR *dcr, off_t offset, int whence) { return -1; }
98 boffset_t lseek(int fd, off_t offset, int whence)
99 { return ::lseek(fd, offset, whence); }
103 #else /*!USE_VTAPE */
105 class vtape: public DEVICE {
107 int d_open(const char *pathname, int flags) { return -1; }
108 ssize_t d_read(void *buffer, size_t count) { return -1; }
109 ssize_t d_write(const void *buffer, size_t count) { return -1; }
110 int d_close(int) { return -1; }
111 int d_ioctl(int fd, ioctl_req_t request, char *mt=NULL) { return -1; }
112 boffset_t lseek(DCR *dcr, off_t offset, int whence) { return -1; }
115 #endif /* USE_VTAPE */
117 #endif /* !VTAPE_H */