]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/stored/vtape.h
update version
[bacula/bacula] / bacula / src / stored / vtape.h
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2000-2008 Free Software Foundation Europe e.V.
5
6    The main author of Bacula is Kern Sibbald, with contributions from
7    many others, a complete list can be found in the file AUTHORS.
8    This program is Free Software; you can redistribute it and/or
9    modify it under the terms of version two of the GNU General Public
10    License as published by the Free Software Foundation, which is
11    listed in the file LICENSE.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23    Bacula® is a registered trademark of Kern Sibbald.
24    The licensor of Bacula is the Free Software Foundation Europe
25    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26    Switzerland, email:ftf@fsfeurope.org.
27 */
28 /*
29  * vtape.h - Emulate the Linux st (scsi tape) driver on file.
30  * for regression and bug hunting purpose
31  *
32  */
33
34 #ifndef VTAPE_H
35 #define VTAPE_H
36
37 #include <stdarg.h>
38 #include <stddef.h>
39 #include "bacula.h"
40
41 /* 
42  * Theses functions will replace open/read/write
43  */
44 int vtape_open(const char *pathname, int flags, ...);
45 int vtape_close(int fd);
46 int vtape_ioctl(int fd, ioctl_req_t request, ...);
47 void vtape_debug(int level);
48 ssize_t vtape_read(int fd, void *buffer, size_t count);
49 ssize_t vtape_write(int fd, const void *buffer, size_t count);
50
51 #ifdef USE_VTAPE
52
53 #define FTAPE_MAX_DRIVE 50
54
55 #define VTAPE_MAX_BLOCK 20*1024*2048;      /* 20GB */
56
57 typedef enum {
58    VT_READ_EOF,                 /* Need to read the entire EOF struct */
59    VT_SKIP_EOF                  /* Have already read the EOF byte */
60 } VT_READ_FM_MODE;
61
62 class vtape {
63 private:
64    int         fd;              /* Our file descriptor */
65
66    boffset_t   file_block;      /* size */
67    boffset_t   max_block;
68
69    boffset_t   last_FM;         /* last file mark (last file) */
70    boffset_t   next_FM;         /* next file mark (next file) */
71    boffset_t   cur_FM;          /* current file mark */
72
73    bool        atEOF;           /* End of file */
74    bool        atEOT;           /* End of media */
75    bool        atEOD;           /* End of data */
76    bool        atBOT;           /* Begin of tape */
77    bool        online;          /* volume online */
78    bool        needEOF;         /* check if last operation need eof */
79
80    int32_t     last_file;       /* last file of the volume */
81    int32_t     current_file;    /* current position */
82    int32_t     current_block;   /* current position */
83
84    void destroy();
85    int offline();
86    int truncate_file();
87    void check_eof() { if(needEOF) weof();};
88    void update_pos();
89    bool read_fm(VT_READ_FM_MODE readfirst);
90
91 public:
92    int fsf();
93    int fsr(int count);
94    int weof();
95    int bsf();
96    int bsr(int count);
97
98    vtape();
99    ~vtape();
100
101    int get_fd();
102    void dump();
103    int open(const char *pathname, int flags);
104    ssize_t read(void *buffer, size_t count);
105    ssize_t write(const void *buffer, size_t count);
106    int close();
107
108    int tape_op(struct mtop *mt_com);
109    int tape_get(struct mtget *mt_com);
110    int tape_pos(struct mtpos *mt_com);
111 };
112
113
114 #endif  /*!USE_VTAPE */
115
116 #endif /* !VTAPE_H */