6b5796f7e44297b7f7be89562148f3ed65e0ba35
[debian/amanda] / device-src / vfs-device.h
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 /* The VFS device is the driver formerly known as the vtape driver or
22  * the file driver. It uses a directory on the UNIX filesystem as a
23  * data store. */
24
25 #include <glib.h>
26 #include <glib-object.h>
27 #include "device.h"
28 #include <dirent.h>
29
30 #ifndef VFS_DEVICE_H
31 #define VFS_DEVICE_H
32
33 #define VFS_DEVICE_MIN_BLOCK_SIZE (1)
34 #define VFS_DEVICE_MAX_BLOCK_SIZE (INT_MAX)
35 #define VFS_DEVICE_DEFAULT_BLOCK_SIZE (MAX_TAPE_BLOCK_BYTES)
36 #define VFS_DEVICE_LABEL_SIZE (32768)
37
38 /* This looks dangerous, but is actually modified by the umask. */
39 #define VFS_DEVICE_CREAT_MODE 0666
40
41 /*
42  * Type checking and casting macros
43  */
44 #define TYPE_VFS_DEVICE (vfs_device_get_type())
45 #define VFS_DEVICE(obj) G_TYPE_CHECK_INSTANCE_CAST((obj), vfs_device_get_type(), VfsDevice)
46 #define VFS_DEVICE_CONST(obj)   G_TYPE_CHECK_INSTANCE_CAST((obj), vfs_device_get_type(), VfsDevice const)
47 #define VFS_DEVICE_CLASS(klass) G_TYPE_CHECK_CLASS_CAST((klass), vfs_device_get_type(), VfsDeviceClass)
48 #define IS_VFS_DEVICE(obj)      G_TYPE_CHECK_INSTANCE_TYPE((obj), vfs_device_get_type ())
49
50 #define VFS_DEVICE_GET_CLASS(obj)       G_TYPE_INSTANCE_GET_CLASS((obj), vfs_device_get_type(), VfsDeviceClass)
51
52 /*
53  * Main object structure
54  */
55 typedef struct {
56     Device __parent__;
57
58     /*< private >*/
59     DIR * dir_handle;
60     char * dir_name;
61     char * file_name;
62     int file_lock_fd;
63     char * file_lock_name;
64     int volume_lock_fd;
65     char * volume_lock_name;
66     int open_file_fd;
67     
68     /* Properties */
69     int block_size;
70     guint64 volume_bytes;
71     guint64 volume_limit;
72 } VfsDevice;
73
74 /*
75  * Class definition
76  */
77 typedef struct {
78     DeviceClass __parent__;
79 } VfsDeviceClass;
80
81
82 /*
83  * Public methods
84  */
85 GType   vfs_device_get_type     (void);
86 void    vfs_device_register     (void);
87
88 #endif
89