From 64b8e965ef339df120ac4bd6193ff0d44c8c227b Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Tue, 20 Oct 2009 17:45:59 +0000 Subject: [PATCH] [fastfat_new] - Increase FCB's OpenCount when opening existing FCB too. - Properly compare prefixes in FatInsertName. - Fix a copypaste bug which resulted in an infinite loop while traversing a splay tree of FCB names. - Implement FatiQueryFsSizeInfo. svn path=/trunk/; revision=43654 --- reactos/drivers/filesystems/fastfat_new/fcb.c | 20 ++++++++--- .../drivers/filesystems/fastfat_new/volume.c | 34 +++++++++++++++++++ 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/reactos/drivers/filesystems/fastfat_new/fcb.c b/reactos/drivers/filesystems/fastfat_new/fcb.c index 2e06db24e66..e863984d83b 100644 --- a/reactos/drivers/filesystems/fastfat_new/fcb.c +++ b/reactos/drivers/filesystems/fastfat_new/fcb.c @@ -423,7 +423,8 @@ SuccComplete: /* Clear the delay close */ ClearFlag(Fcb->State, FCB_STATE_DELAY_CLOSE); - /* Increase global volume counter */ + /* Increase counters */ + Fcb->OpenCount++; Vcb->OpenFileCount++; // TODO: Handle DeleteOnClose and OpenedAsDos by storing those flags in CCB @@ -895,8 +896,19 @@ FatInsertName(IN PFAT_IRP_CONTEXT IrpContext, NameLink = CONTAINING_RECORD(*RootNode, FCB_NAME_LINK, Links); while (TRUE) { - /* Compare prefixes */ - Comparison = FatiCompareNames(&NameLink->Name.Ansi, &Name->Name.Ansi); + /* Compare the prefix */ + if (*(PUCHAR)NameLink->Name.Ansi.Buffer != *(PUCHAR)&Name->Name.Ansi.Buffer) + { + if (*(PUCHAR)NameLink->Name.Ansi.Buffer < *(PUCHAR)&Name->Name.Ansi.Buffer) + Comparison = LessThan; + else + Comparison = GreaterThan; + } + else + { + /* Perform real comparison */ + Comparison = FatiCompareNames(&NameLink->Name.Ansi, &Name->Name.Ansi); + } /* Check the bad case first */ if (Comparison == EqualTo) @@ -912,7 +924,7 @@ FatInsertName(IN PFAT_IRP_CONTEXT IrpContext, if (!RtlLeftChild(&NameLink->Links)) { /* It's absent, insert here and break */ - RtlInsertAsLeftChild(&NameLink->Links, &NameLink->Links); + RtlInsertAsLeftChild(&NameLink->Links, &Name->Links); break; } else diff --git a/reactos/drivers/filesystems/fastfat_new/volume.c b/reactos/drivers/filesystems/fastfat_new/volume.c index 4a2ee5fa3b8..49a67b0a450 100644 --- a/reactos/drivers/filesystems/fastfat_new/volume.c +++ b/reactos/drivers/filesystems/fastfat_new/volume.c @@ -53,6 +53,36 @@ FatiQueryFsVolumeInfo(PVCB Vcb, return Status; } +NTSTATUS +NTAPI +FatiQueryFsSizeInfo(PVCB Vcb, + PFILE_FS_SIZE_INFORMATION Buffer, + PLONG Length) +{ + FF_PARTITION *Partition; + NTSTATUS Status = STATUS_SUCCESS; + + /* Deduct the minimum written length */ + *Length -= sizeof(FILE_FS_SIZE_INFORMATION); + + /* Zero it */ + RtlZeroMemory(Buffer, sizeof(FILE_FS_SIZE_INFORMATION)); + + /* Reference FullFAT's partition */ + Partition = Vcb->Ioman->pPartition; + + /* Set values */ + Buffer->AvailableAllocationUnits.LowPart = Partition->FreeClusterCount; + Buffer->TotalAllocationUnits.LowPart = Partition->NumClusters; + Buffer->SectorsPerAllocationUnit = Vcb->Bpb.SectorsPerCluster; + Buffer->BytesPerSector = Vcb->Bpb.BytesPerSector; + + DPRINT1("Total %d, free %d, SPC %d, BPS %d\n", Partition->FreeClusterCount, + Partition->NumClusters, Vcb->Bpb.SectorsPerCluster, Vcb->Bpb.BytesPerSector); + + return Status; +} + NTSTATUS NTAPI FatiQueryVolumeInfo(PFAT_IRP_CONTEXT IrpContext, PIRP Irp) @@ -105,6 +135,10 @@ FatiQueryVolumeInfo(PFAT_IRP_CONTEXT IrpContext, PIRP Irp) /* Call FsVolumeInfo handler */ Status = FatiQueryFsVolumeInfo(Vcb, Buffer, &Length); break; + case FileFsSizeInformation: + /* Call FsVolumeInfo handler */ + Status = FatiQueryFsSizeInfo(Vcb, Buffer, &Length); + break; default: DPRINT1("Volume information class %d is not supported!\n", InfoClass); UNIMPLEMENTED; -- 2.17.1