2 * Copyright (c) 2007,2008,2009 Zmanda, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 as published
6 * by the Free Software Foundation.
8 * This program 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 General Public License
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 * Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300
18 * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
26 /* Unlike other Device classes, this class is implemented across multiple source
27 * files, so its class declaration is placed in a header file.
31 * Type checking and casting macros
34 #define TYPE_TAPE_DEVICE (tape_device_get_type())
35 #define TAPE_DEVICE(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), tape_device_get_type(), TapeDevice)
36 #define TAPE_DEVICE_CONST(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), tape_device_get_type(), TapeDevice const)
37 #define TAPE_DEVICE_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), tape_device_get_type(), TapeDeviceClass)
38 #define IS_TAPE_DEVICE(obj) G_TYPE_CHECK_INSTANCE_TYPE((obj), tape_device_get_type ())
39 #define TAPE_DEVICE_GET_CLASS(obj) G_TYPE_INSTANCE_GET_CLASS((obj), tape_device_get_type(), TapeDeviceClass)
40 GType tape_device_get_type (void);
43 * Main object structure
45 typedef struct TapeDevicePrivate_s TapeDevicePrivate;
46 typedef struct _TapeDevice {
49 /* It should go without saying that all this stuff is
50 * look-but-don't-touch. */
52 /* characteristics of the device */
53 gboolean fsf, bsf, fsr, bsr, eom, bsf_after_eom, broken_gmt_online;
54 gboolean nonblocking_open, fsf_after_filemark;
57 /* 0 if we opened with O_RDWR; error otherwise. */
58 gboolean write_open_errno;
61 TapeDevicePrivate * private;
67 typedef struct _TapeDeviceClass TapeDeviceClass;
68 struct _TapeDeviceClass {
69 DeviceClass __parent__;
72 /* Tape device properties. These properties do not exist on non-linear
74 extern DevicePropertyBase device_property_broken_gmt_online;
75 #define PROPERTY_BROKEN_GMT_ONLINE (device_property_broken_gmt_online.ID)
77 extern DevicePropertyBase device_property_fsf;
78 #define PROPERTY_FSF (device_property_fsf.ID)
80 extern DevicePropertyBase device_property_fsf_after_filemark;
81 #define PROPERTY_FSF_AFTER_FILEMARK (device_property_fsf_after_filemark.ID)
83 extern DevicePropertyBase device_property_bsf;
84 #define PROPERTY_BSF (device_property_bsf.ID)
86 extern DevicePropertyBase device_property_fsr;
87 #define PROPERTY_FSR (device_property_fsr.ID)
89 extern DevicePropertyBase device_property_bsr;
90 #define PROPERTY_BSR (device_property_bsr.ID)
92 /* Is EOM supported? Must be able to read file number afterwards as
94 extern DevicePropertyBase device_property_eom;
95 #define PROPERTY_EOM (device_property_eom.ID)
97 /* Is it necessary to perform a BSF after EOM? */
98 extern DevicePropertyBase device_property_bsf_after_eom;
99 #define PROPERTY_BSF_AFTER_EOM (device_property_bsf_after_eom.ID)
101 /* Should the device be opened with O_NONBLOCK */
102 extern DevicePropertyBase device_property_nonblocking_open;
103 #define PROPERTY_NONBLOCKING_OPEN (device_property_nonblocking_open.ID)
105 /* How many filemarks to write at EOD? (Default is 2).
106 * This property is a G_TYPE_UINT, but can only really be set to 1 or 2. */
107 extern DevicePropertyBase device_property_final_filemarks;
108 #define PROPERTY_FINAL_FILEMARKS (device_property_final_filemarks.ID)
110 /* useful callback for tape ops */
111 void tape_device_set_capabilities(TapeDevice *self,
112 gboolean fsf, PropertySurety fsf_surety, PropertySource fsf_source,
113 gboolean fsf_after_filemark, PropertySurety faf_surety, PropertySource faf_source,
114 gboolean bsf, PropertySurety bsf_surety, PropertySource bsf_source,
115 gboolean fsr, PropertySurety fsr_surety, PropertySource fsr_source,
116 gboolean bsr, PropertySurety bsr_surety, PropertySource bsr_source,
117 gboolean eom, PropertySurety eom_surety, PropertySource eom_source,
118 gboolean bsf_after_eom, PropertySurety bae_surety, PropertySource bae_source,
119 guint final_filemarks, PropertySurety ff_surety, PropertySource ff_source);