xref: /reactos/drivers/filesystems/ext2/inc/common.h (revision aaeb131b)
1 #ifndef _EXT2_COMMON_INCLUDE_
2 #define _EXT2_COMMON_INCLUDE_
3 
4 /* global ioctl */
5 #define IOCTL_APP_VOLUME_PROPERTY \
6 CTL_CODE(FILE_DEVICE_UNKNOWN, 2000, METHOD_BUFFERED, FILE_ANY_ACCESS)
7 
8 #define IOCTL_APP_QUERY_PERFSTAT \
9 CTL_CODE(FILE_DEVICE_UNKNOWN, 2001, METHOD_BUFFERED, FILE_ANY_ACCESS)
10 
11 #define IOCTL_APP_MOUNT_POINT \
12 CTL_CODE(FILE_DEVICE_UNKNOWN, 2002, METHOD_BUFFERED, FILE_ANY_ACCESS)
13 
14 
15 /* performance / memory allocaiton statistics */
16 #define PS_IRP_CONTEXT  0x00
17 #define PS_VCB          0x01
18 #define PS_FCB          0x02
19 #define PS_CCB          0x03
20 #define PS_MCB          0x04
21 #define PS_EXTENT       0x05
22 #define PS_RW_CONTEXT   0x06
23 #define PS_VPB          0x07
24 #define PS_FILE_NAME    0x08
25 #define PS_MCB_NAME     0x09
26 #define PS_INODE_NAME   0x0A
27 #define PS_DIR_ENTRY    0x0B
28 #define PS_DIR_PATTERN  0x0C
29 #define PS_DISK_EVENT   0x0D
30 #define PS_DISK_BUFFER  0x0E
31 #define PS_BLOCK_DATA   0x0F
32 
33 #define PS_EXT2_INODE   0x10
34 #define PS_DENTRY       0x11
35 #define PS_BUFF_HEAD    0x12
36 
37 #define PS_MAX_TYPE_V1  (0x10)
38 #define PS_MAX_TYPE_V2  (0x30)
39 
40 typedef union {
41 
42     ULONG           Slot[PS_MAX_TYPE_V1];
43 
44     struct {
45         ULONG       IrpContext;
46         ULONG       Vcb;
47         ULONG       Fcb;
48         ULONG       Ccb;
49         ULONG       Mcb;
50         ULONG       Extent;
51         ULONG       RwContext;   /* rw context */
52         ULONG       Vpb;
53         ULONG       FileName;
54         ULONG       McbName;
55         ULONG       InodeName;
56         ULONG       DirEntry;    /* pDir */
57         ULONG       DirPattern;  /* Ccb-> in Ext2QeuryDir */
58         ULONG       ReadDiskEvent;
59         ULONG       ReadDiskBuffer;
60         ULONG       BlockData;   /* Ext2Expand&TruncateFile*/
61     };
62 
63 } EXT2_STAT_ARRAY_V1;
64 
65 typedef union {
66 
67     ULONG           Slot[PS_MAX_TYPE_V2];
68 
69     struct {
70         ULONG       IrpContext;
71         ULONG       Vcb;
72         ULONG       Fcb;
73         ULONG       Ccb;
74         ULONG       Mcb;
75         ULONG       Extent;
76         ULONG       RwContext;  /* rw context */
77         ULONG       Vpb;
78         ULONG       FileName;
79         ULONG       McbName;
80         ULONG       InodeName;
81         ULONG       DirEntry;   /* pDir */
82         ULONG       DirPattern; /* Ccb-> in Ext2QeuryDir */
83         ULONG       ReadDiskEvent;
84         ULONG       ReadDiskBuffer;
85         ULONG       BlockData;  /* Ext2Expand&TruncateFile*/
86         ULONG       Inodes;     /* inodes */
87         ULONG       NameEntries;    /* name dentry */
88         ULONG       BufferHead; /* Buffer Header allocations */
89     };
90 
91 } EXT2_STAT_ARRAY_V2;
92 
93 typedef struct _EXT2_PERF_STATISTICS_V1 {
94 
95     /* totoal number of processed/being processed requests */
96     struct {
97         ULONG           Processed;
98         ULONG           Current;
99     } Irps [IRP_MJ_MAXIMUM_FUNCTION + 1];
100 
101     /* structure size */
102     EXT2_STAT_ARRAY_V1  Unit;
103 
104     /* current memory allocation statistics */
105     EXT2_STAT_ARRAY_V1  Current;
106 
107     /* memory allocated in bytes */
108     EXT2_STAT_ARRAY_V1  Size;
109 
110     /* totoal memory allocation statistics */
111     EXT2_STAT_ARRAY_V1  Total;
112 
113 } EXT2_PERF_STATISTICS_V1, *PEXT2_PERF_STATISTICS_V1;
114 
115 #define EXT2_PERF_STAT_MAGIC '2SPE'
116 #define EXT2_PERF_STAT_VER2   2
117 
118 typedef struct _EXT2_PERF_STATISTICS_V2 {
119 
120     ULONG               Magic;      /* EPS2 */
121     USHORT              Version;    /* 02 */
122     USHORT              Length;     /* sizeof(EXT2_PERF_STATISTICS_V2) */
123 
124     /* totoal number of processed/being processed requests */
125     struct {
126         ULONG           Processed;
127         ULONG           Current;
128     } Irps [IRP_MJ_MAXIMUM_FUNCTION + 1];
129 
130     /* structure size */
131     EXT2_STAT_ARRAY_V2  Unit;
132 
133     /* current memory allocation statistics */
134     EXT2_STAT_ARRAY_V2  Current;
135 
136     /* memory allocated in bytes */
137     EXT2_STAT_ARRAY_V2  Size;
138 
139     /* totoal memory allocation statistics */
140     EXT2_STAT_ARRAY_V2  Total;
141 
142 } EXT2_PERF_STATISTICS_V2, *PEXT2_PERF_STATISTICS_V2;
143 
144 /* volume property ... */
145 
146 #define EXT2_VOLUME_PROPERTY_MAGIC 'EVPM'
147 
148 #define EXT2_FLAG_VP_SET_GLOBAL   0x00000001
149 
150 #define APP_CMD_QUERY_VERSION     0x00000000 /* with global flag set */
151 #define APP_CMD_QUERY_CODEPAGES   0x00000001
152 #define APP_CMD_QUERY_PROPERTY    0x00000002
153 #define APP_CMD_SET_PROPERTY      0x00000003
154 #define APP_CMD_QUERY_PROPERTY2   0x00000004
155 #define APP_CMD_SET_PROPERTY2     0x00000005
156 #define APP_CMD_QUERY_PROPERTY3   0x00000006
157 #define APP_CMD_SET_PROPERTY3     0x00000007
158 
159 #define CODEPAGE_MAXLEN     0x20
160 #define HIDINGPAT_LEN       0x20
161 
162 typedef struct _EXT2_VOLUME_PROPERTY {
163     ULONG               Magic;
164     ULONG               Flags;
165     ULONG               Command;
166     BOOLEAN             bReadonly;
167     BOOLEAN             bExt3Writable;
168     BOOLEAN             bExt2;
169     BOOLEAN             bExt3;
170     CHAR                Codepage[CODEPAGE_MAXLEN];
171 } EXT2_VOLUME_PROPERTY, *PEXT2_VOLUME_PROPERTY;
172 
173 #ifdef __cplusplus
174 typedef struct _EXT2_VOLUME_PROPERTY2:EXT2_VOLUME_PROPERTY {
175 #else   // __cplusplus
176 typedef struct _EXT2_VOLUME_PROPERTY2 {
177     EXT2_VOLUME_PROPERTY ;
178 #endif  // __cplusplus
179 
180     /* new volume properties added after version 0.35 */
181 
182     /* volume uuid */
183     __u8	                    UUID[16];
184 
185     /* mount point: driver letter only */
186     UCHAR                       DrvLetter;
187 
188     /* checking bitmap */
189     BOOLEAN                     bCheckBitmap;
190 
191     /* global hiding patterns */
192     BOOLEAN                     bHidingPrefix;
193     BOOLEAN                     bHidingSuffix;
194     CHAR                        sHidingPrefix[HIDINGPAT_LEN];
195     CHAR                        sHidingSuffix[HIDINGPAT_LEN];
196 
197 } EXT2_VOLUME_PROPERTY2, *PEXT2_VOLUME_PROPERTY2;
198 
199 #ifdef __REACTOS__
200 #define EXT2_VPROP3_AUTOMOUNT (1ULL << 0)
201 #define EXT2_VPROP3_USERIDS   (1ULL << 1)
202 #else
203 #define EXT2_VPROP3_AUTOMOUNT (1ui64 << 0)
204 #define EXT2_VPROP3_USERIDS   (1ui64 << 1)
205 #endif
206 
207 #ifdef __cplusplus
208 typedef struct _EXT2_VOLUME_PROPERTY3:EXT2_VOLUME_PROPERTY2 {
209 #else   // __cplusplus
210 typedef struct _EXT2_VOLUME_PROPERTY3 {
211     EXT2_VOLUME_PROPERTY2 ;
212 #endif  // __cplusplus
213     unsigned __int64       Flags2;
214     ULONG                  AutoMount:1;
215     ULONG                  EIDS:1;
216     ULONG                  Reserved1:30;
217     USHORT                 uid;
218     USHORT                 gid;
219     USHORT                 euid;
220     USHORT                 egid;
221     ULONG                  Reserved2[29];
222 } EXT2_VOLUME_PROPERTY3, *PEXT2_VOLUME_PROPERTY3;
223 
224 /* Ext2Fsd driver version and built time */
225 typedef struct _EXT2_VOLUME_PROPERTY_VERSION {
226     ULONG               Magic;
227     ULONG               Flags;
228     ULONG               Command;
229     CHAR                Version[0x1C];
230     CHAR                Time[0x20];
231     CHAR                Date[0x20];
232 } EXT2_VOLUME_PROPERTY_VERSION, *PEXT2_VOLUME_PROPERTY_VERSION;
233 
234 /* performance statistics */
235 #define EXT2_QUERY_PERFSTAT_MAGIC 'EVPM'
236 #define EXT2_QUERY_PERFSTAT_VER2  0x8000000
237 
238 typedef struct _EXT2_QUERY_PERFSTAT {
239     ULONG                   Magic;
240     ULONG                   Flags;
241     ULONG                   Command;
242     union {
243         EXT2_PERF_STATISTICS_V1 PerfStatV1;
244         EXT2_PERF_STATISTICS_V2 PerfStatV2;
245     };
246 } EXT2_QUERY_PERFSTAT, *PEXT2_QUERY_PERFSTAT;
247 
248 #define EXT2_QUERY_PERFSTAT_SZV1 (FIELD_OFFSET(EXT2_QUERY_PERFSTAT, PerfStatV1) + sizeof(EXT2_PERF_STATISTICS_V1))
249 #define EXT2_QUERY_PERFSTAT_SZV2 (FIELD_OFFSET(EXT2_QUERY_PERFSTAT, PerfStatV1) + sizeof(EXT2_PERF_STATISTICS_V2))
250 
251 /* mountpoint management  */
252 #define EXT2_APP_MOUNTPOINT_MAGIC 'EAMM'
253 typedef struct _EXT2_MOUNT_POINT {
254     ULONG                   Magic;
255     ULONG                   Flags;
256     ULONG                   Size;
257     ULONG                   Command;
258     USHORT                  Link[256];
259     USHORT                  Name[256];
260 } EXT2_MOUNT_POINT, *PEXT2_MOUNT_POINT;
261 
262 #define APP_CMD_ADD_DOS_SYMLINK    0x00000001
263 #define APP_CMD_DEL_DOS_SYMLINK    0x00000002
264 
265 
266 #endif /* _EXT2_COMMON_INCLUDE_ */
267