80e5bbe0d8cdccf05b27121e95eac0092ebbed73
[tpg/acess2.git] / KernelLand / Modules / Filesystems / NTFS / common.h
1 /*
2  * Acess2 - NTFS Driver
3  * By John Hodge (thePowersGang)
4  * This file is published under the terms of the Acess licence. See the
5  * file COPYING for details.
6  *
7  * common.h - Common Types and Definitions
8  */
9 #ifndef _NTFS__COMMON_H_
10 #define _NTFS__COMMON_H_
11
12 #include <acess.h>
13 #include <vfs.h>
14 #include "ntfs.h"
15
16 typedef struct sNTFS_File       tNTFS_File;
17 typedef struct sNTFS_Directory  tNTFS_Directory;
18 typedef struct sNTFS_Disk       tNTFS_Disk;
19 typedef struct sNTFS_Attrib     tNTFS_Attrib;
20 typedef struct sNTFS_AttribDataRun      tNTFS_AttribDataRun;
21
22 // === STRUCTURES ===
23
24 struct sNTFS_File
25 {
26         tVFS_Node       Node;
27         tNTFS_Attrib    *Data;
28 };
29
30 struct sNTFS_Directory
31 {
32         tVFS_Node       Node;
33         tNTFS_Attrib    *I30Root;
34         tNTFS_Attrib    *I30Allocation;
35 };
36
37 /**
38  * In-memory representation of an NTFS Disk
39  */
40 struct sNTFS_Disk
41 {
42          int    FD;
43          int    CacheHandle;
44          
45          int    ClusterSize;
46         
47         Uint64  MFTBase;
48         Uint32  MFTRecSize;
49         
50         tNTFS_Attrib    *MFTDataAttr;
51         tNTFS_Attrib    *MFTBitmapAttr;
52
53          int    InodeCache;
54         
55         tNTFS_Directory RootDir;
56 };
57
58 struct sNTFS_AttribDataRun
59 {
60         Uint64  Count;
61         Uint64  LCN;
62 };
63
64 struct sNTFS_Attrib
65 {
66         tNTFS_Disk      *Disk;
67         Uint32  Type;
68
69         char    *Name;
70
71         Uint64  DataSize;       
72
73          int    IsResident;
74         union {
75                 void    *ResidentData;
76                 struct {
77                          int    nRuns;
78                          int    CompressionUnitL2Size;  // 0 = uncompressed
79                         Uint64  FirstPopulatedCluster;
80                         tNTFS_AttribDataRun     *Runs;
81                 } NonResident;
82         };
83 };
84
85 extern tVFS_NodeType    gNTFS_DirType;
86 extern tVFS_NodeType    gNTFS_FileType;
87
88 extern int      NTFS_int_ApplyUpdateSequence(void *Buf, size_t BufLen, const Uint16 *Sequence, size_t NumEntries);
89 // -- MFT Access / Manipulation
90 extern tNTFS_FILE_Header        *NTFS_GetMFT(tNTFS_Disk *Disk, Uint32 MFTEntry);
91 extern void     NTFS_ReleaseMFT(tNTFS_Disk *Disk, Uint32 MFTEntry, tNTFS_FILE_Header *Entry);
92 extern tNTFS_Attrib     *NTFS_GetAttrib(tNTFS_Disk *Disk, Uint32 MFTEntry, int Type, const char *Name, int DesIdx);
93 extern size_t   NTFS_ReadAttribData(tNTFS_Attrib *Attrib, Uint64 Offset, size_t Length, void *Buffer);
94 // -- dir.c
95 extern int      NTFS_ReadDir(tVFS_Node *Node, int Pos, char Dest[FILENAME_MAX]);
96 extern tVFS_Node        *NTFS_FindDir(tVFS_Node *Node, const char *Name, Uint Flags);
97
98 #endif

UCC git Repository :: git.ucc.asn.au