564ab99d1cecc9554ff64afbf8e64a346f3aa778
[debian/amanda] / tape-src / tapeio.h
1 /*
2  * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3  * Copyright (c) 1991-1998 University of Maryland at College Park
4  * All Rights Reserved.
5  *
6  * Permission to use, copy, modify, distribute, and sell this software and its
7  * documentation for any purpose is hereby granted without fee, provided that
8  * the above copyright notice appear in all copies and that both that
9  * copyright notice and this permission notice appear in supporting
10  * documentation, and that the name of U.M. not be used in advertising or
11  * publicity pertaining to distribution of the software without specific,
12  * written prior permission.  U.M. makes no representations about the
13  * suitability of this software for any purpose.  It is provided "as is"
14  * without express or implied warranty.
15  *
16  * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
18  * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20  * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22  *
23  * Author: James da Silva, Systems Design and Analysis Group
24  *                         Computer Science Department
25  *                         University of Maryland at College Park
26  */
27 /*
28  * $Id: tapeio.h,v 1.20 2005/12/21 19:07:51 paddy_s Exp $
29  *
30  * interface for tapeio.c
31  */
32 #ifndef TAPEIO_H
33 #define TAPEIO_H
34
35 #include "amanda.h"
36 #include "util.h" /* For BSTRNCMP */
37
38 /*
39  * Tape drive status structure.  This abstracts the things we are
40  * interested in from the free-for-all of what the various drivers
41  * supply.
42  */
43
44 struct am_mt_status {
45     char online_valid;                  /* is the online flag valid? */
46     char bot_valid;                     /* is the BOT flag valid? */
47     char eot_valid;                     /* is the EOT flag valid? */
48     char protected_valid;               /* is the protected flag valid? */
49     char flags_valid;                   /* is the flags field valid? */
50     char fileno_valid;                  /* is the fileno field valid? */
51     char blkno_valid;                   /* is the blkno field valid? */
52     char device_status_valid;           /* is the device status field valid? */
53     char error_status_valid;            /* is the device status field valid? */
54
55     char online;                        /* true if device is online/ready */
56     char bot;                           /* true if tape is at the beginning */
57     char eot;                           /* true if tape is at end of medium */
58     char protected;                     /* true if tape is write protected */
59     long flags;                         /* device flags, whatever that is */
60     long fileno;                        /* tape file number */
61     long blkno;                         /* block within file */
62     int device_status_size;             /* size of orig device status field */
63     unsigned long device_status;        /* "device status", whatever that is */
64     int error_status_size;              /* size of orig error status field */
65     unsigned long error_status;         /* "error status", whatever that is */
66 };
67
68 #define FAKE_LABEL      "[fake-label]"
69 #define NO_LABEL        "[no-label-yet]"
70
71 int tape_open (char *, int, ...);
72
73 int tapefd_rewind P((int tapefd));
74 int tapefd_unload P((int tapefd));
75 int tapefd_fsf P((int tapefd, int count));
76 int tapefd_weof P((int tapefd, int count));
77
78 int tapefd_status P((int tapefd, struct am_mt_status *));
79
80 void tapefd_resetofs P((int tapefd));
81
82 ssize_t tapefd_read P((int tapefd, void *buffer, size_t count));
83 ssize_t tapefd_write P((int tapefd, const void *buffer, size_t count));
84
85 char *tapefd_rdlabel P((int tapefd, char **datestamp, char **label));
86 char *tapefd_wrlabel P((int tapefd,
87                         char  *datestamp,
88                         char  *label,
89                         unsigned int s));
90
91 char *auto_tapefd_label P((int tapefd, char **datestamp, char **label));
92 char *auto_tape_label P((char *dev, char **datestamp, char **label));
93
94 char *tapefd_wrendmark P((int tapefd, char *datestamp, unsigned int s));
95
96 int tapefd_eof P((int tapefd));         /* just used in tapeio-test */
97 int tapefd_close P((int tapefd));
98 int tapefd_can_fork P((int tapefd));
99
100 char *tape_unload P((char *dev));
101 char *tape_rewind P((char *dev));
102 char *tape_fsf P((char *dev, int count));
103 char *tape_rdlabel P((char *dev, char **datestamp, char **label));
104 char *tape_wrlabel P((char *dev,
105                       char  *datestamp,
106                       char  *label,
107                       unsigned int size));
108 char *tape_wrendmark P((char *dev,
109                         char *datestamp,
110                         unsigned int size));
111 char *tape_writable P((char *dev));
112
113 int tape_access P((char *dev, int mode));
114 int tape_stat P((char *filename, struct stat *buf));
115
116 char *tapefd_getinfo_label P((int fd));
117 void tapefd_setinfo_label P((int fd, char *v));
118 char *tapefd_getinfo_host P((int fd));
119 void tapefd_setinfo_host P((int fd, char *v));
120 char *tapefd_getinfo_disk P((int fd));
121 void tapefd_setinfo_disk P((int fd, char *v));
122 int tapefd_getinfo_level P((int fd));
123 void tapefd_setinfo_level P((int fd, int v));
124 char *tapefd_getinfo_datestamp P((int fd));
125 void tapefd_setinfo_datestamp P((int fd, char *v));
126 long tapefd_getinfo_length P((int fd));
127 void tapefd_setinfo_length P((int fd, long v));
128 char *tapefd_getinfo_tapetype P((int fd));
129 void tapefd_setinfo_tapetype P((int fd, char *v));
130 int tapefd_getinfo_fake_label P((int fd));
131 void tapefd_setinfo_fake_label P((int fd, int v));
132 int tapefd_getinfo_ioctl_fork P((int fd));
133 void tapefd_setinfo_ioctl_fork P((int fd, int v));
134 void tapefd_set_master_fd P((int tapefd, int master_fd));
135
136 #ifdef HAVE_LINUX_ZFTAPE_H
137 int is_zftape P((const char *filename));
138 #endif
139
140 int tapeio_init_devname P((char * dev,
141                            char **dev_left,
142                            char **dev_right,
143                            char **dev_next));
144 char *tapeio_next_devname P((char * dev_left,
145                              char * dev_right,
146                              char **dev_next));
147
148 #define NOT_AMANDA_TAPE_MSG "not an amanda tape"
149 #define CHECK_NOT_AMANDA_TAPE_MSG(x) (!BSTRNCMP(x, NOT_AMANDA_TAPE_MSG))
150
151 #endif /* ! TAPEIO_H */