[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
This commit is contained in:
Aleksey Bragin 2009-10-10 09:13:39 +00:00
parent 25b4b890e3
commit 2e0924d6af
3 changed files with 48 additions and 11 deletions

View file

@ -306,7 +306,6 @@ FatSetFullNameInFcb(PFCB Fcb,
VOID NTAPI
FatSetFcbNames(IN PFAT_IRP_CONTEXT IrpContext,
IN PUNICODE_STRING Lfn,
IN PFCB Fcb);
VOID NTAPI

View file

@ -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;

View file

@ -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;