a9665a74f5982c4680681b53bb327e5bd8420fbd
[debian/amanda] / device-src / tape-aix.c
1 /*
2  * Copyright (c) 2005 Zmanda, Inc.  All Rights Reserved.
3  * 
4  * This library is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 2.1 as 
6  * published by the Free Software Foundation.
7  * 
8  * This library is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
11  * License for more details.
12  * 
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this library; if not, write to the Free Software Foundation,
15  * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA.
16  * 
17  * Contact information: Zmanda Inc., 505 N Mathlida Ave, Suite 120
18  * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
19  */
20
21 #include <amanda.h>
22 #include "tape-ops.h"
23
24 /* Tape operations for AIX systems. Most of this stuff is based on
25    documentation from 
26    http://publibn.boulder.ibm.com/doc_link/Ja_JP/a_doc_lib/files/aixfiles/rmt.htm */
27
28 /* Uncomment to test compilation on non-AIX systems. */
29 /* ---
30 #undef MTIOCTOP
31 #define STIOCTOP 0
32 #define stop mtop
33 #define st_op mt_op
34 #define st_count mt_count
35 #define STREW MTREW
36 #define STFSF MTFSF
37 #define STRSF MTBSF
38 #define STFSR MTFSR
39 #define STRSR MTBSR
40 #define STWEOF MTWEOF
41 --- */
42
43 gboolean tape_rewind(int fd) {
44     struct stop st;
45     st.st_op = STREW;
46     st.st_count = 1;
47     return 0 == ioctl(fd, STIOCTOP, &st);
48 }
49
50 gboolean tape_fsf(int fd, guint count) {
51     struct stop st;
52     st.st_op = STFSF;
53     st.st_count = count;
54     return 0 == ioctl(fd, STIOCTOP, &st);
55 }
56
57 gboolean tape_bsf(int fd, guint count) {
58     struct stop st;
59     st.st_op = STRSF;
60     st.st_count = count;
61     return 0 == ioctl(fd, STIOCTOP, &st);
62 }
63
64 gboolean tape_fsr(int fd, guint count) {
65     struct stop st;
66     st.st_op = STFSR;
67     st.st_count = count;
68     return 0 == ioctl(fd, STIOCTOP, &st);
69 }
70
71 gboolean tape_bsr(int fd, guint count) {
72     struct stop st;
73     st.st_op = STRSR;
74     st.st_count = count;
75     return 0 == ioctl(fd, STIOCTOP, &st);
76 }
77
78 gint tape_eod(int fd) {
79     g_assert_not_reached();
80     return TAPE_OP_ERROR;
81 }
82
83 gboolean tape_weof(int fd, guint8 count) {
84     struct stop st;
85     st.st_op = STWEOF;
86     st.st_count = count;
87     return 0 == ioctl(fd, STIOCTOP, &st);
88 }
89
90 gboolean tape_setcompression(int fd, gboolean on) {
91     return FALSE;
92 }
93
94 ReadLabelStatusFlags tape_is_tape_device(int fd) {
95     /* AIX doesn't have a no-op. */
96     return READ_LABEL_STATUS_SUCCESS;
97 }
98
99 TapeCheckResult tape_is_ready(int fd) {
100     return TAPE_CHECK_UNKNOWN;
101 }
102
103 void tape_device_discover_capabilities(TapeDevice * t_self) {
104     Device * self;
105     GValue val;
106
107     self = DEVICE(t_self);
108     g_return_if_fail(self != NULL);
109
110     bzero(&val, sizeof(val));
111     g_value_init(&val, FEATURE_SUPPORT_FLAGS_TYPE);
112
113     g_value_set_flags(&val,
114                       FEATURE_STATUS_ENABLED | FEATURE_SURETY_BAD |
115                       FEATURE_SOURCE_DEFAULT);
116     device_property_set(self, PROPERTY_FSF, &val);
117     
118     g_value_set_flags(&val,
119                       FEATURE_STATUS_ENABLED | FEATURE_SURETY_BAD |
120                       FEATURE_SOURCE_DEFAULT);
121     device_property_set(self, PROPERTY_BSF, &val);
122     
123     g_value_set_flags(&val,
124                       FEATURE_STATUS_ENABLED | FEATURE_SURETY_BAD |
125                       FEATURE_SOURCE_DEFAULT);
126     device_property_set(self, PROPERTY_FSR, &val);
127     
128     g_value_set_flags(&val,
129                       FEATURE_STATUS_ENABLED | FEATURE_SURETY_BAD |
130                       FEATURE_SOURCE_DEFAULT);
131     device_property_set(self, PROPERTY_BSR, &val);
132     
133     g_value_set_flags(&val,
134                       FEATURE_STATUS_DISABLED | FEATURE_SURETY_GOOD |
135                       FEATURE_SOURCE_DEFAULT);
136     device_property_set(self, PROPERTY_EOM, &val);
137
138     g_value_unset_init(&val, G_TYPE_UINT);
139     g_value_set_uint(&val, 2);
140     device_property_set(self, PROPERTY_FINAL_FILEMARKS, &val);
141 }