Author: fireball
Date: Fri Oct 2 15:59:51 2009
New Revision: 43256
URL:
http://svn.reactos.org/svn/reactos?rev=43256&view=rev
Log:
[fastfat_new]
- Fail with an error if file can't be opened.
- Implement FatCreateDcb, actually create DCBs for all parsed directories in the path.
- Set file size in an advanced FSRTL header for a file.
- Implement a small helper function for setting full names in FCB/DCB like it's done
in the reference driver.
Modified:
trunk/reactos/drivers/filesystems/fastfat_new/create.c
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/create.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- trunk/reactos/drivers/filesystems/fastfat_new/create.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/fastfat_new/create.c [iso-8859-1] Fri Oct 2
15:59:51 2009
@@ -63,6 +63,7 @@
CHAR AnsiNameBuf[512];
PFCB Fcb;
NTSTATUS Status;
+ FF_FILE *FileHandle;
/* Check for create file option and fail */
if (CreateDisposition == FILE_CREATE)
@@ -72,9 +73,6 @@
}
// TODO: Check more params
-
- /* Create a new FCB for this file */
- Fcb = FatCreateFcb(IrpContext, Vcb, ParentDcb);
/* Convert the name to ANSI */
AnsiName.Buffer = AnsiNameBuf;
@@ -88,7 +86,16 @@
}
/* Open the file with FullFAT */
- Fcb->FatHandle = FF_Open(Vcb->Ioman, AnsiName.Buffer, FF_MODE_READ, NULL);
+ FileHandle = FF_Open(Vcb->Ioman, AnsiName.Buffer, FF_MODE_READ, NULL);
+
+ if (!FileHandle)
+ {
+ Iosb.Status = STATUS_OBJECT_NAME_NOT_FOUND; // FIXME: A shortcut for now
+ return Iosb;
+ }
+
+ /* Create a new FCB for this file */
+ Fcb = FatCreateFcb(IrpContext, Vcb, ParentDcb, FileHandle);
// TODO: Check if overwrite is needed
@@ -505,7 +512,13 @@
/* Break if came to the end */
if (!RemainingPart.Length) break;
- // TODO: Create a DCB for this entry
+ /* Create a DCB for this entry */
+ ParentDcb = FatCreateDcb(IrpContext,
+ Vcb,
+ ParentDcb);
+
+ /* Set its name */
+ FatSetFullNameInFcb(ParentDcb, &FirstName);
}
// TODO: Try to open directory
Modified: trunk/reactos/drivers/filesystems/fastfat_new/dir.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- 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 2 15:59:51
2009
@@ -123,5 +123,46 @@
//FatCheckFreeDirentBitmap( IrpContext, Dcb );
}
+PFCB
+NTAPI
+FatCreateDcb(IN PFAT_IRP_CONTEXT IrpContext,
+ IN PVCB Vcb,
+ IN PFCB ParentDcb)
+{
+ PFCB Fcb;
+
+ /* Allocate it and zero it */
+ Fcb = ExAllocatePoolWithTag(NonPagedPool, sizeof(FCB), TAG_FCB);
+ RtlZeroMemory(Fcb, sizeof(FCB));
+
+ /* Set node types */
+ Fcb->Header.NodeTypeCode = FAT_NTC_DCB;
+ Fcb->Header.NodeByteSize = sizeof(FCB);
+ Fcb->Condition = FcbGood;
+
+ /* Initialize resources */
+ Fcb->Header.Resource = &Fcb->Resource;
+ ExInitializeResourceLite(Fcb->Header.Resource);
+
+ Fcb->Header.PagingIoResource = &Fcb->PagingIoResource;
+ ExInitializeResourceLite(Fcb->Header.PagingIoResource);
+
+ /* Initialize mutexes */
+ Fcb->Header.FastMutex = &Fcb->HeaderMutex;
+ ExInitializeFastMutex(&Fcb->HeaderMutex);
+ FsRtlSetupAdvancedHeader(&Fcb->Header, &Fcb->HeaderMutex);
+
+ /* Insert into parent's DCB list */
+ InsertHeadList(&ParentDcb->Dcb.ParentDcbList, &Fcb->ParentDcbLinks);
+
+ /* Set backlinks */
+ Fcb->ParentFcb = ParentDcb;
+ Fcb->Vcb = Vcb;
+
+ /* Initialize parent dcb list */
+ InitializeListHead(&Fcb->Dcb.ParentDcbList);
+
+ return Fcb;
+}
/* EOF */
Modified: trunk/reactos/drivers/filesystems/fastfat_new/fastfat.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- 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 2
15:59:51 2009
@@ -73,6 +73,11 @@
VOID NTAPI
FatCreateRootDcb(IN PFAT_IRP_CONTEXT IrpContext,
IN PVCB Vcb);
+
+PFCB NTAPI
+FatCreateDcb(IN PFAT_IRP_CONTEXT IrpContext,
+ IN PVCB Vcb,
+ IN PFCB ParentDcb);
/* -------------------------------------------------------- create.c */
@@ -264,7 +269,8 @@
FatCreateFcb(
IN PFAT_IRP_CONTEXT IrpContext,
IN PVCB Vcb,
- IN PFCB ParentDcb);
+ IN PFCB ParentDcb,
+ IN FF_FILE *FileHandle);
NTSTATUS
FatOpenFcb(
@@ -282,6 +288,10 @@
PCCB NTAPI
FatCreateCcb();
+VOID NTAPI
+FatSetFullNameInFcb(PFCB Fcb,
+ PUNICODE_STRING Name);
+
/* ------------------------------------------------------------ rw.c */
NTSTATUS NTAPI
Modified: trunk/reactos/drivers/filesystems/fastfat_new/fatstruc.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- 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 2
15:59:51 2009
@@ -275,6 +275,8 @@
WCHAR ShortNameBuffer[0xc];
/* Full file name */
UNICODE_STRING FullFileName;
+ /* Long name with exact case */
+ UNICODE_STRING ExactCaseLongName;
/* A copy of fat attribute byte */
UCHAR DirentFatFlags;
/* File basic info */
Modified: trunk/reactos/drivers/filesystems/fastfat_new/fcb.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/fastfa…
==============================================================================
--- 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 2 15:59:51
2009
@@ -11,6 +11,8 @@
#define NDEBUG
#include "fastfat.h"
+#define TAG_FILENAME 'fBnF'
+
/* FUNCTIONS ****************************************************************/
FSRTL_COMPARISON_RESULT
@@ -109,7 +111,8 @@
NTAPI
FatCreateFcb(IN PFAT_IRP_CONTEXT IrpContext,
IN PVCB Vcb,
- IN PFCB ParentDcb)
+ IN PFCB ParentDcb,
+ IN FF_FILE *FileHandle)
{
PFCB Fcb;
@@ -141,6 +144,11 @@
Fcb->ParentFcb = ParentDcb;
Fcb->Vcb = Vcb;
+ /* Set file handle and sizes */
+ Fcb->Header.FileSize.LowPart = FileHandle->Filesize;
+ Fcb->Header.ValidDataLength.LowPart = FileHandle->Filesize;
+ Fcb->FatHandle = FileHandle;
+
return Fcb;
}
@@ -161,4 +169,76 @@
return Ccb;
}
+VOID
+NTAPI
+FatSetFullNameInFcb(PFCB Fcb,
+ PUNICODE_STRING Name)
+{
+ PUNICODE_STRING ParentName;
+
+ /* Make sure this FCB's name wasn't already set */
+ ASSERT(Fcb->FullFileName.Buffer == NULL);
+
+ /* First of all, check exact case name */
+ if (Fcb->ExactCaseLongName.Buffer)
+ {
+ ASSERT(Fcb->ExactCaseLongName.Length != 0);
+
+ /* Use exact case name */
+ Name = &Fcb->ExactCaseLongName;
+ }
+
+ /* Treat root dir different */
+ if (FatNodeType(Fcb->ParentFcb) == FAT_NTC_ROOT_DCB)
+ {
+ /* Set lengths */
+ Fcb->FullFileName.MaximumLength = sizeof(WCHAR) + Name->Length;
+ Fcb->FullFileName.Length = Fcb->FullFileName.MaximumLength;
+
+ /* Allocate a buffer */
+ Fcb->FullFileName.Buffer = FsRtlAllocatePoolWithTag(PagedPool,
+ Fcb->FullFileName.Length,
+ TAG_FILENAME);
+
+ /* Prefix with a backslash */
+ Fcb->FullFileName.Buffer[0] = L'\\';
+
+ /* Copy the name here */
+ RtlCopyMemory(&Fcb->FullFileName.Buffer[1],
+ &Name->Buffer[0],
+ Name->Length );
+ }
+ else
+ {
+ ParentName = &Fcb->ParentFcb->FullFileName;
+
+ /* Check if parent's name is set */
+ if (!ParentName->Buffer)
+ return;
+
+ /* Set lengths */
+ Fcb->FullFileName.MaximumLength =
+ ParentName->Length + sizeof(WCHAR) + Name->Length;
+ Fcb->FullFileName.Length = Fcb->FullFileName.MaximumLength;
+
+ /* Allocate a buffer */
+ Fcb->FullFileName.Buffer = FsRtlAllocatePoolWithTag(PagedPool,
+ Fcb->FullFileName.Length,
+ TAG_FILENAME );
+
+ /* Copy parent's name here */
+ RtlCopyMemory(&Fcb->FullFileName.Buffer[0],
+ &ParentName->Buffer[0],
+ ParentName->Length );
+
+ /* Add a backslash */
+ Fcb->FullFileName.Buffer[ParentName->Length / sizeof(WCHAR)] =
L'\\';
+
+ /* Copy given name here */
+ RtlCopyMemory(&Fcb->FullFileName.Buffer[(ParentName->Length /
sizeof(WCHAR)) + 1],
+ &Name->Buffer[0],
+ Name->Length );
+ }
+}
+
/* EOF */