From 2e0924d6afce72b54028628cfd6643127cbf20d6 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Sat, 10 Oct 2009 09:13:39 +0000 Subject: [PATCH] [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. svn path=/trunk/; revision=43356 --- .../drivers/filesystems/fastfat_new/fastfat.h | 1 - reactos/drivers/filesystems/fastfat_new/fcb.c | 52 ++++++++++++++++--- reactos/drivers/filesystems/fastfat_new/rw.c | 6 +-- 3 files changed, 48 insertions(+), 11 deletions(-) diff --git a/reactos/drivers/filesystems/fastfat_new/fastfat.h b/reactos/drivers/filesystems/fastfat_new/fastfat.h index d6be13f75ff..e138bd258bf 100644 --- a/reactos/drivers/filesystems/fastfat_new/fastfat.h +++ b/reactos/drivers/filesystems/fastfat_new/fastfat.h @@ -306,7 +306,6 @@ FatSetFullNameInFcb(PFCB Fcb, VOID NTAPI FatSetFcbNames(IN PFAT_IRP_CONTEXT IrpContext, - IN PUNICODE_STRING Lfn, IN PFCB Fcb); VOID NTAPI diff --git a/reactos/drivers/filesystems/fastfat_new/fcb.c b/reactos/drivers/filesystems/fastfat_new/fcb.c index 7d48720a26d..b18509e5b20 100644 --- a/reactos/drivers/filesystems/fastfat_new/fcb.c +++ b/reactos/drivers/filesystems/fastfat_new/fcb.c @@ -150,7 +150,7 @@ FatCreateFcb(IN PFAT_IRP_CONTEXT IrpContext, Fcb->FatHandle = FileHandle; /* Set names */ - FatSetFcbNames(IrpContext, NULL, Fcb); + FatSetFcbNames(IrpContext, Fcb); return Fcb; } @@ -247,12 +247,17 @@ FatSetFullNameInFcb(PFCB Fcb, 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 @@ FatSetFcbNames(IN PFAT_IRP_CONTEXT IrpContext, 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); + /* Convert raw short name to a proper string */ + Fati8dot3ToString(ShortNameRaw, FALSE, ShortName); - // Unicode name + /* 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); - // Add names to the splay tree + /* 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 @@ Fati8dot3ToString(IN PCHAR FileName, IN BOOLEAN DownCase, OUT POEM_STRING OutString) { -#if 0 +#if 1 ULONG BaseLen, ExtLen; CHAR *cString = OutString->Buffer; ULONG i; diff --git a/reactos/drivers/filesystems/fastfat_new/rw.c b/reactos/drivers/filesystems/fastfat_new/rw.c index 9fa1758966e..a6a2120148f 100644 --- a/reactos/drivers/filesystems/fastfat_new/rw.c +++ b/reactos/drivers/filesystems/fastfat_new/rw.c @@ -40,7 +40,7 @@ FatiRead(PFAT_IRP_CONTEXT IrpContext) 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 @@ FatiRead(PFAT_IRP_CONTEXT IrpContext) 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;