[ros-diffs] [fireball] 43356: [fastfat_new] - Manually fetch a short name entry in FatSetFcbNames and process it. - Get a long name and process it too (though right now there is problem, FullFAT returns a short name instead of a true long name). - Silence debug prints in FatiRead.

fireball at svn.reactos.org fireball at svn.reactos.org
Sat Oct 10 11:13:39 CEST 2009


Author: fireball
Date: Sat Oct 10 11:13:39 2009
New Revision: 43356

URL: http://svn.reactos.org/svn/reactos?rev=43356&view=rev
Log:
[fastfat_new]
- Manually fetch a short name entry in FatSetFcbNames and process it.
- Get a long name and process it too (though right now there is problem, FullFAT returns a short name instead of a true long name).
- Silence debug prints in FatiRead.

Modified:
    trunk/reactos/drivers/filesystems/fastfat_new/fastfat.h
    trunk/reactos/drivers/filesystems/fastfat_new/fcb.c
    trunk/reactos/drivers/filesystems/fastfat_new/rw.c

Modified: trunk/reactos/drivers/filesystems/fastfat_new/fastfat.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat_new/fastfat.h?rev=43356&r1=43355&r2=43356&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat_new/fastfat.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat_new/fastfat.h [iso-8859-1] Sat Oct 10 11:13:39 2009
@@ -306,7 +306,6 @@
 
 VOID NTAPI
 FatSetFcbNames(IN PFAT_IRP_CONTEXT IrpContext,
-               IN PUNICODE_STRING Lfn,
                IN PFCB Fcb);
 
 VOID NTAPI

Modified: trunk/reactos/drivers/filesystems/fastfat_new/fcb.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat_new/fcb.c?rev=43356&r1=43355&r2=43356&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat_new/fcb.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat_new/fcb.c [iso-8859-1] Sat Oct 10 11:13:39 2009
@@ -150,7 +150,7 @@
     Fcb->FatHandle = FileHandle;
 
     /* Set names */
-    FatSetFcbNames(IrpContext, NULL, Fcb);
+    FatSetFcbNames(IrpContext, Fcb);
 
     return Fcb;
 }
@@ -247,12 +247,17 @@
 VOID
 NTAPI
 FatSetFcbNames(IN PFAT_IRP_CONTEXT IrpContext,
-               IN PUNICODE_STRING Lfn,
                IN PFCB Fcb)
 {
     FF_DIRENT DirEnt;
     FF_ERROR Err;
     POEM_STRING ShortName;
+    CHAR ShortNameRaw[13];
+    UCHAR EntryBuffer[32];
+    UCHAR NumLFNs;
+    PUNICODE_STRING UnicodeName;
+    OEM_STRING LongNameOem;
+    NTSTATUS Status;
 
     /* Get the dir entry */
     Err = FF_GetEntry(Fcb->Vcb->Ioman,
@@ -266,18 +271,51 @@
         return;
     }
 
+    /* Read the dirent to fetch the raw short name */
+    FF_FetchEntry(Fcb->Vcb->Ioman,
+                  Fcb->FatHandle->DirCluster,
+                  Fcb->FatHandle->DirEntry,
+                  EntryBuffer);
+    NumLFNs = (UCHAR)(EntryBuffer[0] & ~0x40);
+    RtlCopyMemory(ShortNameRaw, EntryBuffer, 11);
+
     /* Initialize short name string */
     ShortName = &Fcb->ShortName.Name.Ansi;
     ShortName->Buffer = Fcb->ShortNameBuffer;
     ShortName->Length = 0;
     ShortName->MaximumLength = sizeof(Fcb->ShortNameBuffer);
 
-    /* Convert dirent to the proper string */
-    Fati8dot3ToString(DirEnt.FileName, FALSE, ShortName);
-
-    // Unicode name
-
-    // Add names to the splay tree
+    /* Convert raw short name to a proper string */
+    Fati8dot3ToString(ShortNameRaw, FALSE, ShortName);
+
+    /* Get the long file name (if any) */
+    if (NumLFNs > 0)
+    {
+        /* Prepare the oem string */
+        LongNameOem.Buffer = DirEnt.FileName;
+        LongNameOem.MaximumLength = FF_MAX_FILENAME;
+        LongNameOem.Length = strlen(DirEnt.FileName);
+
+        /* Prepare the unicode string */
+        UnicodeName = &Fcb->LongName.Name.String;
+        UnicodeName->Length = (LongNameOem.Length + 1) * sizeof(WCHAR);
+        UnicodeName->MaximumLength = UnicodeName->Length;
+        UnicodeName->Buffer = FsRtlAllocatePool(PagedPool, UnicodeName->Length);
+
+        /* Convert it to unicode */
+        Status = RtlOemStringToUnicodeString(UnicodeName, &LongNameOem, FALSE);
+        if (!NT_SUCCESS(Status))
+        {
+            ASSERT(FALSE);
+        }
+
+        RtlDowncaseUnicodeString(UnicodeName, UnicodeName, FALSE);
+        RtlUpcaseUnicodeString(UnicodeName, UnicodeName, FALSE);
+
+        DPRINT1("Converted long name: %wZ\n", UnicodeName);
+    }
+
+    // TODO: Add names to the splay tree
 }
 
 VOID
@@ -286,7 +324,7 @@
                   IN BOOLEAN DownCase,
                   OUT POEM_STRING OutString)
 {
-#if 0
+#if 1
     ULONG BaseLen, ExtLen;
     CHAR  *cString = OutString->Buffer;
     ULONG i;

Modified: trunk/reactos/drivers/filesystems/fastfat_new/rw.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat_new/rw.c?rev=43356&r1=43355&r2=43356&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat_new/rw.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat_new/rw.c [iso-8859-1] Sat Oct 10 11:13:39 2009
@@ -40,7 +40,7 @@
     
     OpenType = FatDecodeFileObject(FileObject, &Vcb, &Fcb, &Ccb);
 
-    DPRINT1("FatiRead() Fcb %p, Name %wZ, Offset %d, Length %d, Handle %p\n",
+    DPRINT("FatiRead() Fcb %p, Name %wZ, Offset %d, Length %d, Handle %p\n",
         Fcb, &FileObject->FileName, ByteOffset.LowPart, NumberOfBytes, Fcb->FatHandle);
 
     /* Perform actual read */
@@ -52,14 +52,14 @@
     else
     {
         Buffer = FatMapUserBuffer(IrpContext->Irp);
-        DPRINT1("Normal cached read, buffer %p\n");
+        DPRINT("Normal cached read, buffer %p\n");
 
         /* Set offset */
         FF_Seek(Fcb->FatHandle, ByteOffset.LowPart, FF_SEEK_SET);
 
         /* Read */
         BytesRead = FF_Read(Fcb->FatHandle, NumberOfBytes, 1, Buffer);
-        DPRINT1("Read %d bytes\n", BytesRead);
+        DPRINT("Read %d bytes\n", BytesRead);
 
         /* Indicate we read requested amount of bytes */
         IrpContext->Irp->IoStatus.Information = BytesRead;




More information about the Ros-diffs mailing list