MiniDLNA update: 1.0.19.1 to 1.0.20
[tomato.git] / release / src / router / ntfs-3g / include / ntfs-3g / device.h
blobad34ac565c0706ed9f21aac212fd63d8d36801fe
1 /*
2 * device.h - Exports for low level device io. Originated from the Linux-NTFS project.
4 * Copyright (c) 2000-2006 Anton Altaparmakov
6 * This program/include file is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as published
8 * by the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program/include file is distributed in the hope that it will be
12 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program (in the main directory of the NTFS-3G
18 * distribution in the file COPYING); if not, write to the Free Software
19 * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #ifndef _NTFS_DEVICE_H
23 #define _NTFS_DEVICE_H
25 #ifdef HAVE_CONFIG_H
26 #include "config.h"
27 #endif
29 #include "device_io.h"
30 #include "types.h"
31 #include "support.h"
32 #include "volume.h"
34 /**
35 * enum ntfs_device_state_bits -
37 * Defined bits for the state field in the ntfs_device structure.
39 typedef enum {
40 ND_Open, /* 1: Device is open. */
41 ND_ReadOnly, /* 1: Device is read-only. */
42 ND_Dirty, /* 1: Device is dirty, needs sync. */
43 ND_Block, /* 1: Device is a block device. */
44 ND_Sync, /* 1: Device is mounted with "-o sync" */
45 } ntfs_device_state_bits;
47 #define test_ndev_flag(nd, flag) test_bit(ND_##flag, (nd)->d_state)
48 #define set_ndev_flag(nd, flag) set_bit(ND_##flag, (nd)->d_state)
49 #define clear_ndev_flag(nd, flag) clear_bit(ND_##flag, (nd)->d_state)
51 #define NDevOpen(nd) test_ndev_flag(nd, Open)
52 #define NDevSetOpen(nd) set_ndev_flag(nd, Open)
53 #define NDevClearOpen(nd) clear_ndev_flag(nd, Open)
55 #define NDevReadOnly(nd) test_ndev_flag(nd, ReadOnly)
56 #define NDevSetReadOnly(nd) set_ndev_flag(nd, ReadOnly)
57 #define NDevClearReadOnly(nd) clear_ndev_flag(nd, ReadOnly)
59 #define NDevDirty(nd) test_ndev_flag(nd, Dirty)
60 #define NDevSetDirty(nd) set_ndev_flag(nd, Dirty)
61 #define NDevClearDirty(nd) clear_ndev_flag(nd, Dirty)
63 #define NDevBlock(nd) test_ndev_flag(nd, Block)
64 #define NDevSetBlock(nd) set_ndev_flag(nd, Block)
65 #define NDevClearBlock(nd) clear_ndev_flag(nd, Block)
67 #define NDevSync(nd) test_ndev_flag(nd, Sync)
68 #define NDevSetSync(nd) set_ndev_flag(nd, Sync)
69 #define NDevClearSync(nd) clear_ndev_flag(nd, Sync)
71 /**
72 * struct ntfs_device -
74 * The ntfs device structure defining all operations needed to access the low
75 * level device underlying the ntfs volume.
77 struct ntfs_device {
78 struct ntfs_device_operations *d_ops; /* Device operations. */
79 unsigned long d_state; /* State of the device. */
80 char *d_name; /* Name of device. */
81 void *d_private; /* Private data used by the
82 device operations. */
85 struct stat;
87 /**
88 * struct ntfs_device_operations -
90 * The ntfs device operations defining all operations that can be performed on
91 * the low level device described by an ntfs device structure.
93 struct ntfs_device_operations {
94 int (*open)(struct ntfs_device *dev, int flags);
95 int (*close)(struct ntfs_device *dev);
96 s64 (*seek)(struct ntfs_device *dev, s64 offset, int whence);
97 s64 (*read)(struct ntfs_device *dev, void *buf, s64 count);
98 s64 (*write)(struct ntfs_device *dev, const void *buf, s64 count);
99 s64 (*pread)(struct ntfs_device *dev, void *buf, s64 count, s64 offset);
100 s64 (*pwrite)(struct ntfs_device *dev, const void *buf, s64 count,
101 s64 offset);
102 int (*sync)(struct ntfs_device *dev);
103 int (*stat)(struct ntfs_device *dev, struct stat *buf);
104 int (*ioctl)(struct ntfs_device *dev, int request, void *argp);
107 extern struct ntfs_device *ntfs_device_alloc(const char *name, const long state,
108 struct ntfs_device_operations *dops, void *priv_data);
109 extern int ntfs_device_free(struct ntfs_device *dev);
110 extern int ntfs_device_sync(struct ntfs_device *dev);
112 extern s64 ntfs_pread(struct ntfs_device *dev, const s64 pos, s64 count,
113 void *b);
114 extern s64 ntfs_pwrite(struct ntfs_device *dev, const s64 pos, s64 count,
115 const void *b);
117 extern s64 ntfs_mst_pread(struct ntfs_device *dev, const s64 pos, s64 count,
118 const u32 bksize, void *b);
119 extern s64 ntfs_mst_pwrite(struct ntfs_device *dev, const s64 pos, s64 count,
120 const u32 bksize, void *b);
122 extern s64 ntfs_cluster_read(const ntfs_volume *vol, const s64 lcn,
123 const s64 count, void *b);
124 extern s64 ntfs_cluster_write(const ntfs_volume *vol, const s64 lcn,
125 const s64 count, const void *b);
127 extern s64 ntfs_device_size_get(struct ntfs_device *dev, int block_size);
128 extern s64 ntfs_device_partition_start_sector_get(struct ntfs_device *dev);
129 extern int ntfs_device_heads_get(struct ntfs_device *dev);
130 extern int ntfs_device_sectors_per_track_get(struct ntfs_device *dev);
131 extern int ntfs_device_sector_size_get(struct ntfs_device *dev);
132 extern int ntfs_device_block_size_set(struct ntfs_device *dev, int block_size);
134 #endif /* defined _NTFS_DEVICE_H */