Imported Upstream version 3.1.0
[debian/amanda] / device-src / tape-device.h
1 /*
2  * Copyright (c) 2007,2008,2009 Zmanda, Inc.  All Rights Reserved.
3  *
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.
7  *
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
11  * for more details.
12  *
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
16  *
17  * Contact information: Zmanda Inc., 465 S. Mathilda Ave., Suite 300
18  * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
19  */
20
21 #ifndef TAPE_DEVICE_H
22 #define TAPE_DEVICE_H
23
24 #include <device.h>
25
26 /* Unlike other Device classes, this class is implemented across multiple source
27  * files, so its class declaration is placed in a header file.
28  */
29
30 /*
31  * Type checking and casting macros
32  */
33
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);
41
42 /*
43  * Main object structure
44  */
45 typedef struct TapeDevicePrivate_s TapeDevicePrivate;
46 typedef struct _TapeDevice {
47     Device __parent__;
48
49     /* It should go without saying that all this stuff is
50      * look-but-don't-touch. */
51
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;
55     int final_filemarks;
56
57     /* 0 if we opened with O_RDWR; error otherwise. */
58     gboolean write_open_errno;
59     int fd;
60
61     TapeDevicePrivate * private;
62 } TapeDevice;
63
64 /*
65  * Class definition
66  */
67 typedef struct _TapeDeviceClass TapeDeviceClass;
68 struct _TapeDeviceClass {
69         DeviceClass __parent__;
70 };
71
72 /* Tape device properties. These properties do not exist on non-linear
73    devices. */
74 extern DevicePropertyBase device_property_broken_gmt_online;
75 #define PROPERTY_BROKEN_GMT_ONLINE (device_property_broken_gmt_online.ID)
76
77 extern DevicePropertyBase device_property_fsf;
78 #define PROPERTY_FSF (device_property_fsf.ID)
79
80 extern DevicePropertyBase device_property_fsf_after_filemark;
81 #define PROPERTY_FSF_AFTER_FILEMARK (device_property_fsf_after_filemark.ID)
82
83 extern DevicePropertyBase device_property_bsf;
84 #define PROPERTY_BSF (device_property_bsf.ID)
85
86 extern DevicePropertyBase device_property_fsr;
87 #define PROPERTY_FSR (device_property_fsr.ID)
88
89 extern DevicePropertyBase device_property_bsr;
90 #define PROPERTY_BSR (device_property_bsr.ID)
91
92 /* Is EOM supported? Must be able to read file number afterwards as
93    well. */
94 extern DevicePropertyBase device_property_eom;
95 #define PROPERTY_EOM (device_property_eom.ID)
96
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)
100
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)
104
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)
109
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);
120
121 #endif