Author: zguo
Date: Mon Oct 27 17:18:17 2014
New Revision: 65048

URL: http://svn.reactos.org/svn/reactos?rev=65048&view=rev
Log:
[NTFS]
Cherrypick additional NTFS related fixes, including ability to browse NTFS 
volume.

Modified:
    branches/0.3.17/reactos/   (props changed)
    branches/0.3.17/reactos/drivers/filesystems/ntfs/attrib.c
    branches/0.3.17/reactos/drivers/filesystems/ntfs/dirctl.c
    branches/0.3.17/reactos/drivers/filesystems/ntfs/fcb.c
    branches/0.3.17/reactos/drivers/filesystems/ntfs/mft.c
    branches/0.3.17/reactos/drivers/filesystems/ntfs/ntfs.h

Propchange: branches/0.3.17/reactos/
------------------------------------------------------------------------------
--- svn:mergeinfo       (original)
+++ svn:mergeinfo       Mon Oct 27 17:18:17 2014
@@ -18,4 +18,4 @@
 
/branches/usb-bringup:51335,51337,51341-51343,51348,51350,51353,51355,51365-51369,51372,51384-54388,54396-54398,54736-54737,54752-54754,54756-54760,54762,54764-54765,54767-54768,54772,54774-54777,54781,54787,54790-54792,54797-54798,54806,54808,54834-54838,54843,54850,54852,54856,54858-54859
 /branches/usb-bringup-trunk:55019-55543,55548-55554,55556-55567
 /branches/wlan-bringup:54809-54998
-/trunk/reactos:64752-64754,64765,64769,64771,64776,64793,64800,64825,64829,64832-64833,64855-64856,64859,64908-64909,64976
+/trunk/reactos:64752-64754,64765,64769,64771,64776,64793,64800,64825,64829,64832-64833,64855-64856,64859,64908-64909,64976,65025-65028,65041

Modified: branches/0.3.17/reactos/drivers/filesystems/ntfs/attrib.c
URL: 
http://svn.reactos.org/svn/reactos/branches/0.3.17/reactos/drivers/filesystems/ntfs/attrib.c?rev=65048&r1=65047&r2=65048&view=diff
==============================================================================
--- branches/0.3.17/reactos/drivers/filesystems/ntfs/attrib.c   [iso-8859-1] 
(original)
+++ branches/0.3.17/reactos/drivers/filesystems/ntfs/attrib.c   [iso-8859-1] 
Mon Oct 27 17:18:17 2014
@@ -287,16 +287,25 @@
 }
 
 PFILENAME_ATTRIBUTE
-GetFileNameFromRecord(PFILE_RECORD_HEADER FileRecord)
+GetFileNameFromRecord(PFILE_RECORD_HEADER FileRecord, UCHAR NameType)
 {
     PNTFS_ATTR_RECORD Attribute;
+    PFILENAME_ATTRIBUTE Name;
 
     Attribute = (PNTFS_ATTR_RECORD)((ULONG_PTR)FileRecord + 
FileRecord->AttributeOffset);
     while (Attribute < (PNTFS_ATTR_RECORD)((ULONG_PTR)FileRecord + 
FileRecord->BytesInUse) &&
            Attribute->Type != AttributeEnd)
     {
         if (Attribute->Type == AttributeFileName)
-            return (PFILENAME_ATTRIBUTE)((ULONG_PTR)Attribute + 
Attribute->Resident.ValueOffset);
+        {
+            Name = (PFILENAME_ATTRIBUTE)((ULONG_PTR)Attribute + 
Attribute->Resident.ValueOffset);
+            if (Name->NameType == NameType ||
+                (Name->NameType == NTFS_FILE_NAME_WIN32_AND_DOS && NameType == 
NTFS_FILE_NAME_WIN32) ||
+                (Name->NameType == NTFS_FILE_NAME_WIN32_AND_DOS && NameType == 
NTFS_FILE_NAME_DOS))
+            {
+                return Name;
+            }
+        }
 
         Attribute = (PNTFS_ATTR_RECORD)((ULONG_PTR)Attribute + 
Attribute->Length);
     }

Modified: branches/0.3.17/reactos/drivers/filesystems/ntfs/dirctl.c
URL: 
http://svn.reactos.org/svn/reactos/branches/0.3.17/reactos/drivers/filesystems/ntfs/dirctl.c?rev=65048&r1=65047&r2=65048&view=diff
==============================================================================
--- branches/0.3.17/reactos/drivers/filesystems/ntfs/dirctl.c   [iso-8859-1] 
(original)
+++ branches/0.3.17/reactos/drivers/filesystems/ntfs/dirctl.c   [iso-8859-1] 
Mon Oct 27 17:18:17 2014
@@ -135,7 +135,7 @@
 
     DPRINT("NtfsGetNameInformation() called\n");
 
-    FileName = GetFileNameFromRecord(FileRecord);
+    FileName = GetFileNameFromRecord(FileRecord, NTFS_FILE_NAME_WIN32);
     ASSERT(FileName != NULL);
 
     Length = FileName->NameLength * sizeof (WCHAR);
@@ -163,7 +163,7 @@
 
     DPRINT("NtfsGetDirectoryInformation() called\n");
 
-    FileName = GetFileNameFromRecord(FileRecord);
+    FileName = GetFileNameFromRecord(FileRecord, NTFS_FILE_NAME_WIN32);
     ASSERT(FileName != NULL);
 
     Length = FileName->NameLength * sizeof (WCHAR);
@@ -204,7 +204,7 @@
 
     DPRINT("NtfsGetFullDirectoryInformation() called\n");
 
-    FileName = GetFileNameFromRecord(FileRecord);
+    FileName = GetFileNameFromRecord(FileRecord, NTFS_FILE_NAME_WIN32);
     ASSERT(FileName != NULL);
 
     Length = FileName->NameLength * sizeof (WCHAR);
@@ -242,12 +242,13 @@
                                 ULONG BufferLength)
 {
     ULONG Length;
-    PFILENAME_ATTRIBUTE FileName;
+    PFILENAME_ATTRIBUTE FileName, ShortFileName;
 
     DPRINT("NtfsGetBothDirectoryInformation() called\n");
 
-    FileName = GetFileNameFromRecord(FileRecord);
+    FileName = GetFileNameFromRecord(FileRecord, NTFS_FILE_NAME_WIN32);
     ASSERT(FileName != NULL);
+    ShortFileName = GetFileNameFromRecord(FileRecord, NTFS_FILE_NAME_DOS);
 
     Length = FileName->NameLength * sizeof (WCHAR);
     if ((sizeof(FILE_BOTH_DIR_INFORMATION) + Length) > BufferLength)
@@ -258,6 +259,19 @@
         ROUND_UP(sizeof(FILE_BOTH_DIR_INFORMATION) + Length, sizeof(ULONG));
     RtlCopyMemory(Info->FileName, FileName->Name, Length);
 
+    if (ShortFileName)
+    {
+        /* Should we upcase the filename? */
+        ASSERT(ShortFileName->NameLength <= ARRAYSIZE(Info->ShortName));
+        Info->ShortNameLength = ShortFileName->NameLength * sizeof(WCHAR);
+        RtlCopyMemory(Info->ShortName, ShortFileName->Name, 
Info->ShortNameLength);
+    }
+    else
+    {
+        Info->ShortName[0] = 0;
+        Info->ShortNameLength = 0;
+    }
+
     Info->CreationTime.QuadPart = FileName->CreationTime;
     Info->LastAccessTime.QuadPart = FileName->LastAccessTime;
     Info->LastWriteTime.QuadPart = FileName->LastWriteTime;
@@ -271,9 +285,6 @@
 
 //  Info->FileIndex=;
     Info->EaSize = 0;
-
-    Info->ShortName[0] = 0;
-    Info->ShortNameLength = 0;
 
     return STATUS_SUCCESS;
 }

Modified: branches/0.3.17/reactos/drivers/filesystems/ntfs/fcb.c
URL: 
http://svn.reactos.org/svn/reactos/branches/0.3.17/reactos/drivers/filesystems/ntfs/fcb.c?rev=65048&r1=65047&r2=65048&view=diff
==============================================================================
--- branches/0.3.17/reactos/drivers/filesystems/ntfs/fcb.c      [iso-8859-1] 
(original)
+++ branches/0.3.17/reactos/drivers/filesystems/ntfs/fcb.c      [iso-8859-1] 
Mon Oct 27 17:18:17 2014
@@ -289,7 +289,7 @@
         return NULL;
     }
 
-    FileName = GetFileNameFromRecord(MftRecord);
+    FileName = GetFileNameFromRecord(MftRecord, NTFS_FILE_NAME_WIN32);
     if (!FileName)
     {
         ExFreePoolWithTag(MftRecord, TAG_NTFS);
@@ -391,7 +391,7 @@
 
     DPRINT1("NtfsMakeFCBFromDirEntry(%p, %p, %wZ, %p, %p)\n", Vcb, 
DirectoryFCB, Name, Record, fileFCB);
 
-    FileName = GetFileNameFromRecord(Record);
+    FileName = GetFileNameFromRecord(Record, NTFS_FILE_NAME_WIN32);
     if (!FileName)
     {
         return STATUS_OBJECT_NAME_NOT_FOUND; // Not sure that's the best here

Modified: branches/0.3.17/reactos/drivers/filesystems/ntfs/mft.c
URL: 
http://svn.reactos.org/svn/reactos/branches/0.3.17/reactos/drivers/filesystems/ntfs/mft.c?rev=65048&r1=65047&r2=65048&view=diff
==============================================================================
--- branches/0.3.17/reactos/drivers/filesystems/ntfs/mft.c      [iso-8859-1] 
(original)
+++ branches/0.3.17/reactos/drivers/filesystems/ntfs/mft.c      [iso-8859-1] 
Mon Oct 27 17:18:17 2014
@@ -85,7 +85,7 @@
                     PCWSTR Name,
                     ULONG NameLength)
 {
-    DPRINT1("FindAttributeHelper(%p, %p, %p, 0x%x, %S, %u)\n", Vcb, 
AttrRecord, AttrRecordEnd, Type, Name, NameLength);
+    DPRINT("FindAttributeHelper(%p, %p, %p, 0x%x, %S, %u)\n", Vcb, AttrRecord, 
AttrRecordEnd, Type, Name, NameLength);
 
     while (AttrRecord < AttrRecordEnd)
     {
@@ -146,7 +146,7 @@
                 PWCHAR AttrName;
 
                 AttrName = (PWCHAR)((PCHAR)AttrRecord + 
AttrRecord->NameOffset);
-                DPRINT("%s, %s\n", AttrName, Name);
+                DPRINT("%.*S, %.*S\n", AttrRecord->NameLength, AttrName, 
NameLength, Name);
                 if (RtlCompareMemory(AttrName, Name, NameLength << 1) == 
(NameLength << 1))
                 {
                     /* Found it, fill up the context and return. */
@@ -180,7 +180,7 @@
     PNTFS_ATTR_RECORD AttrRecord;
     PNTFS_ATTR_RECORD AttrRecordEnd;
 
-    DPRINT1("FindAttribute(%p, %p, %u, %S, %u, %p)\n", Vcb, MftRecord, Type, 
Name, NameLength, AttrCtx);
+    DPRINT("FindAttribute(%p, %p, 0x%x, %S, %u, %p)\n", Vcb, MftRecord, Type, 
Name, NameLength, AttrCtx);
 
     AttrRecord = (PNTFS_ATTR_RECORD)((PCHAR)MftRecord + 
MftRecord->AttributeOffset);
     AttrRecordEnd = (PNTFS_ATTR_RECORD)((PCHAR)MftRecord + 
Vcb->NtfsInfo.BytesPerFileRecord);
@@ -397,12 +397,12 @@
 {
     ULONGLONG BytesRead;
 
-    DPRINT1("ReadFileRecord(%p, %I64x, %p)\n", Vcb, index, file);
+    DPRINT("ReadFileRecord(%p, %I64x, %p)\n", Vcb, index, file);
 
     BytesRead = ReadAttribute(Vcb, Vcb->MFTContext, index * 
Vcb->NtfsInfo.BytesPerFileRecord, (PCHAR)file, 
Vcb->NtfsInfo.BytesPerFileRecord);
     if (BytesRead != Vcb->NtfsInfo.BytesPerFileRecord)
     {
-        DPRINT1("ReadFileRecord failed: %u read, %u expected\n", BytesRead, 
Vcb->NtfsInfo.BytesPerFileRecord);
+        DPRINT1("ReadFileRecord failed: %I64u read, %u expected\n", BytesRead, 
Vcb->NtfsInfo.BytesPerFileRecord);
         return STATUS_PARTIAL_COPY;
     }
 
@@ -469,7 +469,7 @@
 
     EntryName.Buffer = IndexEntry->FileName.Name;
     EntryName.Length = 
-    EntryName.MaximumLength = IndexEntry->FileName.NameLength;
+    EntryName.MaximumLength = IndexEntry->FileName.NameLength * sizeof(WCHAR);
 
     if (DirSearch)
     {
@@ -477,7 +477,7 @@
     }
     else
     {
-        return (RtlCompareUnicodeString(FileName, &EntryName, 
(IndexEntry->FileName.NameType != NTFS_FILE_NAME_POSIX)) == TRUE);
+        return (RtlCompareUnicodeString(FileName, &EntryName, 
(IndexEntry->FileName.NameType != NTFS_FILE_NAME_POSIX)) == 0);
     }
 }
 
@@ -507,7 +507,7 @@
     NTSTATUS Status;
     ULONG CurrentEntry = 0;
 
-    DPRINT1("NtfsFindMftRecord(%p, %I64d, %wZ, %p, %u, %p)\n", Vcb, MFTIndex, 
FileName, FirstEntry, DirSearch, OutMFTIndex);
+    DPRINT("NtfsFindMftRecord(%p, %I64d, %wZ, %p, %u, %p)\n", Vcb, MFTIndex, 
FileName, FirstEntry, DirSearch, OutMFTIndex);
 
     MftRecord = ExAllocatePoolWithTag(NonPagedPool,
                                       Vcb->NtfsInfo.BytesPerFileRecord,
@@ -631,9 +631,9 @@
                 IndexBuffer = (PINDEX_BUFFER)IndexRecord;
                 ASSERT(IndexBuffer->Ntfs.Type == 'XDNI');
                 ASSERT(IndexBuffer->Header.AllocatedSize + 0x18 == 
IndexBlockSize);
-                IndexEntry = (PINDEX_ENTRY_ATTRIBUTE)(&IndexBuffer->Header + 
IndexBuffer->Header.FirstEntryOffset);
-                IndexEntryEnd = (PINDEX_ENTRY_ATTRIBUTE)(&IndexBuffer->Header 
+ IndexBuffer->Header.TotalSizeOfEntries);
-                //ASSERT(IndexEntryEnd <= 
(PINDEX_ENTRY_ATTRIBUTE)((ULONG_PTR)IndexBuffer + IndexBlockSize)); FIXME: Why 
doesn't it work?
+                IndexEntry = 
(PINDEX_ENTRY_ATTRIBUTE)((ULONG_PTR)&IndexBuffer->Header + 
IndexBuffer->Header.FirstEntryOffset);
+                IndexEntryEnd = 
(PINDEX_ENTRY_ATTRIBUTE)((ULONG_PTR)&IndexBuffer->Header + 
IndexBuffer->Header.TotalSizeOfEntries);
+                ASSERT(IndexEntryEnd <= 
(PINDEX_ENTRY_ATTRIBUTE)((ULONG_PTR)IndexBuffer + IndexBlockSize));
 
                 while (IndexEntry < IndexEntryEnd &&
                        !(IndexEntry->Flags & NTFS_INDEX_ENTRY_END))
@@ -653,6 +653,7 @@
                     }
 
                     ++CurrentEntry;
+                    ASSERT(IndexEntry->Length >= 
sizeof(INDEX_ENTRY_ATTRIBUTE));
                     IndexEntry = (PINDEX_ENTRY_ATTRIBUTE)((PCHAR)IndexEntry + 
IndexEntry->Length);
                 }
 
@@ -686,13 +687,13 @@
     NTSTATUS Status;
     ULONG FirstEntry = 0;
 
-    DPRINT1("NtfsLookupFileAt(%p, %wZ, %p, %p, %I64x)\n", Vcb, PathName, 
FileRecord, DataContext, CurrentMFTIndex);
+    DPRINT("NtfsLookupFileAt(%p, %wZ, %p, %p, %I64x)\n", Vcb, PathName, 
FileRecord, DataContext, CurrentMFTIndex);
 
     FsRtlDissectName(*PathName, &Current, &Remaining);
 
     while (Current.Length != 0)
     {
-        DPRINT1("Current: %wZ\n", &Current);
+        DPRINT("Current: %wZ\n", &Current);
 
         Status = NtfsFindMftRecord(Vcb, CurrentMFTIndex, &Current, 
&FirstEntry, FALSE, &CurrentMFTIndex);
         if (!NT_SUCCESS(Status))
@@ -701,7 +702,7 @@
         }
 
         if (Remaining.Length == 0)
-            return STATUS_OBJECT_PATH_NOT_FOUND;
+            break;
 
         FsRtlDissectName(Current, &Current, &Remaining);
     }
@@ -762,11 +763,12 @@
 {
     NTSTATUS Status;
 
-    DPRINT1("NtfsFindFileAt(%p, %wZ, %p, %p, %p, %p, %I64x)\n", Vcb, 
SearchPattern, FirstEntry, FileRecord, DataContext, MFTIndex, CurrentMFTIndex);
+    DPRINT("NtfsFindFileAt(%p, %wZ, %p, %p, %p, %p, %I64x)\n", Vcb, 
SearchPattern, FirstEntry, FileRecord, DataContext, MFTIndex, CurrentMFTIndex);
 
     Status = NtfsFindMftRecord(Vcb, CurrentMFTIndex, SearchPattern, 
FirstEntry, TRUE, &CurrentMFTIndex);
     if (!NT_SUCCESS(Status))
     {
+        DPRINT("NtfsFindFileAt: NtfsFindMftRecord() failed with status 
0x%08lx\n", Status);
         return Status;
     }
 

Modified: branches/0.3.17/reactos/drivers/filesystems/ntfs/ntfs.h
URL: 
http://svn.reactos.org/svn/reactos/branches/0.3.17/reactos/drivers/filesystems/ntfs/ntfs.h?rev=65048&r1=65047&r2=65048&view=diff
==============================================================================
--- branches/0.3.17/reactos/drivers/filesystems/ntfs/ntfs.h     [iso-8859-1] 
(original)
+++ branches/0.3.17/reactos/drivers/filesystems/ntfs/ntfs.h     [iso-8859-1] 
Mon Oct 27 17:18:17 2014
@@ -448,7 +448,7 @@
 NtfsDumpFileAttributes(PFILE_RECORD_HEADER FileRecord);
 
 PFILENAME_ATTRIBUTE
-GetFileNameFromRecord(PFILE_RECORD_HEADER FileRecord);
+GetFileNameFromRecord(PFILE_RECORD_HEADER FileRecord, UCHAR NameType);
 
 /* blockdev.c */
 


Reply via email to