2 * Copyright (c) 2005-2008 Zmanda Inc. All Rights Reserved.
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.
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.
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.
17 * Contact information: Zmanda Inc., 465 S Mathlida Ave, Suite 300
18 * Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
21 /* Tape operations for SVR4 systems. Most of this stuff is based on
22 documentation from http://docsrv.sco.com/cgi-bin/man/man?sdi+7 */
26 #include "glib-util.h"
28 /* Uncomment to test on non-SYSV4 systems. */
42 int min_blen, max_blen;
47 gboolean tape_rewind(int fd) {
48 return 0 == ioctl(fd, T_RWD);
51 gboolean tape_fsf(int fd, guint count) {
52 return 0 == ioctl(fd, T_SFF, count);
55 gboolean tape_bsf(int fd, guint count) {
56 return 0 == ioctl(fd, T_SFB, count);
59 gboolean tape_fsr(int fd, guint count) {
60 return 0 == ioctl(fd, T_SBF, count);
63 gboolean tape_bsr(int fd, guint count) {
64 return 0 == ioctl(fd, T_SBB, count);
67 gint tape_eod(int fd G_GNUC_UNUSED) {
68 g_assert_not_reached();
72 gboolean tape_weof(int fd, guint8 count) {
73 return 0 == ioctl(fd, T_WRFILEM, count);
76 gboolean tape_setcompression(int fd, gboolean on) {
84 return 0 == ioctl(fd, T_SETCOMP, cmd);
87 DeviceStatusFlags tape_is_tape_device(int fd) {
88 /* If we can read block information, it's probably a tape device. */
90 if (0 == ioctl(fd, T_RDBLKLEN, &result)) {
91 return DEVICE_STATUS_SUCCESS;
93 return DEVICE_STATUS_DEVICE_ERROR;
97 DeviceStatusFlags tape_is_ready(int fd G_GNUC_UNUSED, TapeDevice *t_self G_GNUC_UNUSED) {
98 /* No good way to determine this, so assume it's ready */
99 return DEVICE_STATUS_SUCCESS;
102 void tape_device_detect_capabilities(TapeDevice * t_self) {
103 tape_device_set_capabilities(t_self,
104 TRUE, PROPERTY_SURETY_BAD, PROPERTY_SOURCE_DEFAULT, /* fsf*/
105 TRUE, PROPERTY_SURETY_BAD, PROPERTY_SOURCE_DEFAULT, /* bsf*/
106 TRUE, PROPERTY_SURETY_BAD, PROPERTY_SOURCE_DEFAULT, /* fsr*/
107 TRUE, PROPERTY_SURETY_BAD, PROPERTY_SOURCE_DEFAULT, /* bsr*/
108 FALSE, PROPERTY_SURETY_GOOD, PROPERTY_SOURCE_DEFAULT, /* eom*/
109 FALSE, PROPERTY_SURETY_GOOD, PROPERTY_SOURCE_DEFAULT, /* bsf_after_eom*/
110 2, PROPERTY_SURETY_BAD, PROPERTY_SOURCE_DEFAULT /* final_filemarks*/