Author: zguo
Date: Thu Oct 23 15:45:12 2014
New Revision: 64927

URL: http://svn.reactos.org/svn/reactos?rev=64927&view=rev
Log:
[NTFS]
Cherrypick NTFS related changes from trunk for 0.3.17.

Modified:
    branches/0.3.17/   (props changed)
    branches/0.3.17/reactos/   (props changed)
    branches/0.3.17/reactos/drivers/filesystems/ntfs/dirctl.c
    branches/0.3.17/reactos/drivers/filesystems/ntfs/fsctl.c
    branches/0.3.17/reactos/drivers/filesystems/ntfs/mft.c
    branches/0.3.17/reactos/drivers/filesystems/ntfs/misc.c
    branches/0.3.17/reactos/drivers/filesystems/ntfs/ntfs.h
    branches/0.3.17/reactos/drivers/filesystems/ntfs/volinfo.c

Propchange: branches/0.3.17/
------------------------------------------------------------------------------
    svn:mergeinfo = /trunk:64769

Propchange: branches/0.3.17/reactos/
------------------------------------------------------------------------------
--- svn:mergeinfo       (original)
+++ svn:mergeinfo       Thu Oct 23 15:45:12 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:64769
+/trunk/reactos:64752-64754,64765,64769,64771,64776,64793,64800,64825,64829,64832-64833

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=64927&r1=64926&r2=64927&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] 
Thu Oct 23 15:45:12 2014
@@ -120,400 +120,206 @@
 
   return(STATUS_SUCCESS);
 }
+#endif
 
 
 static NTSTATUS
-CdfsFindFile(PDEVICE_EXTENSION DeviceExt,
-            PFCB Fcb,
-            PFCB Parent,
-            PWSTR FileToFind,
-            PULONG pDirIndex,
-            PULONG pDirIndex2)
-/*
- * FUNCTION: Find a file
- */
-{
-  WCHAR name[256];
-  WCHAR TempStr[2];
-  PVOID Block;
-  NTSTATUS Status;
-  ULONG len;
-  ULONG DirIndex;
-  ULONG Offset;
-  ULONG Read;
-  BOOLEAN IsRoot;
-  PVOID Context = NULL;
-  ULONG DirSize;
-  PUCHAR Ptr;
-  PDIR_RECORD Record;
-  LARGE_INTEGER StreamOffset;
-
-  DPRINT("FindFile(Parent %x, FileToFind '%S', DirIndex: %d)\n",
-        Parent, FileToFind, pDirIndex ? *pDirIndex : 0);
-  DPRINT("FindFile: old Pathname %x, old Objectname %x)\n",
-        Fcb->PathName, Fcb->ObjectName);
-
-  IsRoot = FALSE;
-  DirIndex = 0;
-  if (wcslen (FileToFind) == 0)
-    {
-      CHECKPOINT;
-      TempStr[0] = (WCHAR) '.';
-      TempStr[1] = 0;
-      FileToFind = (PWSTR)&TempStr;
-    }
-
-  if (Parent)
-    {
-      if (Parent->Entry.ExtentLocationL == DeviceExt->CdInfo.RootStart)
-       {
-         IsRoot = TRUE;
-       }
-    }
-  else
-    {
-      IsRoot = TRUE;
-    }
-
-  if (IsRoot == TRUE)
-    {
-      StreamOffset.QuadPart = (LONGLONG)DeviceExt->CdInfo.RootStart * 
(LONGLONG)BLOCKSIZE;
-      DirSize = DeviceExt->CdInfo.RootSize;
-
-
-      if (FileToFind[0] == 0 || (FileToFind[0] == '\\' && FileToFind[1] == 0)
-         || (FileToFind[0] == '.' && FileToFind[1] == 0))
-       {
-         /* it's root : complete essentials fields then return ok */
-         RtlZeroMemory(Fcb, sizeof(FCB));
-
-         Fcb->PathName[0]='\\';
-         Fcb->ObjectName = &Fcb->PathName[1];
-         Fcb->Entry.ExtentLocationL = DeviceExt->CdInfo.RootStart;
-         Fcb->Entry.DataLengthL = DeviceExt->CdInfo.RootSize;
-         Fcb->Entry.FileFlags = 0x02; //FILE_ATTRIBUTE_DIRECTORY;
-
-         if (pDirIndex)
-           *pDirIndex = 0;
-         if (pDirIndex2)
-           *pDirIndex2 = 0;
-         DPRINT("CdfsFindFile: new Pathname %S, new Objectname 
%S)\n",Fcb->PathName, Fcb->ObjectName);
-         return (STATUS_SUCCESS);
-       }
-    }
-  else
-    {
-      StreamOffset.QuadPart = (LONGLONG)Parent->Entry.ExtentLocationL * 
(LONGLONG)BLOCKSIZE;
-      DirSize = Parent->Entry.DataLengthL;
-    }
-
-  DPRINT("StreamOffset %I64u  DirSize %lu\n", StreamOffset.QuadPart, DirSize);
-
-  if (pDirIndex && (*pDirIndex))
-    DirIndex = *pDirIndex;
-
-  if(!CcMapData(DeviceExt->StreamFileObject, &StreamOffset,
-               BLOCKSIZE, TRUE, &Context, &Block))
-  {
-    DPRINT("CcMapData() failed\n");
-    return(STATUS_UNSUCCESSFUL);
-  }
-
-  Ptr = (PUCHAR)Block;
-  while(TRUE)
-    {
-      Record = (PDIR_RECORD)Ptr;
-      if (Record->RecordLength == 0)
-       {
-         DPRINT1("Stopped!\n");
-         break;
-       }
-
-      DPRINT("RecordLength %u  ExtAttrRecordLength %u  NameLength %u\n",
-            Record->RecordLength, Record->ExtAttrRecordLength, 
Record->FileIdLength);
-
-      Status = CdfsGetEntryName(DeviceExt, &Context, &Block, &StreamOffset,
-                               DirSize, (PVOID*)&Ptr, name, &DirIndex, 
pDirIndex2);
-      if (Status == STATUS_NO_MORE_ENTRIES)
-       {
-         break;
-       }
-      else if (Status == STATUS_UNSUCCESSFUL)
-       {
-         /* Note: the directory cache has already been unpinned */
-         return(Status);
-       }
-
-      DPRINT("Name '%S'\n", name);
-
-      if (wstrcmpjoki(name, FileToFind)) /* || wstrcmpjoki (name2, 
FileToFind)) */
-       {
-         if (Parent && Parent->PathName)
-           {
-             len = wcslen(Parent->PathName);
-             memcpy(Fcb->PathName, Parent->PathName, len*sizeof(WCHAR));
-             Fcb->ObjectName=&Fcb->PathName[len];
-             if (len != 1 || Fcb->PathName[0] != '\\')
-               {
-                 Fcb->ObjectName[0] = '\\';
-                 Fcb->ObjectName = &Fcb->ObjectName[1];
-               }
-           }
-         else
-           {
-             Fcb->ObjectName=Fcb->PathName;
-             Fcb->ObjectName[0]='\\';
-             Fcb->ObjectName=&Fcb->ObjectName[1];
-           }
-
-         DPRINT("PathName '%S'  ObjectName '%S'\n", Fcb->PathName, 
Fcb->ObjectName);
-
-         memcpy(&Fcb->Entry, Ptr, sizeof(DIR_RECORD));
-         wcsncpy(Fcb->ObjectName, name, MAX_PATH);
-         if (pDirIndex)
-           *pDirIndex = DirIndex;
-
-         DPRINT("FindFile: new Pathname %S, new Objectname %S, DirIndex %d\n",
-                Fcb->PathName, Fcb->ObjectName, DirIndex);
-
-         CcUnpinData(Context);
-
-         return(STATUS_SUCCESS);
-       }
-
-
-      Ptr = Ptr + Record->RecordLength;
-      DirIndex++;
-
-      if (((ULONG)Ptr - (ULONG)Block) >= DirSize)
-       {
-         DPRINT("Stopped!\n");
-         break;
-       }
-    }
-
-  CcUnpinData(Context);
-
-  if (pDirIndex)
-    *pDirIndex = DirIndex;
-
-  return(STATUS_UNSUCCESSFUL);
+NtfsGetNameInformation(PDEVICE_EXTENSION DeviceExt,
+                       PFILE_RECORD_HEADER FileRecord,
+                       PNTFS_ATTR_CONTEXT DataContext,
+                       PFILE_NAMES_INFORMATION Info,
+                       ULONG BufferLength)
+{
+    ULONG Length;
+    PFILENAME_ATTRIBUTE FileName;
+
+    DPRINT("NtfsGetNameInformation() called\n");
+
+    FileName = GetFileNameFromRecord(FileRecord);
+    ASSERT(FileName != NULL);
+
+    Length = FileName->NameLength * sizeof (WCHAR);
+    if ((sizeof(FILE_NAMES_INFORMATION) + Length) > BufferLength)
+        return(STATUS_BUFFER_OVERFLOW);
+
+    Info->FileNameLength = Length;
+    Info->NextEntryOffset =
+        ROUND_UP(sizeof(FILE_NAMES_INFORMATION) + Length, sizeof(ULONG));
+    RtlCopyMemory(Info->FileName, FileName->Name, Length);
+
+    return(STATUS_SUCCESS);
 }
 
 
 static NTSTATUS
-CdfsGetNameInformation(PFCB Fcb,
-                      PDEVICE_EXTENSION DeviceExt,
-                      PFILE_NAMES_INFORMATION Info,
-                      ULONG BufferLength)
-{
-  ULONG Length;
-
-  DPRINT("CdfsGetNameInformation() called\n");
-
-  Length = wcslen(Fcb->ObjectName) * sizeof(WCHAR);
-  if ((sizeof (FILE_BOTH_DIRECTORY_INFORMATION) + Length) > BufferLength)
-    return(STATUS_BUFFER_OVERFLOW);
-
-  Info->FileNameLength = Length;
-  Info->NextEntryOffset =
-    ROUND_UP(sizeof(FILE_BOTH_DIRECTORY_INFORMATION) + Length, 4);
-  memcpy(Info->FileName, Fcb->ObjectName, Length);
-
-  return(STATUS_SUCCESS);
+NtfsGetDirectoryInformation(PDEVICE_EXTENSION DeviceExt,
+                            PFILE_RECORD_HEADER FileRecord,
+                            PNTFS_ATTR_CONTEXT DataContext,
+                            PFILE_DIRECTORY_INFORMATION Info,
+                            ULONG BufferLength)
+{
+    ULONG Length;
+    PFILENAME_ATTRIBUTE FileName;
+
+    DPRINT("NtfsGetDirectoryInformation() called\n");
+
+    FileName = GetFileNameFromRecord(FileRecord);
+    ASSERT(FileName != NULL);
+
+    Length = FileName->NameLength * sizeof (WCHAR);
+    if ((sizeof(FILE_DIRECTORY_INFORMATION) + Length) > BufferLength)
+        return(STATUS_BUFFER_OVERFLOW);
+
+    Info->FileNameLength = Length;
+    Info->NextEntryOffset =
+        ROUND_UP(sizeof(FILE_DIRECTORY_INFORMATION) + Length, sizeof(ULONG));
+    RtlCopyMemory(Info->FileName, FileName->Name, Length);
+
+    Info->CreationTime.QuadPart = FileName->CreationTime;
+    Info->LastAccessTime.QuadPart = FileName->LastAccessTime;
+    Info->LastWriteTime.QuadPart = FileName->LastWriteTime;
+    Info->ChangeTime.QuadPart = FileName->ChangeTime;
+
+    /* Convert file flags */
+    NtfsFileFlagsToAttributes(FileName->FileAttributes, &Info->FileAttributes);
+
+    Info->EndOfFile.QuadPart = FileName->AllocatedSize;
+    Info->AllocationSize.QuadPart = ROUND_UP(FileName->AllocatedSize, 
DeviceExt->NtfsInfo.BytesPerCluster);
+
+//  Info->FileIndex=;
+
+    return STATUS_SUCCESS;
 }
 
 
 static NTSTATUS
-CdfsGetDirectoryInformation(PFCB Fcb,
-                           PDEVICE_EXTENSION DeviceExt,
-                           PFILE_DIRECTORY_INFORMATION Info,
-                           ULONG BufferLength)
-{
-  ULONG Length;
-
-  DPRINT("CdfsGetDirectoryInformation() called\n");
-
-  Length = wcslen(Fcb->ObjectName) * sizeof(WCHAR);
-  if ((sizeof (FILE_BOTH_DIRECTORY_INFORMATION) + Length) > BufferLength)
-    return(STATUS_BUFFER_OVERFLOW);
-
-  Info->FileNameLength = Length;
-  Info->NextEntryOffset =
-    ROUND_UP(sizeof(FILE_BOTH_DIRECTORY_INFORMATION) + Length, 4);
-  memcpy(Info->FileName, Fcb->ObjectName, Length);
-
-  /* Convert file times */
-  CdfsDateTimeToFileTime(Fcb,
-                        &Info->CreationTime);
-  CdfsDateTimeToFileTime(Fcb,
-                        &Info->LastAccessTime);
-  CdfsDateTimeToFileTime(Fcb,
-                        &Info->LastWriteTime);
-  CdfsDateTimeToFileTime(Fcb,
-                        &Info->ChangeTime);
-
-  /* Convert file flags */
-  CdfsFileFlagsToAttributes(Fcb,
-                           &Info->FileAttributes);
-
-  Info->EndOfFile.QuadPart = Fcb->Entry.DataLengthL;
-
-  /* Make AllocSize a rounded up multiple of the sector size */
-  Info->AllocationSize.QuadPart = ROUND_UP(Fcb->Entry.DataLengthL, BLOCKSIZE);
+NtfsGetFullDirectoryInformation(PDEVICE_EXTENSION DeviceExt,
+                                PFILE_RECORD_HEADER FileRecord,
+                                PNTFS_ATTR_CONTEXT DataContext,
+                                PFILE_FULL_DIRECTORY_INFORMATION Info,
+                                ULONG BufferLength)
+{
+    ULONG Length;
+    PFILENAME_ATTRIBUTE FileName;
+
+    DPRINT("NtfsGetFullDirectoryInformation() called\n");
+
+    FileName = GetFileNameFromRecord(FileRecord);
+    ASSERT(FileName != NULL);
+
+    Length = FileName->NameLength * sizeof (WCHAR);
+    if ((sizeof(FILE_FULL_DIRECTORY_INFORMATION) + Length) > BufferLength)
+        return(STATUS_BUFFER_OVERFLOW);
+
+    Info->FileNameLength = Length;
+    Info->NextEntryOffset =
+        ROUND_UP(sizeof(FILE_FULL_DIRECTORY_INFORMATION) + Length, 
sizeof(ULONG));
+    RtlCopyMemory(Info->FileName, FileName->Name, Length);
+
+    Info->CreationTime.QuadPart = FileName->CreationTime;
+    Info->LastAccessTime.QuadPart = FileName->LastAccessTime;
+    Info->LastWriteTime.QuadPart = FileName->LastWriteTime;
+    Info->ChangeTime.QuadPart = FileName->ChangeTime;
+
+    /* Convert file flags */
+    NtfsFileFlagsToAttributes(FileName->FileAttributes, &Info->FileAttributes);
+
+    Info->EndOfFile.QuadPart = FileName->AllocatedSize;
+    Info->AllocationSize.QuadPart = ROUND_UP(FileName->AllocatedSize, 
DeviceExt->NtfsInfo.BytesPerCluster);
 
 //  Info->FileIndex=;
-
-  return(STATUS_SUCCESS);
+    Info->EaSize = 0;
+
+    return STATUS_SUCCESS;
 }
 
 
 static NTSTATUS
-CdfsGetFullDirectoryInformation(PFCB Fcb,
-                               PDEVICE_EXTENSION DeviceExt,
-                               PFILE_FULL_DIRECTORY_INFORMATION Info,
-                               ULONG BufferLength)
-{
-  ULONG Length;
-
-  DPRINT("CdfsGetFullDirectoryInformation() called\n");
-
-  Length = wcslen(Fcb->ObjectName) * sizeof(WCHAR);
-  if ((sizeof (FILE_BOTH_DIRECTORY_INFORMATION) + Length) > BufferLength)
-    return(STATUS_BUFFER_OVERFLOW);
-
-  Info->FileNameLength = Length;
-  Info->NextEntryOffset =
-    ROUND_UP(sizeof(FILE_BOTH_DIRECTORY_INFORMATION) + Length, 4);
-  memcpy(Info->FileName, Fcb->ObjectName, Length);
-
-  /* Convert file times */
-  CdfsDateTimeToFileTime(Fcb,
-                        &Info->CreationTime);
-  CdfsDateTimeToFileTime(Fcb,
-                        &Info->LastAccessTime);
-  CdfsDateTimeToFileTime(Fcb,
-                        &Info->LastWriteTime);
-  CdfsDateTimeToFileTime(Fcb,
-                        &Info->ChangeTime);
-
-  /* Convert file flags */
-  CdfsFileFlagsToAttributes(Fcb,
-                           &Info->FileAttributes);
-
-  Info->EndOfFile.QuadPart = Fcb->Entry.DataLengthL;
-
-  /* Make AllocSize a rounded up multiple of the sector size */
-  Info->AllocationSize.QuadPart = ROUND_UP(Fcb->Entry.DataLengthL, BLOCKSIZE);
+NtfsGetBothDirectoryInformation(PDEVICE_EXTENSION DeviceExt,
+                                PFILE_RECORD_HEADER FileRecord,
+                                PNTFS_ATTR_CONTEXT DataContext,
+                                PFILE_BOTH_DIR_INFORMATION Info,
+                                ULONG BufferLength)
+{
+    ULONG Length;
+    PFILENAME_ATTRIBUTE FileName;
+
+    DPRINT("NtfsGetBothDirectoryInformation() called\n");
+
+    FileName = GetFileNameFromRecord(FileRecord);
+    ASSERT(FileName != NULL);
+
+    Length = FileName->NameLength * sizeof (WCHAR);
+    if ((sizeof(FILE_BOTH_DIR_INFORMATION) + Length) > BufferLength)
+        return(STATUS_BUFFER_OVERFLOW);
+
+    Info->FileNameLength = Length;
+    Info->NextEntryOffset =
+        ROUND_UP(sizeof(FILE_BOTH_DIR_INFORMATION) + Length, sizeof(ULONG));
+    RtlCopyMemory(Info->FileName, FileName->Name, Length);
+
+    Info->CreationTime.QuadPart = FileName->CreationTime;
+    Info->LastAccessTime.QuadPart = FileName->LastAccessTime;
+    Info->LastWriteTime.QuadPart = FileName->LastWriteTime;
+    Info->ChangeTime.QuadPart = FileName->ChangeTime;
+
+    /* Convert file flags */
+    NtfsFileFlagsToAttributes(FileName->FileAttributes, &Info->FileAttributes);
+
+    Info->EndOfFile.QuadPart = FileName->AllocatedSize;
+    Info->AllocationSize.QuadPart = ROUND_UP(FileName->AllocatedSize, 
DeviceExt->NtfsInfo.BytesPerCluster);
 
 //  Info->FileIndex=;
-  Info->EaSize = 0;
-
-  return(STATUS_SUCCESS);
-}
-
-
-static NTSTATUS
-CdfsGetBothDirectoryInformation(PFCB Fcb,
-                               PDEVICE_EXTENSION DeviceExt,
-                               PFILE_BOTH_DIRECTORY_INFORMATION Info,
-                               ULONG BufferLength)
-{
-  ULONG Length;
-
-  DPRINT("CdfsGetBothDirectoryInformation() called\n");
-
-  Length = wcslen(Fcb->ObjectName) * sizeof(WCHAR);
-  if ((sizeof (FILE_BOTH_DIRECTORY_INFORMATION) + Length) > BufferLength)
-    return(STATUS_BUFFER_OVERFLOW);
-
-  Info->FileNameLength = Length;
-  Info->NextEntryOffset =
-    ROUND_UP(sizeof(FILE_BOTH_DIRECTORY_INFORMATION) + Length, 4);
-  memcpy(Info->FileName, Fcb->ObjectName, Length);
-
-  /* Convert file times */
-  CdfsDateTimeToFileTime(Fcb,
-                        &Info->CreationTime);
-  CdfsDateTimeToFileTime(Fcb,
-                        &Info->LastAccessTime);
-  CdfsDateTimeToFileTime(Fcb,
-                        &Info->LastWriteTime);
-  CdfsDateTimeToFileTime(Fcb,
-                        &Info->ChangeTime);
-
-  /* Convert file flags */
-  CdfsFileFlagsToAttributes(Fcb,
-                           &Info->FileAttributes);
-
-  Info->EndOfFile.QuadPart = Fcb->Entry.DataLengthL;
-
-  /* Make AllocSize a rounded up multiple of the sector size */
-  Info->AllocationSize.QuadPart = ROUND_UP(Fcb->Entry.DataLengthL, BLOCKSIZE);
-
-//  Info->FileIndex=;
-  Info->EaSize = 0;
-
-  if (DeviceExt->CdInfo.JolietLevel == 0)
-    {
-      /* Standard ISO-9660 format */
-      Info->ShortNameLength = Length;
-      memcpy(Info->ShortName, Fcb->ObjectName, Length);
-    }
-  else
-    {
-      /* Joliet extension */
-
-      /* FIXME: Copy or create a short file name */
-
-      Info->ShortName[0] = 0;
-      Info->ShortNameLength = 0;
-    }
-
-  return(STATUS_SUCCESS);
-}
-#endif
+    Info->EaSize = 0;
+
+    Info->ShortName[0] = 0;
+    Info->ShortNameLength = 0;
+
+    return STATUS_SUCCESS;
+}
 
 
 NTSTATUS
 NtfsQueryDirectory(PNTFS_IRP_CONTEXT IrpContext)
 {
     PIRP Irp;
-    //PDEVICE_OBJECT DeviceObject;
-    //PDEVICE_EXTENSION DeviceExtension;
-    //LONG BufferLength = 0;
+    PDEVICE_OBJECT DeviceObject;
+    PDEVICE_EXTENSION DeviceExtension;
+    LONG BufferLength = 0;
     PUNICODE_STRING SearchPattern = NULL;
-    //FILE_INFORMATION_CLASS FileInformationClass;
+    FILE_INFORMATION_CLASS FileInformationClass;
     ULONG FileIndex = 0;
     PUCHAR Buffer = NULL;
     PFILE_NAMES_INFORMATION Buffer0 = NULL;
-    //PNTFS_FCB Fcb;
+    PNTFS_FCB Fcb;
     PNTFS_CCB Ccb;
-//    FCB TempFcb;
     BOOLEAN First = FALSE;
     PIO_STACK_LOCATION Stack;
     PFILE_OBJECT FileObject;
-    //NTSTATUS Status = STATUS_SUCCESS;
+    NTSTATUS Status = STATUS_SUCCESS;
+    PFILE_RECORD_HEADER FileRecord;
+    PNTFS_ATTR_CONTEXT DataContext;
+    ULONGLONG MFTRecord;
+    UNICODE_STRING Pattern;
 
     DPRINT1("NtfsQueryDirectory() called\n");
 
     ASSERT(IrpContext);
     Irp = IrpContext->Irp;
-//    DeviceObject = IrpContext->DeviceObject;
-
-//    DeviceExtension = DeviceObject->DeviceExtension;
+    DeviceObject = IrpContext->DeviceObject;
+
+    DeviceExtension = DeviceObject->DeviceExtension;
     Stack = IoGetCurrentIrpStackLocation(Irp);
     FileObject = Stack->FileObject;
 
     Ccb = (PNTFS_CCB)FileObject->FsContext2;
-//    Fcb = (PNTFS_FCB)FileObject->FsContext;
+    Fcb = (PNTFS_FCB)FileObject->FsContext;
 
     /* Obtain the callers parameters */
-    //BufferLength = Stack->Parameters.QueryDirectory.Length;
+    BufferLength = Stack->Parameters.QueryDirectory.Length;
     SearchPattern = Stack->Parameters.QueryDirectory.FileName;
-    //FileInformationClass = 
Stack->Parameters.QueryDirectory.FileInformationClass;
+    FileInformationClass = 
Stack->Parameters.QueryDirectory.FileInformationClass;
     FileIndex = Stack->Parameters.QueryDirectory.FileIndex;
-
 
     if (SearchPattern != NULL)
     {
@@ -546,7 +352,10 @@
         Ccb->DirectorySearchPattern[1] = 0;
     }
 
-    DPRINT("Search pattern '%S'\n", Ccb->DirectorySearchPattern);
+    RtlInitUnicodeString(&Pattern, Ccb->DirectorySearchPattern);
+
+    DPRINT1("Search pattern '%S'\n", Ccb->DirectorySearchPattern);
+    DPRINT1("In: '%S'\n", Fcb->PathName);
 
     /* Determine directory index */
     if (Stack->Flags & SL_INDEX_SPECIFIED)
@@ -570,93 +379,96 @@
 
     DPRINT("Buffer=%p tofind=%S\n", Buffer, Ccb->DirectorySearchPattern);
 
-#if 0
-  TempFcb.ObjectName = TempFcb.PathName;
-  while (Status == STATUS_SUCCESS && BufferLength > 0)
-    {
-      Status = CdfsFindFile(DeviceExtension,
-                           &TempFcb,
-                           Fcb,
-                           Ccb->DirectorySearchPattern,
-                           &Ccb->Entry,
-                           NULL);
-      DPRINT("Found %S, Status=%x, entry %x\n", TempFcb.ObjectName, Status, 
Ccb->Entry);
-
-      if (NT_SUCCESS(Status))
-       {
-         switch (FileInformationClass)
-           {
-             case FileNameInformation:
-               Status = CdfsGetNameInformation(&TempFcb,
-                                               DeviceExtension,
-                                               (PFILE_NAMES_INFORMATION)Buffer,
-                                               BufferLength);
-               break;
-
-             case FileDirectoryInformation:
-               Status = CdfsGetDirectoryInformation(&TempFcb,
-                                                    DeviceExtension,
-                                                    
(PFILE_DIRECTORY_INFORMATION)Buffer,
-                                                    BufferLength);
-               break;
-
-             case FileFullDirectoryInformation:
-               Status = CdfsGetFullDirectoryInformation(&TempFcb,
-                                                        DeviceExtension,
-                                                        
(PFILE_FULL_DIRECTORY_INFORMATION)Buffer,
-                                                        BufferLength);
-               break;
-
-             case FileBothDirectoryInformation:
-               Status = NtfsGetBothDirectoryInformation(&TempFcb,
-                                                        DeviceExtension,
-                                                        
(PFILE_BOTH_DIRECTORY_INFORMATION)Buffer,
-                                                        BufferLength);
-               break;
-
-             default:
-               Status = STATUS_INVALID_INFO_CLASS;
-           }
-
-         if (Status == STATUS_BUFFER_OVERFLOW)
-           {
-             if (Buffer0)
-               {
-                 Buffer0->NextEntryOffset = 0;
-               }
-             break;
-           }
-       }
-      else
-       {
-         if (Buffer0)
-           {
-             Buffer0->NextEntryOffset = 0;
-           }
-
-         if (First)
-           {
-             Status = STATUS_NO_SUCH_FILE;
-           }
-         else
-           {
-             Status = STATUS_NO_MORE_FILES;
-           }
-         break;
-       }
-
-      Buffer0 = (PFILE_NAMES_INFORMATION)Buffer;
-      Buffer0->FileIndex = FileIndex++;
-      Ccb->Entry++;
-
-      if (Stack->Flags & SL_RETURN_SINGLE_ENTRY)
-       {
-         break;
-       }
-      BufferLength -= Buffer0->NextEntryOffset;
-      Buffer += Buffer0->NextEntryOffset;
-    }
-#endif
+    while (Status == STATUS_SUCCESS && BufferLength > 0)
+    {
+        Status = NtfsFindFileAt(DeviceExtension,
+                                &Pattern,
+                                &Ccb->Entry,
+                                &FileRecord,
+                                &DataContext,
+                                &MFTRecord,
+                                Fcb->MFTIndex);
+      //DPRINT("Found %S, Status=%x, entry %x\n", TempFcb.ObjectName, Status, 
Ccb->Entry);
+
+        if (NT_SUCCESS(Status))
+        {
+            switch (FileInformationClass)
+            {
+                case FileNameInformation:
+                    Status = NtfsGetNameInformation(DeviceExtension,
+                                                    FileRecord,
+                                                    DataContext,
+                                                    
(PFILE_NAMES_INFORMATION)Buffer,
+                                                    BufferLength);
+                    break;
+
+                case FileDirectoryInformation:
+                    Status = NtfsGetDirectoryInformation(DeviceExtension,
+                                                         FileRecord,
+                                                         DataContext,
+                                                         
(PFILE_DIRECTORY_INFORMATION)Buffer,
+                                                         BufferLength);
+                    break;
+
+                case FileFullDirectoryInformation:
+                    Status = NtfsGetFullDirectoryInformation(DeviceExtension,
+                                                             FileRecord,
+                                                             DataContext,
+                                                             
(PFILE_FULL_DIRECTORY_INFORMATION)Buffer,
+                                                             BufferLength);
+                    break;
+
+                case FileBothDirectoryInformation:
+                    Status = NtfsGetBothDirectoryInformation(DeviceExtension,
+                                                             FileRecord,
+                                                             DataContext,
+                                                             
(PFILE_BOTH_DIR_INFORMATION)Buffer,
+                                                             BufferLength);
+                    break;
+
+                default:
+                    Status = STATUS_INVALID_INFO_CLASS;
+            }
+
+            if (Status == STATUS_BUFFER_OVERFLOW)
+            {
+                if (Buffer0)
+                {
+                    Buffer0->NextEntryOffset = 0;
+                }
+                break;
+            }
+        }
+        else
+        {
+            if (Buffer0)
+            {
+                Buffer0->NextEntryOffset = 0;
+            }
+
+            if (First)
+            {
+                Status = STATUS_NO_SUCH_FILE;
+            }
+            else
+            {
+                Status = STATUS_NO_MORE_FILES;
+            }
+            break;
+        }
+
+        Buffer0 = (PFILE_NAMES_INFORMATION)Buffer;
+        Buffer0->FileIndex = FileIndex++;
+        Ccb->Entry++;
+
+        if (Stack->Flags & SL_RETURN_SINGLE_ENTRY)
+        {
+            break;
+        }
+        BufferLength -= Buffer0->NextEntryOffset;
+        Buffer += Buffer0->NextEntryOffset;
+        ExFreePoolWithTag(FileRecord, TAG_NTFS);
+    }
 
     if (Buffer0)
     {
@@ -665,11 +477,10 @@
 
     if (FileIndex > 0)
     {
-        //Status = STATUS_SUCCESS;
-    }
-
-//    return Status;
-    return STATUS_NO_MORE_FILES;
+        Status = STATUS_SUCCESS;
+    }
+
+    return Status;
 }
 
 

Modified: branches/0.3.17/reactos/drivers/filesystems/ntfs/fsctl.c
URL: 
http://svn.reactos.org/svn/reactos/branches/0.3.17/reactos/drivers/filesystems/ntfs/fsctl.c?rev=64927&r1=64926&r2=64927&view=diff
==============================================================================
--- branches/0.3.17/reactos/drivers/filesystems/ntfs/fsctl.c    [iso-8859-1] 
(original)
+++ branches/0.3.17/reactos/drivers/filesystems/ntfs/fsctl.c    [iso-8859-1] 
Thu Oct 23 15:45:12 2014
@@ -34,8 +34,6 @@
 #define NDEBUG
 #include <debug.h>
 
-UNICODE_STRING EmptyName = RTL_CONSTANT_STRING(L"");
-
 /* FUNCTIONS ****************************************************************/
 
 /*
@@ -274,7 +272,7 @@
         return Status;
     }
 
-    Status = FindAttribute(DeviceExt, DeviceExt->MasterFileTable, 
AttributeData, &EmptyName, &DeviceExt->MFTContext);
+    Status = FindAttribute(DeviceExt, DeviceExt->MasterFileTable, 
AttributeData, L"", 0, &DeviceExt->MFTContext);
     if (!NT_SUCCESS(Status))
     {
         DPRINT1("Can't find data attribute for Master File Table.\n");
@@ -312,7 +310,7 @@
     NtfsDumpFileAttributes(VolumeRecord);
 
     /* Get volume name */
-    Status = FindAttribute(DeviceExt, VolumeRecord, AttributeVolumeName, 
&EmptyName, &AttrCtxt);
+    Status = FindAttribute(DeviceExt, VolumeRecord, AttributeVolumeName, L"", 
0, &AttrCtxt);
 
     if (NT_SUCCESS(Status) && AttrCtxt->Record.Resident.ValueLength != 0)
     {
@@ -348,7 +346,7 @@
     DeviceExt->VolumeFcb = VolumeFcb;
 
     /* Get volume information */
-    Status = FindAttribute(DeviceExt, VolumeRecord, 
AttributeVolumeInformation, &EmptyName, &AttrCtxt);
+    Status = FindAttribute(DeviceExt, VolumeRecord, 
AttributeVolumeInformation, L"", 0, &AttrCtxt);
 
     if (NT_SUCCESS(Status) && AttrCtxt->Record.Resident.ValueLength != 0)
     {

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=64927&r1=64926&r2=64927&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] 
Thu Oct 23 15:45:12 2014
@@ -31,8 +31,6 @@
 #define NDEBUG
 #include <debug.h>
 
-UNICODE_STRING IndexOfFileNames = RTL_CONSTANT_STRING(L"$I30");
-
 /* FUNCTIONS ****************************************************************/
 
 PNTFS_ATTR_CONTEXT
@@ -84,10 +82,10 @@
                     PNTFS_ATTR_RECORD AttrRecord,
                     PNTFS_ATTR_RECORD AttrRecordEnd,
                     ULONG Type,
-                    const WCHAR *Name,
+                    PCWSTR Name,
                     ULONG NameLength)
 {
-    DPRINT("FindAttributeHelper(%p, %p, %p, 0x%x, %s, %u)\n", Vcb, AttrRecord, 
AttrRecordEnd, Type, Name, NameLength);
+    DPRINT1("FindAttributeHelper(%p, %p, %p, 0x%x, %S, %u)\n", Vcb, 
AttrRecord, AttrRecordEnd, Type, Name, NameLength);
 
     while (AttrRecord < AttrRecordEnd)
     {
@@ -143,7 +141,6 @@
 
         if (AttrRecord->Type == Type)
         {
-            DPRINT("%d, %d\n", AttrRecord->NameLength, NameLength);
             if (AttrRecord->NameLength == NameLength)
             {
                 PWCHAR AttrName;
@@ -176,18 +173,19 @@
 FindAttribute(PDEVICE_EXTENSION Vcb,
               PFILE_RECORD_HEADER MftRecord,
               ULONG Type,
-              PUNICODE_STRING Name,
+              PCWSTR Name,
+              ULONG NameLength,
               PNTFS_ATTR_CONTEXT * AttrCtx)
 {
     PNTFS_ATTR_RECORD AttrRecord;
     PNTFS_ATTR_RECORD AttrRecordEnd;
 
-    DPRINT("NtfsFindAttribute(%p, %p, %u, %s)\n", Vcb, MftRecord, Type, Name);
+    DPRINT1("FindAttribute(%p, %p, %u, %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);
 
-    *AttrCtx = FindAttributeHelper(Vcb, AttrRecord, AttrRecordEnd, Type, 
Name->Buffer, Name->Length);
+    *AttrCtx = FindAttributeHelper(Vcb, AttrRecord, AttrRecordEnd, Type, Name, 
NameLength);
     if (*AttrCtx == NULL)
     {
         return STATUS_OBJECT_NAME_NOT_FOUND;
@@ -399,6 +397,8 @@
 {
     ULONGLONG BytesRead;
 
+    DPRINT1("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)
     {
@@ -488,8 +488,7 @@
                   PUNICODE_STRING FileName,
                   PULONG FirstEntry,
                   BOOLEAN DirSearch,
-                  ULONGLONG *OutMFTIndex,
-                  PWSTR OutName)
+                  ULONGLONG *OutMFTIndex)
 {
     PFILE_RECORD_HEADER MftRecord;
     //ULONG Magic;
@@ -497,6 +496,7 @@
     PNTFS_ATTR_CONTEXT IndexBitmapCtx;
     PNTFS_ATTR_CONTEXT IndexAllocationCtx;
     PINDEX_ROOT_ATTRIBUTE IndexRoot;
+    PINDEX_BUFFER IndexBuffer;
     ULONGLONG BitmapDataSize;
     ULONGLONG IndexAllocationSize;
     PCHAR BitmapData;
@@ -507,6 +507,8 @@
     NTSTATUS Status;
     ULONG CurrentEntry = 0;
 
+    DPRINT1("NtfsFindMftRecord(%p, %I64d, %wZ, %p, %u, %p)\n", Vcb, MFTIndex, 
FileName, FirstEntry, DirSearch, OutMFTIndex);
+
     MftRecord = ExAllocatePoolWithTag(NonPagedPool,
                                       Vcb->NtfsInfo.BytesPerFileRecord,
                                       TAG_NTFS);
@@ -519,7 +521,7 @@
     {
         //Magic = MftRecord->Magic;
 
-        Status = FindAttribute(Vcb, MftRecord, AttributeIndexRoot, 
&IndexOfFileNames, &IndexRootCtx);
+        Status = FindAttribute(Vcb, MftRecord, AttributeIndexRoot, L"$I30", 4, 
&IndexRootCtx);
         if (!NT_SUCCESS(Status))
         {
             ExFreePoolWithTag(MftRecord, TAG_NTFS);
@@ -545,12 +547,12 @@
         while (IndexEntry < IndexEntryEnd &&
                !(IndexEntry->Flags & NTFS_INDEX_ENTRY_END))
         {
-            if (CurrentEntry >= *FirstEntry && CompareFileName(FileName, 
IndexEntry, DirSearch))
-            {
-                *OutMFTIndex = IndexEntry->Data.Directory.IndexedFile;
+            if ((IndexEntry->Data.Directory.IndexedFile & NTFS_MFT_MASK) > 
0x10 &&
+                CurrentEntry >= *FirstEntry &&
+                CompareFileName(FileName, IndexEntry, DirSearch))
+            {
+                *OutMFTIndex = (IndexEntry->Data.Directory.IndexedFile & 
NTFS_MFT_MASK);
                 *FirstEntry = CurrentEntry;
-                RtlCopyMemory(OutName, IndexEntry->FileName.Name, 
IndexEntry->FileName.NameLength);
-                OutName[IndexEntry->FileName.NameLength / sizeof(WCHAR)] = 
UNICODE_NULL;
                 ExFreePoolWithTag(IndexRecord, TAG_NTFS);
                 ExFreePoolWithTag(MftRecord, TAG_NTFS);
                 return STATUS_SUCCESS;
@@ -566,10 +568,10 @@
 
             IndexBlockSize = IndexRoot->SizeOfEntry;
 
-            Status = FindAttribute(Vcb, MftRecord, AttributeBitmap, 
&IndexOfFileNames, &IndexBitmapCtx);
+            Status = FindAttribute(Vcb, MftRecord, AttributeBitmap, L"$I30", 
4, &IndexBitmapCtx);
             if (!NT_SUCCESS(Status))
             {
-                DPRINT("Corrupted filesystem!\n");
+                DPRINT1("Corrupted filesystem!\n");
                 ExFreePoolWithTag(MftRecord, TAG_NTFS);
                 return Status;
             }
@@ -589,7 +591,7 @@
             ReadAttribute(Vcb, IndexBitmapCtx, 0, BitmapData, 
(ULONG)BitmapDataSize);
             ReleaseAttributeContext(IndexBitmapCtx);
 
-            Status = FindAttribute(Vcb, MftRecord, AttributeIndexAllocation, 
&IndexOfFileNames, &IndexAllocationCtx);
+            Status = FindAttribute(Vcb, MftRecord, AttributeIndexAllocation, 
L"$I30", 4, &IndexAllocationCtx);
             if (!NT_SUCCESS(Status))
             {
                 DPRINT("Corrupted filesystem!\n");
@@ -621,25 +623,28 @@
 
                 ReadAttribute(Vcb, IndexAllocationCtx, RecordOffset, 
IndexRecord, IndexBlockSize);
 
-                if (!FixupUpdateSequenceArray(Vcb, 
&((PFILE_RECORD_HEADER)IndexRecord)->Ntfs))
+                if (!NT_SUCCESS(FixupUpdateSequenceArray(Vcb, 
&((PFILE_RECORD_HEADER)IndexRecord)->Ntfs)))
                 {
                     break;
                 }
 
-                /* FIXME */
-                IndexEntry = (PINDEX_ENTRY_ATTRIBUTE)(IndexRecord + 0x18 + 
*(USHORT *)(IndexRecord + 0x18));
-                IndexEntryEnd = (PINDEX_ENTRY_ATTRIBUTE)(IndexRecord + 
IndexBlockSize);
+                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?
 
                 while (IndexEntry < IndexEntryEnd &&
                        !(IndexEntry->Flags & NTFS_INDEX_ENTRY_END))
                 {
-                    if (CurrentEntry >= *FirstEntry && 
CompareFileName(FileName, IndexEntry, DirSearch))
+                    if ((IndexEntry->Data.Directory.IndexedFile & 
NTFS_MFT_MASK) > 0x10 &&
+                        CurrentEntry >= *FirstEntry &&
+                        CompareFileName(FileName, IndexEntry, DirSearch))
                     {
                         DPRINT("File found\n");
-                        *OutMFTIndex = IndexEntry->Data.Directory.IndexedFile;
+                        *OutMFTIndex = (IndexEntry->Data.Directory.IndexedFile 
& NTFS_MFT_MASK);
                         *FirstEntry = CurrentEntry;
-                        RtlCopyMemory(OutName, IndexEntry->FileName.Name, 
IndexEntry->FileName.NameLength);
-                        OutName[IndexEntry->FileName.NameLength / 
sizeof(WCHAR)] = UNICODE_NULL;
                         ExFreePoolWithTag(BitmapData, TAG_NTFS);
                         ExFreePoolWithTag(IndexRecord, TAG_NTFS);
                         ExFreePoolWithTag(MftRecord, TAG_NTFS);
@@ -677,9 +682,8 @@
                  PULONGLONG MFTIndex,
                  ULONGLONG CurrentMFTIndex)
 {
-    UNICODE_STRING Current, Remaining, Found;
+    UNICODE_STRING Current, Remaining;
     NTSTATUS Status;
-    WCHAR FoundName[MAX_PATH + 1];
     ULONG FirstEntry = 0;
 
     DPRINT1("NtfsLookupFileAt(%p, %wZ, %p, %p, %I64x)\n", Vcb, PathName, 
FileRecord, DataContext, CurrentMFTIndex);
@@ -688,15 +692,18 @@
 
     while (Current.Length != 0)
     {
-        DPRINT1("Lookup: %wZ\n", &Current);
-
-        Status = NtfsFindMftRecord(Vcb, CurrentMFTIndex, &Current, 
&FirstEntry, FALSE, &CurrentMFTIndex, FoundName);
+        DPRINT1("Current: %wZ\n", &Current);
+
+        Status = NtfsFindMftRecord(Vcb, CurrentMFTIndex, &Current, 
&FirstEntry, FALSE, &CurrentMFTIndex);
         if (!NT_SUCCESS(Status))
         {
             return Status;
         }
 
-        FsRtlDissectName(*PathName, &Current, &Remaining);
+        if (Remaining.Length == 0)
+            return STATUS_OBJECT_PATH_NOT_FOUND;
+
+        FsRtlDissectName(Current, &Current, &Remaining);
     }
 
     *FileRecord = ExAllocatePoolWithTag(NonPagedPool, 
Vcb->NtfsInfo.BytesPerFileRecord, TAG_NTFS);
@@ -710,18 +717,23 @@
     if (!NT_SUCCESS(Status))
     {
         DPRINT("NtfsLookupFileAt: Can't read MFT record\n");
-        ExFreePoolWithTag(FileRecord, TAG_NTFS);
+        ExFreePoolWithTag(*FileRecord, TAG_NTFS);
         return Status;
     }
 
-    RtlInitUnicodeString(&Found, FoundName);
-
-    Status = FindAttribute(Vcb, *FileRecord, AttributeData, &Found, 
DataContext);
-    if (!NT_SUCCESS(Status))
-    {
-        DPRINT("NtfsLookupFileAt: Can't find data attribute\n");
-        ExFreePoolWithTag(FileRecord, TAG_NTFS);
-        return Status;
+    if (!((*FileRecord)->Flags & FRH_DIRECTORY))
+    {
+        Status = FindAttribute(Vcb, *FileRecord, AttributeData, L"", 0, 
DataContext);
+        if (!NT_SUCCESS(Status))
+        {
+            DPRINT("NtfsLookupFileAt: Can't find data attribute\n");
+            ExFreePoolWithTag(*FileRecord, TAG_NTFS);
+            return Status;
+        }
+    }
+    else
+    {
+        *DataContext = NULL;
     }
 
     *MFTIndex = CurrentMFTIndex;
@@ -748,13 +760,11 @@
                PULONGLONG MFTIndex,
                ULONGLONG CurrentMFTIndex)
 {
-    UNICODE_STRING Found;
     NTSTATUS Status;
-    WCHAR FoundName[MAX_PATH + 1];
 
     DPRINT1("NtfsFindFileAt(%p, %wZ, %p, %p, %p, %p, %I64x)\n", Vcb, 
SearchPattern, FirstEntry, FileRecord, DataContext, MFTIndex, CurrentMFTIndex);
 
-    Status = NtfsFindMftRecord(Vcb, CurrentMFTIndex, SearchPattern, 
FirstEntry, TRUE, &CurrentMFTIndex, FoundName);
+    Status = NtfsFindMftRecord(Vcb, CurrentMFTIndex, SearchPattern, 
FirstEntry, TRUE, &CurrentMFTIndex);
     if (!NT_SUCCESS(Status))
     {
         return Status;
@@ -771,18 +781,23 @@
     if (!NT_SUCCESS(Status))
     {
         DPRINT("NtfsFindFileAt: Can't read MFT record\n");
-        ExFreePoolWithTag(FileRecord, TAG_NTFS);
+        ExFreePoolWithTag(*FileRecord, TAG_NTFS);
         return Status;
     }
 
-    RtlInitUnicodeString(&Found, FoundName);
-
-    Status = FindAttribute(Vcb, *FileRecord, AttributeData, &Found, 
DataContext);
-    if (!NT_SUCCESS(Status))
-    {
-        DPRINT("NtfsFindFileAt: Can't find data attribute\n");
-        ExFreePoolWithTag(FileRecord, TAG_NTFS);
-        return Status;
+    if (!((*FileRecord)->Flags & FRH_DIRECTORY))
+    {
+        Status = FindAttribute(Vcb, *FileRecord, AttributeData, L"", 0, 
DataContext);
+        if (!NT_SUCCESS(Status))
+        {
+            DPRINT("NtfsFindFileAt: Can't find data attribute\n");
+            ExFreePoolWithTag(*FileRecord, TAG_NTFS);
+            return Status;
+        }
+    }
+    else
+    {
+        *DataContext = NULL;
     }
 
     *MFTIndex = CurrentMFTIndex;

Modified: branches/0.3.17/reactos/drivers/filesystems/ntfs/misc.c
URL: 
http://svn.reactos.org/svn/reactos/branches/0.3.17/reactos/drivers/filesystems/ntfs/misc.c?rev=64927&r1=64926&r2=64927&view=diff
==============================================================================
--- branches/0.3.17/reactos/drivers/filesystems/ntfs/misc.c     [iso-8859-1] 
(original)
+++ branches/0.3.17/reactos/drivers/filesystems/ntfs/misc.c     [iso-8859-1] 
Thu Oct 23 15:45:12 2014
@@ -97,4 +97,19 @@
     return IrpContext;
 }
 
+VOID
+NtfsFileFlagsToAttributes(ULONG NtfsAttributes,
+                          PULONG FileAttributes)
+{
+    *FileAttributes = NtfsAttributes;
+    if ((NtfsAttributes & NTFS_FILE_TYPE_DIRECTORY) == 
NTFS_FILE_TYPE_DIRECTORY)
+    {
+        *FileAttributes = NtfsAttributes & ~NTFS_FILE_TYPE_DIRECTORY;
+        *FileAttributes |= FILE_ATTRIBUTE_DIRECTORY;
+    }
+
+    if (NtfsAttributes == 0)
+        *FileAttributes = FILE_ATTRIBUTE_NORMAL;
+}
+
 /* EOF */

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=64927&r1=64926&r2=64927&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] 
Thu Oct 23 15:45:12 2014
@@ -168,6 +168,8 @@
 #define NTFS_FILE_QUOTA                9
 #define NTFS_FILE_UPCASE            10
 #define NTFS_FILE_EXTEND            11
+
+#define NTFS_MFT_MASK 0x0000FFFFFFFFFFFFULL
 
 #define COLLATION_BINARY              0x00
 #define COLLATION_FILE_NAME           0x01
@@ -331,6 +333,13 @@
 
 typedef struct
 {
+    NTFS_RECORD_HEADER Ntfs;
+    ULONGLONG VCN;
+    INDEX_HEADER_ATTRIBUTE Header;
+} INDEX_BUFFER, *PINDEX_BUFFER;
+
+typedef struct
+{
     union
     {
         struct
@@ -613,7 +622,8 @@
 FindAttribute(PDEVICE_EXTENSION Vcb,
               PFILE_RECORD_HEADER MftRecord,
               ULONG Type,
-              PUNICODE_STRING Name,
+              PCWSTR Name,
+              ULONG NameLength,
               PNTFS_ATTR_CONTEXT * AttrCtx);
 
 VOID
@@ -680,15 +690,11 @@
 CdfsSwapString(PWCHAR Out,
               PUCHAR In,
               ULONG Count);
-
-VOID
-CdfsDateTimeToFileTime(PFCB Fcb,
-                      TIME *FileTime);
-
-VOID
-CdfsFileFlagsToAttributes(PFCB Fcb,
-                         PULONG FileAttributes);
 #endif
+
+VOID
+NtfsFileFlagsToAttributes(ULONG NtfsAttributes,
+                          PULONG FileAttributes);
 
 
 /* rw.c */

Modified: branches/0.3.17/reactos/drivers/filesystems/ntfs/volinfo.c
URL: 
http://svn.reactos.org/svn/reactos/branches/0.3.17/reactos/drivers/filesystems/ntfs/volinfo.c?rev=64927&r1=64926&r2=64927&view=diff
==============================================================================
--- branches/0.3.17/reactos/drivers/filesystems/ntfs/volinfo.c  [iso-8859-1] 
(original)
+++ branches/0.3.17/reactos/drivers/filesystems/ntfs/volinfo.c  [iso-8859-1] 
Thu Oct 23 15:45:12 2014
@@ -31,6 +31,14 @@
 #include <debug.h>
 
 /* FUNCTIONS ****************************************************************/
+
+static
+ULONGLONG
+NtfsGetFreeClusters(PDEVICE_EXTENSION DeviceExt)
+{
+    UNIMPLEMENTED;
+    return 0;
+}
 
 static
 NTSTATUS
@@ -130,8 +138,8 @@
 
     DeviceExt = DeviceObject->DeviceExtension;
 
-    FsSizeInfo->AvailableAllocationUnits.QuadPart = 0;
-    FsSizeInfo->TotalAllocationUnits.QuadPart = 
DeviceExt->NtfsInfo.SectorCount; /* ?? */
+    FsSizeInfo->AvailableAllocationUnits.QuadPart = 
NtfsGetFreeClusters(DeviceExt);
+    FsSizeInfo->TotalAllocationUnits.QuadPart = 
DeviceExt->NtfsInfo.SectorCount / DeviceExt->NtfsInfo.SectorsPerCluster;
     FsSizeInfo->SectorsPerAllocationUnit = 
DeviceExt->NtfsInfo.SectorsPerCluster;
     FsSizeInfo->BytesPerSector = DeviceExt->NtfsInfo.BytesPerSector;
 
@@ -145,7 +153,8 @@
 
 static
 NTSTATUS
-NtfsGetFsDeviceInformation(PFILE_FS_DEVICE_INFORMATION FsDeviceInfo,
+NtfsGetFsDeviceInformation(PDEVICE_OBJECT DeviceObject,
+                           PFILE_FS_DEVICE_INFORMATION FsDeviceInfo,
                            PULONG BufferLength)
 {
     DPRINT("NtfsGetFsDeviceInformation()\n");
@@ -157,7 +166,7 @@
         return STATUS_BUFFER_OVERFLOW;
 
     FsDeviceInfo->DeviceType = FILE_DEVICE_DISK;
-    FsDeviceInfo->Characteristics = 0; /* FIXME: fix this !! */
+    FsDeviceInfo->Characteristics = DeviceObject->Characteristics;
 
     DPRINT("NtfsGetFsDeviceInformation() finished.\n");
 
@@ -215,7 +224,8 @@
             break;
 
         case FileFsDeviceInformation:
-            Status = NtfsGetFsDeviceInformation(SystemBuffer,
+            Status = NtfsGetFsDeviceInformation(DeviceObject,
+                                                SystemBuffer,
                                                 &BufferLength);
             break;
 


Reply via email to