Change gfx.hidd API -:
[AROS.git] / workbench / fs / ntfs / ntfs_fs.h
blob06a72fe9ed24f23afc54bb23aa2c334497ebd61f
1 /*
2 * ntfs.handler - New Technology FileSystem handler
4 * Copyright © 2012 The AROS Development Team
6 * This program is free software; you can redistribute it and/or modify it
7 * under the same terms as AROS itself.
9 * $Id $
12 #ifndef NTFS_FS_H
13 #define NTFS_FS_H
15 //#define DEBUG 1
17 #define DEBUG_DIRENTRY 0
18 #define DEBUG_FILE 0
19 #define DEBUG_DUMP 0
20 #define DEBUG_LOCK 0
21 #define DEBUG_NAMES 0
22 #define DEBUG_NOTIFY 0
23 #define DEBUG_OPS 0
24 #define DEBUG_PACKETS 0
25 #define DEBUG_CACHESTATS 0
26 #define DEBUG_MISC 0
28 #include <aros/libcall.h>
29 #include <devices/trackdisk.h>
30 #include <libraries/uuid.h>
32 #include "ntfs_struct.h"
34 #include "cache.h"
36 #define NTFS_READONLY
38 extern struct Globals *glob;
40 /* filesystem structures */
41 #define ID_NTFS_DISK 0x4E544653UL
43 #define ACTION_VOLUME_ADD 16000
44 #define ACTION_VOLUME_REMOVE 16001
46 #define DEF_POOL_SIZE 65536
47 #define DEF_POOL_THRESHOLD DEF_POOL_SIZE
48 #define DEF_BUFF_LINES 128
49 #define DEF_READ_AHEAD 16*1024
51 #define SECTORSIZE_SHIFT 9
53 #define RLEFLAG_COMPR (1 << 0)
54 #define RLEFLAG_SPARSE (1 << 1)
56 struct NTFSMFTAttr
58 struct MFTAttr *emft_buf;
59 struct MFTAttr *edat_buf;
60 struct MFTAttr *attr_cur;
61 struct MFTAttr *attr_nxt;
62 struct MFTAttr *attr_end;
63 struct NTFSMFTEntry *mft;
64 struct MFTAttr *sbuf;
65 ULONG save_pos;
66 UBYTE flags;
69 struct NTFSMFTEntry
71 struct FSData *data;
72 APTR cblock; /* current block from the cache */
73 UBYTE *cbuf; /* current data buffer (from cache) */
74 UBYTE *buf; /* MFT Entry Buffer */
75 UQUAD size;
76 UQUAD mftrec_no;
77 struct NTFSMFTAttr attr;
78 UBYTE buf_filled;
81 struct NTFSRunLstEntry
83 struct NTFSMFTAttr *attr;
84 UBYTE *mappingpair;
85 UQUAD target_vcn;
86 UQUAD curr_vcn;
87 UQUAD next_vcn;
88 UQUAD curr_lcn;
89 UBYTE flags;
92 /* a handle on something, file or directory */
93 struct IOHandle {
94 struct FSData *data; /* filesystem data */
96 UQUAD first_cluster; /* first cluster of this file */
98 struct NTFSMFTEntry mft;
99 UBYTE *bitmap;
100 UQUAD bitmap_len;
103 /* a handle on a directory */
104 struct DirHandle {
105 struct IOHandle ioh;
106 UQUAD parent_mft;
107 UBYTE *idx_root;
108 struct NTFSMFTAttr idx_attr;
109 ULONG cur_no; /* last entry returned, for GetNextDirEntry */
112 struct Index_Key {
113 UBYTE *indx;
114 UBYTE *bitmap;
115 UBYTE *pos; /* byte offset within index record that the entry came from */
116 ULONG current; /* index no. of this entry */
117 UQUAD i;
118 UWORD v;
121 /* single directory entry */
122 struct DirEntry {
123 struct FSData *data; /* filesystem data */
124 struct Index_Key *key;
125 struct NTFSMFTEntry *entry;
126 char *entryname;
127 ULONG entrytype;
128 ULONG no;
129 UQUAD cluster; /* cluster the containing directory starts at */
132 struct GlobalLock;
134 struct ExtFileLock {
135 /* struct FileLock */
136 BPTR fl_Link;
137 IPTR fl_Key;
138 LONG fl_Access;
139 struct MsgPort *fl_Task;
140 BPTR fl_Volume;
142 ULONG magic; /* we set this to ID_NTFS_DISK so we can tell
143 our locks from those of other filesystems */
145 struct FSData *data; /* pointer to data, for unlocking when volume is removed */
146 struct GlobalLock *gl; /* pointer to the global lock for this file */
147 struct MinNode node; /* node in the list of locks attached to the global lock */
149 struct DirHandle *dir; /* handle for reads and writes */
150 struct DirEntry *entry; /* handle for reads and writes */
151 UQUAD pos; /* current seek position within the file */
153 BOOL do_notify; /* if set, send notification on file close (ACTION_END) */
156 struct GlobalLock {
157 struct MinNode node;
159 ULONG dir_cluster; /* first cluster of the directory we're in */
160 ULONG dir_entry; /* this is our dir entry within dir_cluster */
162 LONG access; /* access mode, shared or exclusive */
164 ULONG first_cluster; /* first data cluster */
166 ULONG attr; /* file attributes, from the dir entry */
167 UQUAD size; /* file size, from the dir entry */
169 UBYTE name[256]; /* copy of the name (bstr) */
171 struct MinList locks; /* list of ExtFileLocks opened on this file */
174 /* a node in the list of notification requests */
175 struct NotifyNode {
176 struct MinNode node;
178 struct GlobalLock *gl; /* pointer to global lock if this file is
179 locked. if it's not, this is NULL */
181 struct NotifyRequest *nr; /* the request that DOS passed us */
184 struct VolumeInfo {
185 struct MinList locks; /* global locks */
186 struct MinList notifies;
187 APTR mem_pool;
188 struct GlobalLock root_lock;
189 uuid_t uuid;
192 struct VolumeIdentity {
193 UBYTE name[128]; /* BCPL string */
194 struct DateStamp create_time;
197 struct FSData {
198 struct Node node;
199 struct DosList *doslist;
201 struct VolumeInfo *info;
203 struct cache *cache;
204 ULONG first_device_sector;
206 ULONG sectorsize;
207 ULONG sectorsize_bits;
209 ULONG cluster_sectors;
210 ULONG clustersize;
211 ULONG clustersize_bits;
212 ULONG cluster_sectors_bits;
214 struct NTFSMFTEntry mft; /* Handle for $MFT access */
215 struct NTFSMFTEntry bmmft; /* Handle for $Bitmap access */
216 struct NTFSMFTEntry logmft; /* Handle for $LogFile access */
217 struct NTFSMFTEntry secmft; /* Handle for $LogFile access */
219 ULONG idx_size;
220 ULONG mft_size;
221 UQUAD mft_start;
223 uuid_t uuid;
225 struct VolumeIdentity volume;
227 UQUAD total_sectors;
228 UQUAD used_sectors;
231 struct Globals {
232 /* mem/task */
233 struct Task *ourtask;
234 struct MsgPort *ourport;
235 APTR mempool;
237 struct MsgPort *notifyport;
239 /* fs */
240 struct DosList *devnode;
241 struct FileSysStartupMsg *fssm;
242 LONG quit;
243 struct DosPacket *death_packet;
244 BOOL autodetect;
246 /* io */
247 struct IOExtTD *diskioreq;
248 struct IOExtTD *diskchgreq;
249 struct MsgPort *diskport;
250 ULONG diskchgsig_bit;
251 struct timerequest *timereq;
252 struct MsgPort *timerport;
253 ULONG last_num; /* last block number that was outside boundaries */
254 UWORD readcmd;
255 UWORD writecmd;
256 char timer_active;
257 char restart_timer;
259 /* volumes */
260 struct FSData *data; /* current data */
261 struct MinList sblist; /* sbs with outstanding locks or notifies */
263 /* disk status */
264 LONG disk_inserted;
265 LONG disk_inhibited;
267 /* Character sets translation */
268 UBYTE from_unicode[65536];
269 UWORD to_unicode[256];
272 //#include "support.h"
274 /* new definitions as we refactor the code */
276 #define RESET_HANDLE(ioh) \
277 do { \
278 if ((ioh)->mft.cblock != NULL) { \
279 Cache_FreeBlock((ioh)->data->cache, (ioh)->mft.cblock); \
280 (ioh)->mft.cblock = NULL; \
282 } while (0);
284 #define RESET_DIRHANDLE(dh) \
285 do { \
286 RESET_HANDLE(&((dh)->ioh)); \
287 (dh)->cur_no = -1; \
288 } while(0);
290 #define LOCKFROMNODE(A) \
291 ((struct ExtFileLock *) \
292 (((BYTE *)(A)) - (IPTR)&((struct ExtFileLock *)NULL)->node))
294 #define INIT_MFTATTRIB(attrib, mftentry) \
296 struct NTFSMFTAttr *tmpattr = (struct NTFSMFTAttr *)attrib; \
297 tmpattr->mft = mftentry; \
298 tmpattr->flags = (tmpattr->mft == &tmpattr->mft->data->mft) ? AF_MMFT : 0; \
299 tmpattr->attr_nxt = (struct MFTAttr *)(tmpattr->mft->buf + AROS_LE2WORD(*((UWORD *)(tmpattr->mft->buf + 0x14)))); \
300 tmpattr->attr_end = tmpattr->emft_buf = tmpattr->edat_buf = tmpattr->sbuf = NULL; \
303 #endif