Author: fireball
Date: Fri Oct 2 12:49:57 2009
New Revision: 43252
URL:
http://svn.reactos.org/svn/reactos?rev=43252&view=rev
Log:
[fastfat_new]
- Implement querying standard information (important for getting correct file size).
- Substitute CcMap/copy/Unpin by CcCopyRead in FatReadBlocks.
- Take offset into account (seek) in file read operation. Fixes always reading files from
the beginning.
Modified:
trunk/reactos/drivers/filesystems/fastfat_new/finfo.c
trunk/reactos/drivers/filesystems/fastfat_new/fullfat.c
trunk/reactos/drivers/filesystems/fastfat_new/rw.c
Modified: trunk/reactos/drivers/filesystems/fastfat_new/finfo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat_new/finfo.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat_new/finfo.c [iso-8859-1] Fri Oct 2 12:49:57
2009
@@ -13,6 +13,49 @@
/* FUNCTIONS ****************************************************************/
+VOID
+NTAPI
+FatiQueryStandardInformation(IN PFAT_IRP_CONTEXT IrpContext,
+ IN PFCB Fcb,
+ IN PFILE_OBJECT FileObject,
+ IN OUT PFILE_STANDARD_INFORMATION Buffer,
+ IN OUT PLONG Length)
+{
+ /* Zero the buffer */
+ RtlZeroMemory(Buffer, sizeof(FILE_STANDARD_INFORMATION));
+
+ /* Deduct the written length */
+ *Length -= sizeof(FILE_STANDARD_INFORMATION);
+
+ Buffer->NumberOfLinks = 1;
+ Buffer->DeletePending = FALSE; // FIXME
+
+ /* Check if it's a dir or a file */
+ if (FatNodeType(Fcb) == FAT_NTC_FCB)
+ {
+ Buffer->Directory = FALSE;
+
+ Buffer->EndOfFile.LowPart = Fcb->FatHandle->Filesize;
+ Buffer->AllocationSize = Buffer->EndOfFile;
+ DPRINT1("Filesize %d, chain length %d\n",
Fcb->FatHandle->Filesize, Fcb->FatHandle->iChainLength);
+ }
+ else
+ {
+ Buffer->Directory = TRUE;
+ }
+}
+
+VOID
+NTAPI
+FatiQueryInternalInformation(IN PFAT_IRP_CONTEXT IrpContext,
+ IN PFCB Fcb,
+ IN PFILE_OBJECT FileObject,
+ IN OUT PFILE_INTERNAL_INFORMATION Buffer,
+ IN OUT PLONG Length)
+{
+ UNIMPLEMENTED;
+}
+
NTSTATUS
NTAPI
FatiQueryInformation(IN PFAT_IRP_CONTEXT IrpContext,
@@ -25,6 +68,9 @@
PVCB Vcb;
PFCB Fcb;
PCCB Ccb;
+ LONG Length;
+ PVOID Buffer;
+ NTSTATUS Status = STATUS_SUCCESS;
/* Get IRP stack location */
IrpSp = IoGetCurrentIrpStackLocation(Irp);
@@ -32,19 +78,51 @@
/* Get the file object */
FileObject = IrpSp->FileObject;
+ /* Copy variables to something with shorter names */
InfoClass = IrpSp->Parameters.QueryFile.FileInformationClass;
+ Length = IrpSp->Parameters.QueryFile.Length;
+ Buffer = Irp->AssociatedIrp.SystemBuffer;
- DPRINT1("FatCommonQueryInformation\n", 0);
+ DPRINT1("FatiQueryInformation\n", 0);
DPRINT1("\tIrp = %08lx\n", Irp);
- DPRINT1("\tLength = %08lx\n",
IrpSp->Parameters.QueryFile.Length);
+ DPRINT1("\tLength = %08lx\n", Length);
DPRINT1("\tFileInformationClass = %08lx\n", InfoClass);
- DPRINT1("\tBuffer = %08lx\n",
Irp->AssociatedIrp.SystemBuffer);
+ DPRINT1("\tBuffer = %08lx\n", Buffer);
FileType = FatDecodeFileObject(FileObject, &Vcb, &Fcb, &Ccb);
DPRINT1("Vcb %p, Fcb %p, Ccb %p, open type %d\n", Vcb, Fcb, Ccb,
FileType);
- return STATUS_SUCCESS;
+ // TODO: Acquire FCB locks
+
+ switch (InfoClass)
+ {
+ case FileStandardInformation:
+ FatiQueryStandardInformation(IrpContext, Fcb, FileObject, Buffer, &Length);
+ break;
+ case FileInternalInformation:
+ FatiQueryInternalInformation(IrpContext, Fcb, FileObject, Buffer, &Length);
+ break;
+ default:
+ DPRINT1("Unimplemented information class %d requested\n", InfoClass);
+ Status = STATUS_INVALID_PARAMETER;
+ }
+
+ /* Check for buffer overflow */
+ if (Length < 0)
+ {
+ Status = STATUS_BUFFER_OVERFLOW;
+ Length = 0;
+ }
+
+ /* Set IoStatus.Information to amount of filled bytes */
+ Irp->IoStatus.Information = IrpSp->Parameters.QueryFile.Length - Length;
+
+ // TODO: Release FCB locks
+
+ /* Complete request and return status */
+ FatCompleteRequest(IrpContext, Irp, Status);
+ return Status;
}
NTSTATUS
Modified: trunk/reactos/drivers/filesystems/fastfat_new/fullfat.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat_new/fullfat.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat_new/fullfat.c [iso-8859-1] Fri Oct 2
12:49:57 2009
@@ -41,16 +41,17 @@
FatReadBlocks(FF_T_UINT8 *DestBuffer, FF_T_UINT32 SectorAddress, FF_T_UINT32 Count, void
*pParam)
{
LARGE_INTEGER Offset;
- PVOID Buffer;
+ //PVOID Buffer;
PVCB Vcb = (PVCB)pParam;
- PBCB Bcb;
+ //PBCB Bcb;
ULONG SectorSize = 512; // FIXME: hardcoding 512 is bad
+ IO_STATUS_BLOCK IoSb;
DPRINT("FatReadBlocks %p %d %d %p\n", DestBuffer, SectorAddress, Count,
pParam);
/* Calculate the offset */
Offset.QuadPart = Int32x32To64(SectorAddress, SectorSize);
-
+#if 0
if (!CcMapData(Vcb->StreamFileObject,
&Offset,
Count * SectorSize,
@@ -68,6 +69,9 @@
/* Unpin unneeded data */
CcUnpinData(Bcb);
+#else
+ CcCopyRead(Vcb->StreamFileObject, &Offset, Count * SectorSize, TRUE,
DestBuffer, &IoSb);
+#endif
/* Return amount of read data in sectors */
return Count;
Modified: trunk/reactos/drivers/filesystems/fastfat_new/rw.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat_new/rw.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat_new/rw.c [iso-8859-1] Fri Oct 2 12:49:57
2009
@@ -54,6 +54,10 @@
Buffer = FatMapUserBuffer(IrpContext->Irp);
DPRINT1("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);