From 8f8f77367cd578f9d4b64b1477b40663c52adcd7 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Thu, 1 Oct 2009 13:21:28 +0000 Subject: [PATCH] [fastfat_new] - Open a file in FatiOpenExistingFile by means of FullFAT library. - Fix incorrect fullfat placement in fasfat.rbuild. - Hack StreamFileObject to be 5Gb in length instead of 512 bytes. It'll be set to the size of an underlying physical device later. - Add FF file handle to FCB structure. svn path=/trunk/; revision=43247 --- .../drivers/filesystems/fastfat_new/create.c | 17 +++++++++++++++++ .../filesystems/fastfat_new/fastfat.rbuild | 2 +- reactos/drivers/filesystems/fastfat_new/fat.c | 7 +++++-- .../drivers/filesystems/fastfat_new/fatstruc.h | 2 ++ .../drivers/filesystems/fastfat_new/fullfat.c | 1 + reactos/drivers/filesystems/fastfat_new/rw.c | 4 ++-- 6 files changed, 28 insertions(+), 5 deletions(-) diff --git a/reactos/drivers/filesystems/fastfat_new/create.c b/reactos/drivers/filesystems/fastfat_new/create.c index 846577a9a3f..0aec6378d18 100644 --- a/reactos/drivers/filesystems/fastfat_new/create.c +++ b/reactos/drivers/filesystems/fastfat_new/create.c @@ -59,7 +59,10 @@ FatiOpenExistingFile(IN PFAT_IRP_CONTEXT IrpContext, IN BOOLEAN IsDosName) { IO_STATUS_BLOCK Iosb = {{0}}; + OEM_STRING AnsiName; + CHAR AnsiNameBuf[512]; PFCB Fcb; + NTSTATUS Status; /* Check for create file option and fail */ if (CreateDisposition == FILE_CREATE) @@ -73,6 +76,20 @@ FatiOpenExistingFile(IN PFAT_IRP_CONTEXT IrpContext, /* Create a new FCB for this file */ Fcb = FatCreateFcb(IrpContext, Vcb, ParentDcb); + /* Convert the name to ANSI */ + AnsiName.Buffer = AnsiNameBuf; + AnsiName.Length = 0; + AnsiName.MaximumLength = sizeof(AnsiNameBuf); + RtlZeroMemory(AnsiNameBuf, sizeof(AnsiNameBuf)); + Status = RtlUpcaseUnicodeStringToCountedOemString(&AnsiName, &FileObject->FileName, FALSE); + if (!NT_SUCCESS(Status)) + { + ASSERT(FALSE); + } + + /* Open the file with FullFAT */ + Fcb->FatHandle = FF_Open(Vcb->Ioman, AnsiName.Buffer, FF_MODE_READ, NULL); + // TODO: Check if overwrite is needed // This is usual file open branch, without overwriting! diff --git a/reactos/drivers/filesystems/fastfat_new/fastfat.rbuild b/reactos/drivers/filesystems/fastfat_new/fastfat.rbuild index ac49fe0611b..f29c915dc56 100644 --- a/reactos/drivers/filesystems/fastfat_new/fastfat.rbuild +++ b/reactos/drivers/filesystems/fastfat_new/fastfat.rbuild @@ -4,10 +4,10 @@ . include/reactos/libs/fullfat + fullfat ntoskrnl hal pseh - fullfat blockdev.c cleanup.c close.c diff --git a/reactos/drivers/filesystems/fastfat_new/fat.c b/reactos/drivers/filesystems/fastfat_new/fat.c index c1fa63ab76c..db6d517394d 100644 --- a/reactos/drivers/filesystems/fastfat_new/fat.c +++ b/reactos/drivers/filesystems/fastfat_new/fat.c @@ -484,11 +484,14 @@ FatInitializeVcb(IN PFAT_IRP_CONTEXT IrpContext, Vcb->StreamFileObject->SectionObjectPointer = &Vcb->SectionObjectPointers; /* At least full boot sector should be available */ - Vcb->Header.FileSize.QuadPart = sizeof(PACKED_BOOT_SECTOR); - Vcb->Header.AllocationSize.QuadPart = sizeof(PACKED_BOOT_SECTOR); + //Vcb->Header.FileSize.QuadPart = sizeof(PACKED_BOOT_SECTOR); + //Vcb->Header.AllocationSize.QuadPart = sizeof(PACKED_BOOT_SECTOR); Vcb->Header.ValidDataLength.HighPart = MAXLONG; Vcb->Header.ValidDataLength.LowPart = MAXULONG; + Vcb->Header.AllocationSize.QuadPart = Int32x32To64(5*1024, 1024*1024); //HACK: 5 Gb + Vcb->Header.FileSize.QuadPart = Vcb->Header.AllocationSize.QuadPart; + /* Set VCB to a good condition */ Vcb->Condition = VcbGood; diff --git a/reactos/drivers/filesystems/fastfat_new/fatstruc.h b/reactos/drivers/filesystems/fastfat_new/fatstruc.h index 64fb5358327..962e06e606e 100644 --- a/reactos/drivers/filesystems/fastfat_new/fatstruc.h +++ b/reactos/drivers/filesystems/fastfat_new/fatstruc.h @@ -279,6 +279,8 @@ typedef struct _FCB UCHAR DirentFatFlags; /* File basic info */ FILE_BASIC_INFORMATION BasicInfo; + /* FullFAT file handle */ + FF_FILE *FatHandle; union { struct diff --git a/reactos/drivers/filesystems/fastfat_new/fullfat.c b/reactos/drivers/filesystems/fastfat_new/fullfat.c index dcaf94bd655..cb1b8351c83 100644 --- a/reactos/drivers/filesystems/fastfat_new/fullfat.c +++ b/reactos/drivers/filesystems/fastfat_new/fullfat.c @@ -58,6 +58,7 @@ FatReadBlocks(FF_T_UINT8 *DestBuffer, FF_T_UINT32 SectorAddress, FF_T_UINT32 Cou &Bcb, &Buffer)) { + ASSERT(FALSE); /* Mapping failed */ return 0; } diff --git a/reactos/drivers/filesystems/fastfat_new/rw.c b/reactos/drivers/filesystems/fastfat_new/rw.c index 3e543f89b72..d3693d897c2 100644 --- a/reactos/drivers/filesystems/fastfat_new/rw.c +++ b/reactos/drivers/filesystems/fastfat_new/rw.c @@ -38,8 +38,8 @@ FatiRead(PFAT_IRP_CONTEXT IrpContext) OpenType = FatDecodeFileObject(FileObject, &Vcb, &Fcb, &Ccb); - DPRINT1("FatiRead() Fcb %p, Name %wZ, Offset %d, Length %d\n", - Fcb, &FileObject->FileName, ByteOffset.LowPart, NumberOfBytes); + DPRINT1("FatiRead() Fcb %p, Name %wZ, Offset %d, Length %d, Handle %p\n", + Fcb, &FileObject->FileName, ByteOffset.LowPart, NumberOfBytes, Fcb->FatHandle); return STATUS_NOT_IMPLEMENTED; }