Imported Upstream version 2.5.1
[debian/amanda] / tape-src / output-rait.h
1 #ifndef RAIT_H
2
3 #define RAIT_H
4
5 typedef struct {
6     int nopen;
7     int nfds;
8     size_t fd_count;
9     int *fds;
10     ssize_t *readres;
11     size_t xorbuflen;
12     char *xorbuf;
13 } RAIT;
14
15 #ifdef NO_AMANDA
16
17 #define stralloc strdup
18
19 /*
20  * Tape drive status structure.  This abstracts the things we are
21  * interested in from the free-for-all of what the various drivers
22  * supply.
23  */
24
25 struct am_mt_status {
26     char online_valid;                  /* is the online flag valid? */
27     char bot_valid;                     /* is the BOT flag valid? */
28     char eot_valid;                     /* is the EOT flag valid? */
29     char protected_valid;               /* is the protected flag valid? */
30     char flags_valid;                   /* is the flags field valid? */
31     char fileno_valid;                  /* is the fileno field valid? */
32     char blkno_valid;                   /* is the blkno field valid? */
33     char device_status_valid;           /* is the device status field valid? */
34     char error_status_valid;            /* is the device status field valid? */
35
36     char online;                        /* true if device is online/ready */
37     char bot;                           /* true if tape is at the beginning */
38     char eot;                           /* true if tape is at end of medium */
39     char protected;                     /* true if tape is write protected */
40     long flags;                         /* device flags, whatever that is */
41     off_t fileno;                       /* tape file number */
42     off_t blkno;                        /* block within file */
43     int device_status_size;             /* size of orig device status field */
44     unsigned long device_status;        /* "device status", whatever that is */
45     int error_status_size;              /* size of orig error status field */
46     unsigned long error_status;         /* "error status", whatever that is */
47 };
48 #endif
49
50 int rait_open(char *dev, int flags, mode_t mask);
51 int rait_access(char *, int);
52 int rait_stat(char *, struct stat *);
53 int rait_close(int);
54 off_t rait_lseek(int, off_t, int);
55 ssize_t rait_write(int, const void *, size_t);
56 ssize_t rait_read(int, void *, size_t);
57 int rait_ioctl(int, int, void *);
58 int rait_copy(char *f1, char *f2, size_t buflen);
59 char *rait_init_namelist(char * dev, char **dev_left, char **dev_right, char **dev_next);
60 int rait_next_name(char * dev_left, char * dev_right, char **dev_next, char * dev_real);
61 int  rait_tape_open(char *, int, mode_t);
62 int  rait_tapefd_fsf(int rait_tapefd, off_t count);
63 int  rait_tapefd_rewind(int rait_tapefd);
64 void rait_tapefd_resetofs(int rait_tapefd);
65 int  rait_tapefd_unload(int rait_tapefd);
66 int  rait_tapefd_status(int rait_tapefd, struct am_mt_status *stat);
67 int  rait_tapefd_weof(int rait_tapefd, off_t count);
68 int  rait_tapefd_can_fork(int);
69
70 #ifdef RAIT_REDIRECT
71
72 /* handle ugly Solaris stat mess */
73
74 #ifdef _FILE_OFFSET_BITS
75 #include <sys/stat.h>
76 #undef stat
77 #undef open
78 #if _FILE_OFFSET_BITS == 64
79 struct  stat {
80         dev_t   st_dev;
81         long    st_pad1[3];     /* reserved for network id */
82         ino_t   st_ino;
83         mode_t  st_mode;
84         nlink_t st_nlink;
85         uid_t   st_uid;
86         gid_t   st_gid;
87         dev_t   st_rdev;
88         long    st_pad2[2];
89         off_t   st_size;
90         timestruc_t st_atim;
91         timestruc_t st_mtim;
92         timestruc_t st_ctim;
93         long    st_blksize;
94         blkcnt_t st_blocks;
95         char    st_fstype[_ST_FSTYPSZ];
96         long    st_pad4[8];     /* expansion area */
97 };
98 #endif
99
100 #endif
101
102 #define access(p,f)     rait_access(p,f)
103 #define stat(a,b)       rait_stat(a,b)
104 #define open            rait_open
105 #define close(a)        rait_close(a)
106 #define read(f,b,l)     rait_read(f,b,l)
107 #define write(f,b,l)    rait_write(f,b,l)
108 #define ioctl(f,n,x)    rait_ioctl(f,n,x)
109 #endif
110
111 #endif