[NTFS]
authorPierre Schweitzer <pierre@reactos.org>
Wed, 8 Oct 2014 19:32:21 +0000 (19:32 +0000)
committerPierre Schweitzer <pierre@reactos.org>
Wed, 8 Oct 2014 19:32:21 +0000 (19:32 +0000)
- Add a directory entry into FCB which will be a copy of the $FILE_NAME attribute of the FILE record. Though, it won't contain the name itself (in the FCB instead), so keep first char NULL and length 0.
- Implement its support (which requires opening the FILE record 5 first) for root FCB creation.

svn path=/trunk/; revision=64617

reactos/drivers/filesystems/ntfs/fcb.c
reactos/drivers/filesystems/ntfs/ntfs.h

index f023535..e9b0cc4 100644 (file)
@@ -275,19 +275,43 @@ PNTFS_FCB
 NtfsMakeRootFCB(PNTFS_VCB Vcb)
 {
     PNTFS_FCB Fcb;
+    PFILE_RECORD_HEADER MftRecord;
+    PFILENAME_ATTRIBUTE FileName;
 
-    Fcb = NtfsCreateFCB(L"\\", Vcb);
+    MftRecord = ExAllocatePoolWithTag(NonPagedPool,
+                                      Vcb->NtfsInfo.BytesPerFileRecord,
+                                      TAG_NTFS);
+    if (MftRecord == NULL)
+    {
+        return NULL;
+    }
+
+    if (!NT_SUCCESS(ReadFileRecord(Vcb, NTFS_FILE_ROOT, MftRecord)))
+    {
+        return NULL;
+    }
 
-//    memset(Fcb->entry.Filename, ' ', 11);
+    FileName = GetFileNameFromRecord(MftRecord);
+    if (!FileName)
+    {
+        return NULL;
+    }
+
+    Fcb = NtfsCreateFCB(L"\\", Vcb);
+    if (!Fcb)
+    {
+        return NULL;
+    }
 
-//    Fcb->Entry.DataLengthL = Vcb->CdInfo.RootSize;
-//    Fcb->Entry.ExtentLocationL = Vcb->CdInfo.RootStart;
-//    Fcb->Entry.FileFlags = 0x02; // FILE_ATTRIBUTE_DIRECTORY;
+    memcpy(&Fcb->Entry, FileName, FIELD_OFFSET(FILENAME_ATTRIBUTE, NameLength));
+    Fcb->Entry.NameType = FileName->NameType;
+    Fcb->Entry.NameLength = 0;
+    Fcb->Entry.Name[0] = UNICODE_NULL;
     Fcb->RefCount = 1;
     Fcb->DirIndex = 0;
-    Fcb->RFCB.FileSize.QuadPart = PAGE_SIZE;//Vcb->CdInfo.RootSize;
-    Fcb->RFCB.ValidDataLength.QuadPart = PAGE_SIZE;//Vcb->CdInfo.RootSize;
-    Fcb->RFCB.AllocationSize.QuadPart = PAGE_SIZE;//Vcb->CdInfo.RootSize;
+    Fcb->RFCB.FileSize.QuadPart = FileName->DataSize;
+    Fcb->RFCB.ValidDataLength.QuadPart = FileName->DataSize;
+    Fcb->RFCB.AllocationSize.QuadPart = FileName->AllocatedSize;
     Fcb->MFTIndex = NTFS_FILE_ROOT;
 
     NtfsFCBInitializeCache(Vcb, Fcb);
@@ -390,6 +414,8 @@ NtfsMakeFCBFromDirEntry(PNTFS_VCB Vcb,
         return STATUS_INSUFFICIENT_RESOURCES;
     }
 
+    memcpy(&rcFCB->Entry, FileName, FIELD_OFFSET(FILENAME_ATTRIBUTE, NameLength));
+    rcFCB->Entry.NameType = FileName->NameType;
     rcFCB->RFCB.FileSize.QuadPart = FileName->DataSize;
     rcFCB->RFCB.ValidDataLength.QuadPart = FileName->DataSize;
     rcFCB->RFCB.AllocationSize.QuadPart = FileName->AllocatedSize;
index fd174a3..bca024f 100644 (file)
@@ -108,43 +108,6 @@ typedef struct
 
 } DEVICE_EXTENSION, *PDEVICE_EXTENSION, NTFS_VCB, *PNTFS_VCB;
 
-
-#define FCB_CACHE_INITIALIZED   0x0001
-#define FCB_IS_VOLUME_STREAM    0x0002
-#define FCB_IS_VOLUME           0x0004
-#define MAX_PATH                260
-
-typedef struct _FCB
-{
-    NTFSIDENTIFIER Identifier;
-
-    FSRTL_COMMON_FCB_HEADER RFCB;
-    SECTION_OBJECT_POINTERS SectionObjectPointers;
-
-    PFILE_OBJECT FileObject;
-    PNTFS_VCB Vcb;
-
-    WCHAR *ObjectName;         /* point on filename (250 chars max) in PathName */
-    WCHAR PathName[MAX_PATH];  /* path+filename 260 max */
-
-    ERESOURCE PagingIoResource;
-    ERESOURCE MainResource;
-
-    LIST_ENTRY FcbListEntry;
-    struct _FCB* ParentFcb;
-
-    ULONG DirIndex;
-
-    LONG RefCount;
-    ULONG Flags;
-
-    ULONGLONG MFTIndex;
-
-//  DIR_RECORD Entry;
-
-} NTFS_FCB, *PNTFS_FCB;
-
-
 typedef struct
 {
     NTFSIDENTIFIER Identifier;
@@ -414,6 +377,41 @@ typedef struct _NTFS_ATTR_CONTEXT
     NTFS_ATTR_RECORD    Record;
 } NTFS_ATTR_CONTEXT, *PNTFS_ATTR_CONTEXT;
 
+#define FCB_CACHE_INITIALIZED   0x0001
+#define FCB_IS_VOLUME_STREAM    0x0002
+#define FCB_IS_VOLUME           0x0004
+#define MAX_PATH                260
+
+typedef struct _FCB
+{
+    NTFSIDENTIFIER Identifier;
+
+    FSRTL_COMMON_FCB_HEADER RFCB;
+    SECTION_OBJECT_POINTERS SectionObjectPointers;
+
+    PFILE_OBJECT FileObject;
+    PNTFS_VCB Vcb;
+
+    WCHAR *ObjectName;         /* point on filename (250 chars max) in PathName */
+    WCHAR PathName[MAX_PATH];  /* path+filename 260 max */
+
+    ERESOURCE PagingIoResource;
+    ERESOURCE MainResource;
+
+    LIST_ENTRY FcbListEntry;
+    struct _FCB* ParentFcb;
+
+    ULONG DirIndex;
+
+    LONG RefCount;
+    ULONG Flags;
+
+    ULONGLONG MFTIndex;
+
+    FILENAME_ATTRIBUTE Entry;
+
+} NTFS_FCB, *PNTFS_FCB;
+
 extern PNTFS_GLOBAL_DATA NtfsGlobalData;
 
 //int CdfsStrcmpi( wchar_t *str1, wchar_t *str2 );