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