#include <stddef.h>
#include "bacula.h"
-typedef struct
-{
- /* format infos */
- int16_t version;
- int16_t max_file_mark;
- int16_t block_size;
- int32_t block_max;
-} FTAPE_FORMAT;
+#ifdef USE_FAKETAPE
-#define FTAPE_MAX_DRIVE 20
+#define FTAPE_MAX_DRIVE 50
/*
* Theses functions will replace open/read/write
*/
-int faketape_open(const char *pathname, int flags, int mode);
+int faketape_open(const char *pathname, int flags);
int faketape_read(int fd, void *buffer, unsigned int count);
int faketape_write(int fd, const void *buffer, unsigned int count);
int faketape_close(int fd);
int faketape_ioctl(int fd, unsigned long int request, ...);
+void faketape_debug(int level);
class faketape {
private:
- int fd; /* Our file descriptor */
+ int fd; /* Our file descriptor */
- int cur_fd; /* OS file descriptor (-1 if not open) */
- off_t size; /* size */
+ off_t file_size; /* size */
+ off_t max_block;
- bool atEOF; /* End of file */
- bool atEOT; /* End of media */
- bool atEOD; /* End of data */
+ bool atEOF; /* End of file */
+ bool atEOT; /* End of media */
+ bool atEOD; /* End of data */
bool atBOT; /* Begin of tape */
- bool online; /* volume online */
+ bool online; /* volume online */
+ bool inplace; /* have to seek before writing ? */
+ bool needEOF; /* check if last operation need eof */
- POOLMEM *volume; /* volume name */
- POOLMEM *cur_info; /* volume info */
- POOLMEM *cur_file; /* current file name */
-
- int16_t last_file; /* last file of the volume */
- int16_t current_file; /* max 65000 files */
- int32_t current_block; /* max 4G blocks of 1KB */
- off_t max_size; /* max size of volume */
-
- FTAPE_FORMAT tape_info;
+ int32_t last_file; /* last file of the volume */
+ int32_t current_file; /* max 65000 files */
+ int32_t current_block; /* max 4G blocks of 1KB */
+ off_t current_pos; /* current position in stream */
void destroy();
- int read_volinfo(); /* read current volume format */
int find_maxfile();
- int open_file();
- int delete_files(int startfile);
- void check_file() { if (cur_fd == -1) open_file(); };
int offline();
- int close_file();
+ int truncate_file();
+ int seek_file();
+ void check_eof() { if(needEOF) weof(1);};
public:
int fsf(int count);
+ int fsr(int count);
int weof(int count);
int bsf(int count);
+ int bsr(int count);
faketape();
~faketape();
int get_fd();
void dump();
- int open(const char *pathname, int flags, int mode);
+ int open(const char *pathname, int flags);
int read(void *buffer, unsigned int count);
int write(const void *buffer, unsigned int count);
int close();
int tape_pos(struct mtpos *mt_com);
};
+#endif /* USE_FAKETAPE */
#endif /* !FAKETAPE_H */