Author: fireball Date: Fri Oct 9 16:20:33 2009 New Revision: 43343
URL: http://svn.reactos.org/svn/reactos?rev=43343&view=rev Log: [fastfat_new] - Add two names to an FCB - a short name, and a long name. - Start implementing FatSetFcbNames, currently deals with short names only. - Implement Fati8dot3ToString, with most of the code actually #if0ed, because FullFAT already does this conversion.
Modified: trunk/reactos/drivers/filesystems/fastfat_new/dir.c trunk/reactos/drivers/filesystems/fastfat_new/fastfat.h trunk/reactos/drivers/filesystems/fastfat_new/fatstruc.h trunk/reactos/drivers/filesystems/fastfat_new/fcb.c
Modified: trunk/reactos/drivers/filesystems/fastfat_new/dir.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat... ============================================================================== --- trunk/reactos/drivers/filesystems/fastfat_new/dir.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filesystems/fastfat_new/dir.c [iso-8859-1] Fri Oct 9 16:20:33 2009 @@ -71,9 +71,9 @@ Dcb->FullFileName.Length = 1 * sizeof(WCHAR); Dcb->FullFileName.MaximumLength = 2 * sizeof(WCHAR);
- Dcb->FileName.Name.Ansi.Buffer = "\"; - Dcb->FileName.Name.Ansi.Length = 1; - Dcb->FileName.Name.Ansi.MaximumLength = 2 * sizeof(CHAR); + Dcb->ShortName.Name.Ansi.Buffer = "\"; + Dcb->ShortName.Name.Ansi.Length = 1; + Dcb->ShortName.Name.Ansi.MaximumLength = 2 * sizeof(CHAR);
/* Fill dirent attribute byte copy */ Dcb->DirentFatFlags = FILE_ATTRIBUTE_DIRECTORY;
Modified: trunk/reactos/drivers/filesystems/fastfat_new/fastfat.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat... ============================================================================== --- trunk/reactos/drivers/filesystems/fastfat_new/fastfat.h [iso-8859-1] (original) +++ trunk/reactos/drivers/filesystems/fastfat_new/fastfat.h [iso-8859-1] Fri Oct 9 16:20:33 2009 @@ -306,8 +306,14 @@
VOID NTAPI FatSetFcbNames(IN PFAT_IRP_CONTEXT IrpContext, + IN PUNICODE_STRING Lfn, IN PFCB Fcb);
+VOID NTAPI +Fati8dot3ToString(IN PCHAR FileName, + IN BOOLEAN DownCase, + OUT POEM_STRING OutString); + /* ------------------------------------------------------------ rw.c */
NTSTATUS NTAPI
Modified: trunk/reactos/drivers/filesystems/fastfat_new/fatstruc.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat... ============================================================================== --- trunk/reactos/drivers/filesystems/fastfat_new/fatstruc.h [iso-8859-1] (original) +++ trunk/reactos/drivers/filesystems/fastfat_new/fatstruc.h [iso-8859-1] Fri Oct 9 16:20:33 2009 @@ -269,10 +269,11 @@ /* Mcb mapping Vbo->Lbo */ LARGE_MCB Mcb; ULONG FirstCluster; - /* Links into FCB Trie */ - FCB_NAME_LINK FileName; + /* Links into FCB Tree */ + FCB_NAME_LINK ShortName; + FCB_NAME_LINK LongName; /* Buffer for the short name */ - WCHAR ShortNameBuffer[0xc]; + CHAR ShortNameBuffer[0xc]; /* Full file name */ UNICODE_STRING FullFileName; /* Long name with exact case */
Modified: trunk/reactos/drivers/filesystems/fastfat_new/fcb.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfat... ============================================================================== --- trunk/reactos/drivers/filesystems/fastfat_new/fcb.c [iso-8859-1] (original) +++ trunk/reactos/drivers/filesystems/fastfat_new/fcb.c [iso-8859-1] Fri Oct 9 16:20:33 2009 @@ -150,7 +150,7 @@ Fcb->FatHandle = FileHandle;
/* Set names */ - FatSetFcbNames(IrpContext, Fcb); + FatSetFcbNames(IrpContext, NULL, Fcb);
return Fcb; } @@ -247,10 +247,125 @@ VOID NTAPI FatSetFcbNames(IN PFAT_IRP_CONTEXT IrpContext, + IN PUNICODE_STRING Lfn, IN PFCB Fcb) { - // Set the short name first - UNIMPLEMENTED; -} + FF_DIRENT DirEnt; + FF_ERROR Err; + POEM_STRING ShortName; + + /* Get the dir entry */ + Err = FF_GetEntry(Fcb->Vcb->Ioman, + Fcb->FatHandle->DirEntry, + Fcb->FatHandle->DirCluster, + &DirEnt); + + if (Err != FF_ERR_NONE) + { + DPRINT1("Error %d getting dirent of a file\n", Err); + return; + } + + /* 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 +} + +VOID +NTAPI +Fati8dot3ToString(IN PCHAR FileName, + IN BOOLEAN DownCase, + OUT POEM_STRING OutString) +{ +#if 0 + ULONG BaseLen, ExtLen; + CHAR *cString = OutString->Buffer; + ULONG i; + + /* Calc base and ext lens */ + for (BaseLen = 8; BaseLen > 0; BaseLen--) + { + if (FileName[BaseLen - 1] != ' ') break; + } + + for (ExtLen = 3; ExtLen > 0; ExtLen--) + { + if (FileName[8 + ExtLen - 1] != ' ') break; + } + + /* Process base name */ + if (BaseLen) + { + RtlCopyMemory(cString, FileName, BaseLen); + + /* Substitute the e5 thing */ + if (cString[0] == 0x05) cString[0] = 0xe5; + + /* Downcase if asked to */ + if (DownCase) + { + /* Do it manually */ + for (i = 0; i < BaseLen; i++) + { + if (cString[i] >= 'A' && + cString[i] <= 'Z') + { + /* Lowercase it */ + cString[i] += 'a' - 'A'; + } + + } + } + } + + /* Process extension */ + if (ExtLen) + { + /* Add the dot */ + cString[BaseLen] = '.'; + BaseLen++; + + /* Copy the extension */ + for (i = 0; i < ExtLen; i++) + { + cString[BaseLen + i] = FileName[8 + i]; + } + + /* Lowercase the extension if asked to */ + if (DownCase) + { + /* Do it manually */ + for (i = BaseLen; i < BaseLen + ExtLen; i++) + { + if (cString[i] >= 'A' && + cString[i] <= 'Z') + { + /* Lowercase it */ + cString[i] += 'a' - 'A'; + } + } + } + } + + /* Set the length */ + OutString->Length = BaseLen + ExtLen; +#else + RtlCopyMemory(OutString->Buffer, FileName, 11); + OutString->Length = strlen(FileName); + ASSERT(OutString->Length <= 12); +#endif + + DPRINT1("'%s', len %d\n", OutString->Buffer, OutString->Length); +} +
/* EOF */