]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/stored/faketape.h
kes If operator has rewind tape, print warning, release tape and
[bacula/bacula] / bacula / src / stored / faketape.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 John Walker.
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  * faketape.h - Emulate the Linux st (scsi tape) driver on file.
30  * for regression and bug hunting purpose
31  *
32  */
33
34 #ifndef FAKETAPE_H
35 #define FAKETAPE_H
36
37 #include <stdarg.h>
38 #include <stddef.h>
39 #include "bacula.h"
40
41 #ifdef USE_FAKETAPE
42
43 #define FTAPE_MAX_DRIVE 50
44
45 /* 
46  * Theses functions will replace open/read/write
47  */
48 int faketape_open(const char *pathname, int flags);
49 int faketape_read(int fd, void *buffer, unsigned int count);
50 int faketape_write(int fd, const void *buffer, unsigned int count);
51 int faketape_close(int fd);
52 int faketape_ioctl(int fd, unsigned long int request, ...);
53 void faketape_debug(int level);
54
55 class faketape {
56 private:
57    int         fd;              /* Our file descriptor */
58
59    off_t       file_block;       /* size */
60    off_t       max_block;
61
62    bool        atEOF;           /* End of file */
63    bool        atEOT;           /* End of media */
64    bool        atEOD;           /* End of data */
65    bool        atBOT;           /* Begin of tape */
66    bool        online;          /* volume online */
67    bool        inplace;         /* have to seek before writing ? */
68    bool        needEOF;         /* check if last operation need eof */
69
70    int32_t     last_file;       /* last file of the volume */
71    int32_t     current_file;    /* current position */
72    int32_t     current_block;   /* current position */
73
74    void destroy();
75    int find_maxfile();
76    int offline();
77    int truncate_file();
78    int seek_file();
79    void check_eof() { if(needEOF) weof(1);};
80    void update_pos();
81
82 public:
83    int fsf(int count);
84    int fsr(int count);
85    int weof(int count);
86    int bsf(int count);
87    int bsr(int count);
88
89    faketape();
90    ~faketape();
91
92    int get_fd();
93    void dump();
94    int open(const char *pathname, int flags);
95    int read(void *buffer, unsigned int count);
96    int write(const void *buffer, unsigned int count);
97    int close();
98
99    int tape_op(struct mtop *mt_com);
100    int tape_get(struct mtget *mt_com);
101    int tape_pos(struct mtpos *mt_com);
102 };
103
104 #endif /* USE_FAKETAPE */
105 #endif /* !FAKETAPE_H */