From 5b9f97fc9b10ded09a844935f7cd0d33e5d2e4d6 Mon Sep 17 00:00:00 2001 From: John Hodge Date: Fri, 27 Aug 2010 19:00:50 +0800 Subject: [PATCH] NTFS Driver work (index headers) --- Modules/Filesystems/NTFS/attributes.h | 38 ++++++++++++++++ Modules/Filesystems/NTFS/common.h | 2 + Modules/Filesystems/NTFS/dir.c | 1 + Modules/Filesystems/NTFS/index.h | 65 +++++++++++++++++++++++++++ 4 files changed, 106 insertions(+) create mode 100644 Modules/Filesystems/NTFS/attributes.h create mode 100644 Modules/Filesystems/NTFS/index.h diff --git a/Modules/Filesystems/NTFS/attributes.h b/Modules/Filesystems/NTFS/attributes.h new file mode 100644 index 00000000..671a36e7 --- /dev/null +++ b/Modules/Filesystems/NTFS/attributes.h @@ -0,0 +1,38 @@ +/* + * Acess2 - NTFS Driver + * By John Hodge (thePowersGang) + * This file is published under the terms of the Acess licence. See the + * file COPYING for details. + * + * attributes.h - MFT Attribute Types + */ +#ifndef _ATTRIBUTES_H_ +#define _ATTRIBUTES_H_ + +typedef struct +{ + Uint64 ParentDirectory; //!< Parent directory MFT entry + Sint64 CreationTime; //!< Time the file was created + Sint64 LastDataModTime; //!< Last change time for the data + Sint64 LastMtfModTime; //!< Last change time for the MFT entry + Sint64 LastAccessTime; //!< Last Access Time (unreliable on most systems) + + Uint64 AllocatedSize; //!< Allocated data size for $DATA unnamed stream + Uint64 DataSize; //!< Actual size of $DATA unnamed stream + Uint32 Flags; //!< File attribute files + + union { + struct { + Uint16 PackedSize; //!< Size of buffer needed for extended attributes + Uint16 _reserved; + } PACKED ExtAttrib; + struct { + Uint32 Tag; //!< Type of reparse point + } PACKED ReparsePoint; + } PACKED Type; + + Uint8 FilenameType; //!< Filename namespace (DOS, Windows, Unix) + WCHAR Filename[0]; +} PACKED tNTFS_Attrib_Filename; + +#endif diff --git a/Modules/Filesystems/NTFS/common.h b/Modules/Filesystems/NTFS/common.h index 6ed0ac6c..598120d2 100644 --- a/Modules/Filesystems/NTFS/common.h +++ b/Modules/Filesystems/NTFS/common.h @@ -12,6 +12,8 @@ #include #include +typedef Uint16 WCHAR; + // === STRUCTURES === /** * In-memory representation of an NTFS Disk diff --git a/Modules/Filesystems/NTFS/dir.c b/Modules/Filesystems/NTFS/dir.c index c3a90682..37661e82 100644 --- a/Modules/Filesystems/NTFS/dir.c +++ b/Modules/Filesystems/NTFS/dir.c @@ -7,6 +7,7 @@ * dir.c - Directory Handling */ #include "common.h" +#include "index.h" // === PROTOTYPES === char *NTFS_ReadDir(tVFS_Node *Node, int Pos); diff --git a/Modules/Filesystems/NTFS/index.h b/Modules/Filesystems/NTFS/index.h new file mode 100644 index 00000000..f45d8975 --- /dev/null +++ b/Modules/Filesystems/NTFS/index.h @@ -0,0 +1,65 @@ +/* + * Acess2 - NTFS Driver + * By John Hodge (thePowersGang) + * This file is published under the terms of the Acess licence. See the + * file COPYING for details. + * + * index.h - Index Types + */ +#ifndef _INDEX_H_ +#define _INDEX_H_ + +#include "attributes.h" + +typedef struct +{ + Uint32 EntryOffset; + Uint32 IndexLength; + Uint32 AllocateSize; + Uint8 Flags; + Uint8 _reserved[3]; +} PACKED tNTFS_IndexHeader; + +typedef struct +{ + Uint32 Type; + Uint32 CollationRule; + Uint32 IndexBlockSize; + Uint8 ClustersPerIndexBlock; + Uint8 _reserved[3]; + tNTFS_IndexHeader Header; +} PACKED tNTFS_IndexRoot; + +typedef struct +{ + union { + struct { + Uint64 File; // MFT Index of file + } PACKED Dir; + /** + * Views/Indexes + */ + struct { + Uint16 DataOffset; + Uint16 DataLength; + Uint32 _reserved; + } PACKED ViewIndex; + } PACKED Header; + + Uint16 Length; //!< Size of the index entry (multiple of 8 bytes) + Uint16 KeyLength; //!< Size of key value + Uint16 Flags; //!< Flags Bitfield + Uint16 _reserved; + + /** + * \brief Key Data + * \note Only valid if \a Flags does not have \a INDEX_ENTRY_END set + * \note In NTFS3 only \a Filename is used + */ + union { + tNTFS_Attrib_Filename Filename; + //TODO: more key types + } PACKED Key; +} PACKED tNTFS_IndexEntry; + +#endif -- 2.20.1