Imported Upstream version 2.4.4p3
[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.9.2.2.4.3.2.3 2003/03/07 20:55:37 martinea Exp $
29  *
30  * interface for tapeio.c
31  */
32 #ifndef TAPEIO_H
33 #define TAPEIO_H
34
35 #include "amanda.h"
36
37 /*
38  * Tape drive status structure.  This abstracts the things we are
39  * interested in from the free-for-all of what the various drivers
40  * supply.
41  */
42
43 struct am_mt_status {
44     char online_valid;                  /* is the online flag valid? */
45     char bot_valid;                     /* is the BOT flag valid? */
46     char eot_valid;                     /* is the EOT flag valid? */
47     char protected_valid;               /* is the protected flag valid? */
48     char flags_valid;                   /* is the flags field valid? */
49     char fileno_valid;                  /* is the fileno field valid? */
50     char blkno_valid;                   /* is the blkno field valid? */
51     char device_status_valid;           /* is the device status field valid? */
52     char error_status_valid;            /* is the device status field valid? */
53
54     char online;                        /* true if device is online/ready */
55     char bot;                           /* true if tape is at the beginning */
56     char eot;                           /* true if tape is at end of medium */
57     char protected;                     /* true if tape is write protected */
58     long flags;                         /* device flags, whatever that is */
59     long fileno;                        /* tape file number */
60     long blkno;                         /* block within file */
61     int device_status_size;             /* size of orig device status field */
62     unsigned long device_status;        /* "device status", whatever that is */
63     int error_status_size;              /* size of orig error status field */
64     unsigned long error_status;         /* "error status", whatever that is */
65 };
66
67 #define FAKE_LABEL      "[fake-label]"
68
69 int tape_open ();
70
71 int tapefd_rewind P((int tapefd));
72 int tapefd_unload P((int tapefd));
73 int tapefd_fsf P((int tapefd, int count));
74 int tapefd_weof P((int tapefd, int count));
75
76 int tapefd_status P((int tapefd, struct am_mt_status *));
77
78 void tapefd_resetofs P((int tapefd));
79
80 ssize_t tapefd_read P((int tapefd, void *buffer, size_t count));
81 ssize_t tapefd_write P((int tapefd, const void *buffer, size_t count));
82
83 char *tapefd_rdlabel P((int tapefd, char **datestamp, char **label));
84 char *tapefd_wrlabel P((int tapefd,
85                         char  *datestamp,
86                         char  *label,
87                         unsigned int s));
88 char *tapefd_wrendmark P((int tapefd, char *datestamp, unsigned int s));
89
90 int tapefd_eof P((int tapefd));         /* just used in tapeio-test */
91 int tapefd_close P((int tapefd));
92 int tapefd_can_fork P((int tapefd));
93
94 char *tape_unload P((char *dev));
95 char *tape_rewind P((char *dev));
96 char *tape_fsf P((char *dev, int count));
97 char *tape_rdlabel P((char *dev, char **datestamp, char **label));
98 char *tape_wrlabel P((char *dev,
99                       char  *datestamp,
100                       char  *label,
101                       unsigned int size));
102 char *tape_wrendmark P((char *dev,
103                         char *datestamp,
104                         unsigned int size));
105 char *tape_writable P((char *dev));
106
107 int tape_access P((char *dev, int mode));
108 int tape_stat P((char *filename, struct stat *buf));
109
110 char *tapefd_getinfo_label P((int fd));
111 void tapefd_setinfo_label P((int fd, char *v));
112 char *tapefd_getinfo_host P((int fd));
113 void tapefd_setinfo_host P((int fd, char *v));
114 char *tapefd_getinfo_disk P((int fd));
115 void tapefd_setinfo_disk P((int fd, char *v));
116 int tapefd_getinfo_level P((int fd));
117 void tapefd_setinfo_level P((int fd, int v));
118 char *tapefd_getinfo_datestamp P((int fd));
119 void tapefd_setinfo_datestamp P((int fd, char *v));
120 long tapefd_getinfo_length P((int fd));
121 void tapefd_setinfo_length P((int fd, long v));
122 char *tapefd_getinfo_tapetype P((int fd));
123 void tapefd_setinfo_tapetype P((int fd, char *v));
124 int tapefd_getinfo_fake_label P((int fd));
125 void tapefd_setinfo_fake_label P((int fd, int v));
126 int tapefd_getinfo_ioctl_fork P((int fd));
127 void tapefd_setinfo_ioctl_fork P((int fd, int v));
128 void tapefd_set_master_fd P((int tapefd, int master_fd));
129
130 #ifdef HAVE_LINUX_ZFTAPE_H
131 int is_zftape P((const char *filename));
132 #endif
133
134 int tapeio_init_devname P((char * dev,
135                            char **dev_left,
136                            char **dev_right,
137                            char **dev_next));
138 char *tapeio_next_devname P((char * dev_left,
139                              char * dev_right,
140                              char **dev_next));
141
142 #endif /* ! TAPEIO_H */