4586e12e5a24354ab699f694b75938c029bb60a4
[tpg/acess2.git] / KernelLand / Modules / Filesystems / NTFS / main.c
1 /*
2  * Acess2 - NTFS Driver
3  * By John Hodge (thePowersGang)
4  *
5  * main.c
6  * - Driver core
7  *
8  * Reference: ntfsdoc.pdf
9  */
10 #define DEBUG   0
11 #define VERBOSE 0
12 #include <acess.h>
13 #include <vfs.h>
14 #include "common.h"
15 #include <modules.h>
16 #include <utf16.h>
17
18 // === PROTOTYPES ===
19  int    NTFS_Install(char **Arguments);
20  int    NTFS_Detect(int FD);
21 tVFS_Node       *NTFS_InitDevice(const char *Devices, const char **Options);
22 void    NTFS_Unmount(tVFS_Node *Node);
23 // - MFT Related Functions
24 tNTFS_FILE_Header       *NTFS_GetMFT(tNTFS_Disk *Disk, Uint32 MFTEntry);
25 void    NTFS_ReleaseMFT(tNTFS_Disk *Disk, Uint32 MFTEntry, tNTFS_FILE_Header *Entry);
26 tNTFS_Attrib    *NTFS_GetAttrib(tNTFS_Disk *Disk, Uint32 MFTEntry, int Type, const char *Name, int DesIdx);
27 size_t  NTFS_ReadAttribData(tNTFS_Attrib *Attrib, Uint64 Offset, size_t Length, void *Buffer);
28 void    NTFS_DumpEntry(tNTFS_Disk *Disk, Uint32 Entry);
29
30 // === GLOBALS ===
31 MODULE_DEFINE(0, 0x0A /*v0.1*/, FS_NTFS, NTFS_Install, NULL);
32 tVFS_Driver     gNTFS_FSInfo = {
33         .Name = "ntfs",
34         .Detect = NTFS_Detect,
35         .InitDevice = NTFS_InitDevice,
36         .Unmount = NTFS_Unmount,
37         .GetNodeFromINode = NULL
38 };
39 tVFS_NodeType   gNTFS_DirType = {
40         .TypeName = "NTFS-Dir",
41         .ReadDir = NTFS_ReadDir,
42         .FindDir = NTFS_FindDir,
43         .Close = NTFS_Close
44         };
45 tVFS_NodeType   gNTFS_FileType = {
46         .TypeName = "NTFS-File",
47         .Read = NTFS_ReadFile,
48         .Close = NTFS_Close
49         };
50
51 tNTFS_Disk      gNTFS_Disks;
52
53 // === CODE ===
54 /**
55  * \brief Installs the NTFS driver
56  */
57 int NTFS_Install(char **Arguments)
58 {
59         VFS_AddDriver( &gNTFS_FSInfo );
60         return 0;
61 }
62
63 /**
64  * \brief Detect if a volume is NTFS
65  */
66 int NTFS_Detect(int FD)
67 {
68         tNTFS_BootSector        bs;
69         VFS_ReadAt(FD, 0, 512, &bs);
70         
71         if( bs.BytesPerSector == 0 || (bs.BytesPerSector & 511) )
72                 return 0;
73
74         Uint64  ncluster = bs.TotalSectorCount / bs.SectorsPerCluster;
75         if( bs.MFTStart >= ncluster || bs.MFTMirrorStart >= ncluster )
76                 return 0;
77
78         if( memcmp(bs.SystemID, "NTFS    ", 8) != 0 )
79                 return 0;
80         
81         return 1;
82 }
83
84 /**
85  * \brief Mount a NTFS volume
86  */
87 tVFS_Node *NTFS_InitDevice(const char *Device, const char **Options)
88 {
89         tNTFS_Disk      *disk;
90         tNTFS_BootSector        bs;
91         
92         disk = calloc( sizeof(tNTFS_Disk), 1 );
93         
94         disk->FD = VFS_Open(Device, VFS_OPENFLAG_READ);
95         if(!disk->FD) {
96                 free(disk);
97                 return NULL;
98         }
99         
100         VFS_ReadAt(disk->FD, 0, 512, &bs);
101
102 #if 0   
103         Log_Debug("FS_NTFS", "Jump = %02x%02x%02x",
104                 bs.Jump[0],
105                 bs.Jump[1],
106                 bs.Jump[2]);
107         Log_Debug("FS_NTFS", "SystemID = %02x%02x%02x%02x%02x%02x%02x%02x (%8C)",
108                 bs.SystemID[0], bs.SystemID[1], bs.SystemID[2], bs.SystemID[3],
109                 bs.SystemID[4], bs.SystemID[5], bs.SystemID[6], bs.SystemID[7],
110                 bs.SystemID
111                 );
112         Log_Debug("FS_NTFS", "BytesPerSector = %i", bs.BytesPerSector);
113         Log_Debug("FS_NTFS", "SectorsPerCluster = %i", bs.SectorsPerCluster);
114         Log_Debug("FS_NTFS", "MediaDescriptor = 0x%x", bs.MediaDescriptor);
115         Log_Debug("FS_NTFS", "SectorsPerTrack = %i", bs.SectorsPerTrack);
116         Log_Debug("FS_NTFS", "Heads = %i", bs.Heads);
117         Log_Debug("FS_NTFS", "TotalSectorCount = 0x%llx", bs.TotalSectorCount);
118         Log_Debug("FS_NTFS", "MFTStart = 0x%llx", bs.MFTStart);
119         Log_Debug("FS_NTFS", "MFTMirrorStart = 0x%llx", bs.MFTMirrorStart);
120         Log_Debug("FS_NTFS", "ClustersPerMFTRecord = %i", bs.ClustersPerMFTRecord);
121         Log_Debug("FS_NTFS", "ClustersPerIndexRecord = %i", bs.ClustersPerIndexRecord);
122         Log_Debug("FS_NTFS", "SerialNumber = 0x%llx", bs.SerialNumber);
123 #endif
124         
125         disk->ClusterSize = bs.BytesPerSector * bs.SectorsPerCluster;
126         disk->MFTBase = bs.MFTStart;
127         Log_Debug("NTFS", "Cluster Size = %i KiB", disk->ClusterSize/1024);
128         Log_Debug("NTFS", "MFT Base = %i", disk->MFTBase);
129         Log_Debug("NTFS", "TotalSectorCount = 0x%x", bs.TotalSectorCount);
130         
131         if( bs.ClustersPerMFTRecord < 0 ) {
132                 disk->MFTRecSize = 1 << (-bs.ClustersPerMFTRecord);
133         }
134         else {
135                 disk->MFTRecSize = bs.ClustersPerMFTRecord * disk->ClusterSize;
136         }
137         //NTFS_DumpEntry(disk, 0);      // $MFT
138         //NTFS_DumpEntry(disk, 3);      // $VOLUME
139
140         disk->InodeCache = Inode_GetHandle();
141         
142         disk->MFTDataAttr = NULL;
143         disk->MFTDataAttr = NTFS_GetAttrib(disk, 0, NTFS_FileAttrib_Data, "", 0);
144         //NTFS_DumpEntry(disk, 5);      // .
145
146         disk->RootDir.I30Root = NTFS_GetAttrib(disk, 5, NTFS_FileAttrib_IndexRoot, "$I30", 0);
147         disk->RootDir.I30Allocation = NTFS_GetAttrib(disk, 5, NTFS_FileAttrib_IndexAllocation, "$I30", 0);
148         disk->RootDir.Node.Inode = 5;   // MFT Ent #5 is filesystem root
149         disk->RootDir.Node.ImplPtr = disk;
150         disk->RootDir.Node.Type = &gNTFS_DirType;
151         disk->RootDir.Node.Flags = VFS_FFLAG_DIRECTORY;
152         
153         disk->RootDir.Node.UID = 0;
154         disk->RootDir.Node.GID = 0;
155         
156         disk->RootDir.Node.NumACLs = 1;
157         disk->RootDir.Node.ACLs = &gVFS_ACL_EveryoneRX;
158
159         #if 0
160         {
161                 // Read from allocation
162                 char buf[disk->ClusterSize];
163                 size_t len = NTFS_ReadAttribData(disk->RootDir.I30Allocation, 0, sizeof(buf), buf);
164                 Debug_HexDump("RootDir allocation", buf, len);
165         }
166         #endif
167
168         return &disk->RootDir.Node;
169 }
170
171 /**
172  * \brief Unmount an NTFS Disk
173  */
174 void NTFS_Unmount(tVFS_Node *Node)
175 {
176         tNTFS_Disk      *Disk = Node->ImplPtr;
177         VFS_Close(Disk->FD);
178         free(Disk);
179 }
180
181 void NTFS_Close(tVFS_Node *Node)
182 {
183         tNTFS_Disk      *Disk = Node->ImplPtr;
184         Inode_UncacheNode(Disk->InodeCache, Node->Inode);
185 }
186
187 void NTFS_FreeNode(tVFS_Node *Node)
188 {
189         if( Node->Type == &gNTFS_DirType ) {
190                 tNTFS_Directory *Dir = (void*)Node;
191                 NTFS_FreeAttrib(Dir->I30Root);
192                 NTFS_FreeAttrib(Dir->I30Allocation);
193         }
194         else {
195                 tNTFS_File      *File = (void*)Node;
196                 NTFS_FreeAttrib(File->Data);
197         }
198 }
199
200 int NTFS_int_ApplyUpdateSequence(void *Buffer, size_t BufLen, const Uint16 *Sequence, size_t NumEntries)
201 {
202         Uint16  cksum = Sequence[0];
203         LOG("cksum = %04x", cksum);
204         Sequence ++;
205         Uint16  *buf16 = Buffer;
206         for( int i = 0; i < NumEntries-1; i ++ )
207         {
208                 size_t  ofs = (i+1)*512 - 2;
209                 if( ofs + 2 > BufLen ) {
210                         // Oops?
211                         Log_Warning("NTFS", "%x > %x", ofs+2, BufLen);
212                 }
213                 Uint16  *cksum_word = &buf16[ofs/2];
214                 LOG("[%i]: %04x => %04x", i, Sequence[i], *cksum_word);
215                 if( *cksum_word != cksum ) {
216                         Log_Warning("NTFS", "Disk corruption detected");
217                         return 1;
218                 }
219                 *cksum_word = Sequence[i];
220         }
221         return 0;
222 }
223
224 tNTFS_FILE_Header *NTFS_GetMFT(tNTFS_Disk *Disk, Uint32 MFTEntry)
225 {
226         tNTFS_FILE_Header       *ret = malloc( Disk->MFTRecSize );
227         if(!ret) {
228                 Log_Warning("FS_NTFS", "malloc() fail!");
229                 return NULL;
230         }
231         
232         // NOTE: The MFT is a file, and can get fragmented
233         if( !Disk->MFTDataAttr ) {
234                 VFS_ReadAt( Disk->FD,
235                         Disk->MFTBase * Disk->ClusterSize + MFTEntry * Disk->MFTRecSize,
236                         Disk->MFTRecSize,
237                         ret);
238         }
239         else {
240                 NTFS_ReadAttribData(Disk->MFTDataAttr, MFTEntry * Disk->MFTRecSize, Disk->MFTRecSize, ret);
241         }
242
243         NTFS_int_ApplyUpdateSequence(ret, Disk->MFTRecSize,
244                 (void*)((char*)ret + ret->UpdateSequenceOfs), ret->UpdateSequenceSize
245                 );
246
247         return ret;
248 }
249
250 void NTFS_ReleaseMFT(tNTFS_Disk *Disk, Uint32 MFTEntry, tNTFS_FILE_Header *Entry)
251 {
252         free(Entry);
253 }
254
255 static inline Uint64 _getVariableLengthInt(const void *Ptr, int Length, int bExtend)
256 {
257         const Uint8     *data = Ptr;
258         Uint64  bits = 0;
259         for( int i = 0; i < Length; i ++ )
260                 bits |= (Uint64)data[i] << (i*8);
261         if( bExtend && Length && data[Length-1] & 0x80 ) {
262                 for( int i = Length; i < 8; i ++ )
263                         bits |= 0xFF << (i*8);
264         }
265         return bits;    // 
266 }
267
268 const void *_GetDataRun(const void *ptr, const void *limit, Uint64 LastLCN, Uint64 *Count, Uint64 *LCN)
269 {
270         // Clean exit?
271         if( ptr == limit ) {
272                 LOG("Clean end of list");
273                 return NULL;
274         }
275         
276         const Uint8     *data = ptr;
277         
278         // Offset size
279         Uint8   ofsSize = data[0] >> 4;
280         Uint8   lenSize = data[0] & 0xF;
281         LOG("ofsSize = %i, lenSize = %i", ofsSize, lenSize);
282         if( ofsSize > 8 )
283                 return NULL;
284         if( lenSize > 8 || lenSize < 1 )
285                 return NULL;
286         if( data + 1 + ofsSize + lenSize > (const Uint8*)limit )
287                 return NULL;
288         
289         if( Count ) {
290                 *Count = _getVariableLengthInt(data + 1, lenSize, 0);
291         }
292         if( LCN ) {
293                 *LCN = LastLCN + (Sint64)_getVariableLengthInt(data + 1 + lenSize, ofsSize, 1);
294         }
295         
296         return data + 1 + ofsSize + lenSize;
297 }
298
299 tNTFS_Attrib *NTFS_GetAttrib(tNTFS_Disk *Disk, Uint32 MFTEntry, int Type, const char *Name, int DesIdx)
300 {
301         ENTER("pDisk xMFTEntry xType sName iDesIdx",
302                 Disk, MFTEntry, Type, Name, DesIdx);
303          int    curIdx = 0;
304         // TODO: Scan cache of attributes
305         
306         // Load MFT entry
307         tNTFS_FILE_Header *hdr = NTFS_GetMFT(Disk, MFTEntry);
308         LOG("hdr = %p", hdr);
309
310         tNTFS_FILE_Attrib       *attr;
311         for( size_t ofs = hdr->FirstAttribOfs; ofs < hdr->RecordSize; ofs += attr->Size )
312         {
313                 attr = (void*)( (tVAddr)hdr + ofs );
314                 // Sanity #1: Type
315                 if( ofs + 4 > hdr->RecordSize )
316                         break ;
317                 // End-of-list?
318                 if( attr->Type == 0xFFFFFFFF )
319                         break;
320                 // Sanity #2: Type,Size
321                 if( ofs + 8 > hdr->RecordSize )
322                         break;
323                 // Sanity #3: Reported size
324                 if( attr->Size < sizeof(attr->Resident) )
325                         break;
326                 // Sanity #4: Reported size fits
327                 if( ofs + attr->Size > hdr->RecordSize )
328                         break;
329                 
330                 // - Chceck if this attribute is the one requested
331                 LOG("Type check %x == %x", attr->Type, Type);
332                 if( attr->Type != Type )
333                         continue;
334                 if( Name ) {
335                         LOG("Name check = '%s'", Name);
336                         const void      *name16 = (char*)attr + attr->NameOffset;
337                         if( UTF16_CompareWithUTF8(attr->NameLength, name16, Name) != 0 )
338                                 continue ;
339                 }
340                 LOG("Idx check %i", curIdx);
341                 if( curIdx++ != DesIdx )
342                         continue ;
343
344                 // - Construct (and cache) attribute description
345                 ASSERT(attr->NameOffset % 1 == 0);
346                 Uint16  *name16 = (Uint16*)attr + attr->NameOffset/2;
347                 size_t  namelen = UTF16_ConvertToUTF8(0, NULL, attr->NameLength, name16);
348                 size_t  edatalen = (attr->NonresidentFlag ? 0 : attr->Resident.AttribLen*4);
349                 tNTFS_Attrib *ret = malloc( sizeof(tNTFS_Attrib) + namelen + 1 + edatalen );
350                 if(!ret) {
351                         LEAVE('n');
352                         return NULL;
353                 }
354                 if( attr->NonresidentFlag )
355                         ret->Name = (void*)(ret + 1);
356                 else {
357                         ret->ResidentData = ret + 1;
358                         ret->Name = (char*)ret->ResidentData + edatalen;
359                 }
360                 
361                 ret->Disk = Disk;
362                 ret->Type = attr->Type;
363                 UTF16_ConvertToUTF8(namelen+1, ret->Name, attr->NameLength, name16);
364                 ret->IsResident = !(attr->NonresidentFlag);
365
366                 LOG("Creating with %x '%s'", ret->Type, ret->Name);
367
368                 if( attr->NonresidentFlag )
369                 {
370                         ret->DataSize = attr->NonResident.RealSize;
371                         ret->NonResident.CompressionUnitL2Size = attr->NonResident.CompressionUnitSize;
372                         ret->NonResident.FirstPopulatedCluster = attr->NonResident.StartingVCN;
373                         // Count data runs
374                         const char *limit = (char*)attr + attr->Size;
375                          int    nruns = 0;
376                         const char *datarun = (char*)attr + attr->NonResident.DataRunOfs;
377                         while( (datarun = _GetDataRun(datarun, limit, 0, NULL, NULL)) )
378                                 nruns ++;
379                         LOG("nruns = %i", nruns);
380                         // Allocate data runs
381                         ret->NonResident.nRuns = nruns;
382                         ret->NonResident.Runs = malloc( sizeof(tNTFS_AttribDataRun) * nruns );
383                          int    i = 0;
384                         datarun = (char*)attr + attr->NonResident.DataRunOfs;
385                         Uint64  lastLCN = 0;
386                         while( datarun && i < nruns )
387                         {
388                                 tNTFS_AttribDataRun     *run = &ret->NonResident.Runs[i];
389                                 datarun = _GetDataRun(datarun,limit, lastLCN, &run->Count, &run->LCN);
390                                 LOG("Run %i: %llx+%llx", i, run->LCN, run->Count);
391                                 lastLCN = run->LCN;
392                                 i ++;
393                         }
394                 }
395                 else
396                 {
397                         ret->DataSize = edatalen;
398                         memcpy(ret->ResidentData, (char*)attr + attr->Resident.AttribOfs, edatalen);
399                 }
400                 
401                 LEAVE('p', ret);
402                 return ret;
403         }
404
405         NTFS_ReleaseMFT(Disk, MFTEntry, hdr);
406         LEAVE('n');
407         return NULL;
408 }
409
410 void NTFS_FreeAttrib(tNTFS_Attrib *Attrib)
411 {
412         if( Attrib )
413                 free(Attrib);
414 }
415
416 size_t NTFS_ReadAttribData(tNTFS_Attrib *Attrib, Uint64 Offset, size_t Length, void *Buffer)
417 {
418         if( !Attrib )
419                 return 0;
420         if( Offset >= Attrib->DataSize )
421                 return 0;
422         if( Length > Attrib->DataSize )
423                 Length = Attrib->DataSize;
424         if( Offset + Length > Attrib->DataSize )
425                 Length = Attrib->DataSize - Offset;
426                 
427         if( Attrib->IsResident )
428         {
429                 memcpy(Buffer, Attrib->ResidentData, Length);
430                 return Length;
431         }
432         else
433         {
434                 size_t  ret = 0;
435                 tNTFS_Disk      *Disk = Attrib->Disk;
436                 Uint64  first_cluster = Offset / Disk->ClusterSize;
437                 size_t  cluster_ofs = Offset % Disk->ClusterSize;
438                 if( first_cluster < Attrib->NonResident.FirstPopulatedCluster ) {
439                         Log_Warning("NTFS", "TODO: Ofs < FirstVCN");
440                 }
441                 first_cluster -= Attrib->NonResident.FirstPopulatedCluster;
442                 if( Attrib->NonResident.CompressionUnitL2Size )
443                 {
444                         // TODO: Compression
445                         Log_Warning("NTFS", "Compression unsupported");
446                         // NOTE: Compressed blocks show up in pairs of runs
447                         // - The first contains the compressed data
448                         // - The second is a placeholder 'sparse' (LCN=0) to align to the compression unit
449                 }
450                 else
451                 {
452                         // Iterate through data runs until the desired run is located
453                         for( int i = 0; i < Attrib->NonResident.nRuns && Length; i ++ )
454                         {
455                                 tNTFS_AttribDataRun     *run = &Attrib->NonResident.Runs[i];
456                                 if( first_cluster > run->Count ) {
457                                         first_cluster -= run->Count;
458                                         continue ;
459                                 }
460                                 size_t  avail_bytes = (run->Count-first_cluster)*Disk->ClusterSize - cluster_ofs;
461                                 if( avail_bytes > Length )
462                                         avail_bytes = Length;
463                                 // Read from this extent
464                                 if( run->LCN == 0 ) {
465                                         memset(Buffer, 0, avail_bytes);
466                                 }
467                                 else {
468                                         VFS_ReadAt(Disk->FD,
469                                                 (run->LCN + first_cluster)*Disk->ClusterSize + cluster_ofs,
470                                                 avail_bytes,
471                                                 Buffer
472                                                 );
473                                 }
474                                 Length -= avail_bytes;
475                                 Buffer += avail_bytes;
476                                 ret += avail_bytes;
477                                 first_cluster = 0;
478                                 cluster_ofs = 0;
479                                 continue ;
480                         }
481                 }
482                 return ret;
483         }
484 }
485
486 /**
487  * \brief Dumps a MFT Entry
488  */
489 void NTFS_DumpEntry(tNTFS_Disk *Disk, Uint32 Entry)
490 {
491         tNTFS_FILE_Attrib       *attr;
492          int    i;
493         
494
495         tNTFS_FILE_Header       *hdr = NTFS_GetMFT(Disk, Entry);
496         if(!hdr) {
497                 Log_Warning("FS_NTFS", "malloc() fail!");
498                 return ;
499         }
500         
501         Log_Debug("FS_NTFS", "MFT Entry #%i", Entry);
502         Log_Debug("FS_NTFS", "- Magic = 0x%08x (%4C)", hdr->Magic, &hdr->Magic);
503         Log_Debug("FS_NTFS", "- UpdateSequenceOfs = 0x%x", hdr->UpdateSequenceOfs);
504         Log_Debug("FS_NTFS", "- UpdateSequenceSize = 0x%x", hdr->UpdateSequenceSize);
505         Log_Debug("FS_NTFS", "- LSN = 0x%x", hdr->LSN);
506         Log_Debug("FS_NTFS", "- SequenceNumber = %i", hdr->SequenceNumber);
507         Log_Debug("FS_NTFS", "- HardLinkCount = %i", hdr->HardLinkCount);
508         Log_Debug("FS_NTFS", "- FirstAttribOfs = 0x%x", hdr->FirstAttribOfs);
509         Log_Debug("FS_NTFS", "- Flags = 0x%x", hdr->Flags);
510         Log_Debug("FS_NTFS", "- RecordSize = 0x%x", hdr->RecordSize);
511         Log_Debug("FS_NTFS", "- RecordSpace = 0x%x", hdr->RecordSpace);
512         Log_Debug("FS_NTFS", "- Reference = 0x%llx", hdr->Reference);
513         Log_Debug("FS_NTFS", "- NextAttribID = 0x%04x", hdr->NextAttribID);
514         
515         attr = (void*)( (char*)hdr + hdr->FirstAttribOfs );
516         i = 0;
517         while( (tVAddr)attr < (tVAddr)hdr + hdr->RecordSize )
518         {
519                 if(attr->Type == 0xFFFFFFFF)    break;
520                 Log_Debug("FS_NTFS", "- Attribute %i", i ++);
521                 Log_Debug("FS_NTFS", " > Type = 0x%x", attr->Type);
522                 Log_Debug("FS_NTFS", " > Size = 0x%x", attr->Size);
523                 Log_Debug("FS_NTFS", " > ResidentFlag = 0x%x", attr->NonresidentFlag);
524                 Log_Debug("FS_NTFS", " > NameLength = %i", attr->NameLength);
525                 Log_Debug("FS_NTFS", " > NameOffset = 0x%x", attr->NameOffset);
526                 Log_Debug("FS_NTFS", " > Flags = 0x%x", attr->Flags);
527                 Log_Debug("FS_NTFS", " > AttributeID = 0x%x", attr->AttributeID);
528                 {
529                         Uint16  *name16 = (void*)((char*)attr + attr->NameOffset);
530                         size_t  len = UTF16_ConvertToUTF8(0, NULL, attr->NameLength, name16);
531                         char    name[len+1];
532                         UTF16_ConvertToUTF8(len+1, name, attr->NameLength, name16);
533                         Log_Debug("FS_NTFS", " > Name = '%s'", name);
534                 }
535                 if( !attr->NonresidentFlag ) {
536                         Log_Debug("FS_NTFS", " > AttribLen = 0x%x", attr->Resident.AttribLen);
537                         Log_Debug("FS_NTFS", " > AttribOfs = 0x%x", attr->Resident.AttribOfs);
538                         Log_Debug("FS_NTFS", " > IndexedFlag = 0x%x", attr->Resident.IndexedFlag);
539                         Debug_HexDump("FS_NTFS",
540                                 (void*)( (tVAddr)attr + attr->Resident.AttribOfs ),
541                                 attr->Resident.AttribLen
542                                 );
543                 }
544                 else {
545                         Log_Debug("FS_NTFS", " > StartingVCN = 0x%llx", attr->NonResident.StartingVCN);
546                         Log_Debug("FS_NTFS", " > LastVCN = 0x%llx", attr->NonResident.LastVCN);
547                         Log_Debug("FS_NTFS", " > DataRunOfs = 0x%x", attr->NonResident.DataRunOfs);
548                         Log_Debug("FS_NTFS", " > CompressionUnitSize = 0x%x", attr->NonResident.CompressionUnitSize);
549                         Log_Debug("FS_NTFS", " > AllocatedSize = 0x%llx", attr->NonResident.AllocatedSize);
550                         Log_Debug("FS_NTFS", " > RealSize = 0x%llx", attr->NonResident.RealSize);
551                         Log_Debug("FS_NTFS", " > InitiatedSize = 0x%llx", attr->NonResident.InitiatedSize);
552                         Debug_HexDump("FS_NTFS",
553                                 (char*)attr + attr->NonResident.DataRunOfs,
554                                 attr->Size - attr->NonResident.DataRunOfs
555                                 );
556                 }
557                 
558                 attr = (void*)( (tVAddr)attr + attr->Size );
559         }
560         
561         NTFS_ReleaseMFT(Disk, Entry, hdr);
562 }

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