X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FModules%2FFilesystems%2FNTFS%2Fmain.c;h=5e1c2aeb3f0cba6dacdda8c66915b69cf37b6084;hb=c70e02ed8cc8771daedb78507b33ab0cecebee43;hp=dd1bf846e762a360549eeb546158a5cc39b41a71;hpb=3baaddee040c6e58d3fdb10c3d04b69354e221e7;p=tpg%2Facess2.git diff --git a/KernelLand/Modules/Filesystems/NTFS/main.c b/KernelLand/Modules/Filesystems/NTFS/main.c index dd1bf846..5e1c2aeb 100644 --- a/KernelLand/Modules/Filesystems/NTFS/main.c +++ b/KernelLand/Modules/Filesystems/NTFS/main.c @@ -7,7 +7,7 @@ * * Reference: ntfsdoc.pdf */ -#define DEBUG 1 +#define DEBUG 0 #define VERBOSE 0 #include #include @@ -42,6 +42,10 @@ tVFS_NodeType gNTFS_DirType = { .FindDir = NTFS_FindDir, .Close = NULL }; +tVFS_NodeType gNTFS_FileType = { + .TypeName = "NTFS-File", + .Close = NULL + }; tNTFS_Disk gNTFS_Disks; @@ -92,9 +96,9 @@ tVFS_Node *NTFS_InitDevice(const char *Device, const char **Options) return NULL; } - Log_Debug("FS_NTFS", "&bs = %p", &bs); VFS_ReadAt(disk->FD, 0, 512, &bs); - + +#if 0 Log_Debug("FS_NTFS", "Jump = %02x%02x%02x", bs.Jump[0], bs.Jump[1], @@ -115,10 +119,11 @@ tVFS_Node *NTFS_InitDevice(const char *Device, const char **Options) Log_Debug("FS_NTFS", "ClustersPerMFTRecord = %i", bs.ClustersPerMFTRecord); Log_Debug("FS_NTFS", "ClustersPerIndexRecord = %i", bs.ClustersPerIndexRecord); Log_Debug("FS_NTFS", "SerialNumber = 0x%llx", bs.SerialNumber); +#endif disk->ClusterSize = bs.BytesPerSector * bs.SectorsPerCluster; - Log_Debug("NTFS", "Cluster Size = %i KiB", disk->ClusterSize/1024); disk->MFTBase = bs.MFTStart; + Log_Debug("NTFS", "Cluster Size = %i KiB", disk->ClusterSize/1024); Log_Debug("NTFS", "MFT Base = %i", disk->MFTBase); Log_Debug("NTFS", "TotalSectorCount = 0x%x", bs.TotalSectorCount); @@ -128,12 +133,14 @@ tVFS_Node *NTFS_InitDevice(const char *Device, const char **Options) else { disk->MFTRecSize = bs.ClustersPerMFTRecord * disk->ClusterSize; } - NTFS_DumpEntry(disk, 0); // $MFT + //NTFS_DumpEntry(disk, 0); // $MFT //NTFS_DumpEntry(disk, 3); // $VOLUME + + disk->InodeCache = Inode_GetHandle(); disk->MFTDataAttr = NULL; disk->MFTDataAttr = NTFS_GetAttrib(disk, 0, NTFS_FileAttrib_Data, "", 0); - NTFS_DumpEntry(disk, 5); // . + //NTFS_DumpEntry(disk, 5); // . disk->RootDir.I30Root = NTFS_GetAttrib(disk, 5, NTFS_FileAttrib_IndexRoot, "$I30", 0); disk->RootDir.I30Allocation = NTFS_GetAttrib(disk, 5, NTFS_FileAttrib_IndexAllocation, "$I30", 0); @@ -148,12 +155,14 @@ tVFS_Node *NTFS_InitDevice(const char *Device, const char **Options) disk->RootDir.Node.NumACLs = 1; disk->RootDir.Node.ACLs = &gVFS_ACL_EveryoneRX; + #if 0 { // Read from allocation char buf[disk->ClusterSize]; size_t len = NTFS_ReadAttribData(disk->RootDir.I30Allocation, 0, sizeof(buf), buf); Debug_HexDump("RootDir allocation", buf, len); } + #endif return &disk->RootDir.Node; } @@ -337,6 +346,7 @@ tNTFS_Attrib *NTFS_GetAttrib(tNTFS_Disk *Disk, Uint32 MFTEntry, int Type, const } else { + ret->DataSize = edatalen; memcpy(ret->ResidentData, (char*)attr + attr->Resident.AttribOfs, edatalen); } @@ -351,6 +361,8 @@ tNTFS_Attrib *NTFS_GetAttrib(tNTFS_Disk *Disk, Uint32 MFTEntry, int Type, const size_t NTFS_ReadAttribData(tNTFS_Attrib *Attrib, Uint64 Offset, size_t Length, void *Buffer) { + if( !Attrib ) + return 0; if( Offset >= Attrib->DataSize ) return 0; if( Length > Attrib->DataSize )