[ros-diffs] [ekohl] 49713: [NPFS] Add an FCB that represents the file system (volume/device) and support absolute and relative open, cleanup and close.

ekohl at svn.reactos.org ekohl at svn.reactos.org
Mon Nov 22 23:08:12 UTC 2010


Author: ekohl
Date: Mon Nov 22 23:08:11 2010
New Revision: 49713

URL: http://svn.reactos.org/svn/reactos?rev=49713&view=rev
Log:
[NPFS]
Add an FCB that represents the file system (volume/device) and support absolute and relative open, cleanup and close.

Modified:
    trunk/reactos/drivers/filesystems/npfs/create.c
    trunk/reactos/drivers/filesystems/npfs/npfs.c
    trunk/reactos/drivers/filesystems/npfs/npfs.h

Modified: trunk/reactos/drivers/filesystems/npfs/create.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/npfs/create.c?rev=49713&r1=49712&r2=49713&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/npfs/create.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/npfs/create.c [iso-8859-1] Mon Nov 22 23:08:11 2010
@@ -102,6 +102,35 @@
         }
         CurrentEntry = CurrentEntry->Flink;
     }
+}
+
+
+static VOID
+NpfsOpenFileSystem(PNPFS_FCB Fcb,
+                   PFILE_OBJECT FileObject,
+                   PIO_STATUS_BLOCK IoStatus)
+{
+    PNPFS_CCB Ccb;
+
+    DPRINT("NpfsOpenFileSystem()\n");
+
+    Ccb = ExAllocatePool(NonPagedPool, sizeof(NPFS_CCB));
+    if (Ccb == NULL)
+    {
+        IoStatus->Status = STATUS_NO_MEMORY;
+        return;
+    }
+
+    Ccb->Type = CCB_DEVICE;
+    Ccb->Fcb = Fcb;
+
+    FileObject->FsContext = Fcb;
+    FileObject->FsContext2 = Ccb;
+
+    IoStatus->Information = FILE_OPENED;
+    IoStatus->Status = STATUS_SUCCESS;
+
+    return;
 }
 
 
@@ -174,6 +203,24 @@
     }
 #endif
 
+    DPRINT("FileName->Length: %hu  RelatedFileObject: %p\n", FileName->Length, RelatedFileObject);
+
+    /* Open the file system */
+    if (FileName->Length == 0 &&
+        (RelatedFileObject == NULL || ((PNPFS_CCB)RelatedFileObject->FsContext2)->Type == CCB_DEVICE))
+    {
+        DPRINT("Open the file system\n");
+
+        NpfsOpenFileSystem(Vcb->DeviceFcb,
+                           FileObject,
+                           &Irp->IoStatus);
+
+        Status = Irp->IoStatus.Status;
+        IoCompleteRequest(Irp, IO_NO_INCREMENT);
+        return Status;
+    }
+
+    /* Open the root directory */
     if (FileName->Length == 2 && FileName->Buffer[0] == L'\\' && RelatedFileObject == NULL)
     {
         DPRINT("Open the root directory\n");
@@ -656,6 +703,15 @@
     if (Ccb == NULL)
     {
         DPRINT("Success!\n");
+        Irp->IoStatus.Status = STATUS_SUCCESS;
+        Irp->IoStatus.Information = 0;
+        IoCompleteRequest(Irp, IO_NO_INCREMENT);
+        return STATUS_SUCCESS;
+    }
+
+    if (Ccb->Type == CCB_DEVICE)
+    {
+        DPRINT("Cleanup the file system!\n");
         Irp->IoStatus.Status = STATUS_SUCCESS;
         Irp->IoStatus.Information = 0;
         IoCompleteRequest(Irp, IO_NO_INCREMENT);
@@ -806,6 +862,20 @@
         return STATUS_SUCCESS;
     }
 
+    if (Ccb->Type == CCB_DEVICE)
+    {
+        DPRINT("Closing the file system!\n");
+
+        ExFreePool(Ccb);
+        FileObject->FsContext = NULL;
+        FileObject->FsContext2 = NULL;
+
+        Irp->IoStatus.Status = STATUS_SUCCESS;
+        Irp->IoStatus.Information = 0;
+        IoCompleteRequest(Irp, IO_NO_INCREMENT);
+        return STATUS_SUCCESS;
+    }
+
     if (Ccb->Type == CCB_DIRECTORY)
     {
         DPRINT("Closing the root directory!\n");

Modified: trunk/reactos/drivers/filesystems/npfs/npfs.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/npfs/npfs.c?rev=49713&r1=49712&r2=49713&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/npfs/npfs.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/npfs/npfs.c [iso-8859-1] Mon Nov 22 23:08:11 2010
@@ -85,12 +85,16 @@
     Vcb->DefaultQuota = 8 * PAGE_SIZE;
     Vcb->MaxQuota = 64 * PAGE_SIZE;
 
+    /* Create the device FCB */
+    Fcb = ExAllocatePool(NonPagedPool, sizeof(NPFS_FCB));
+    Fcb->Type = FCB_DEVICE;
+    Fcb->Vcb = Vcb;
+    Vcb->DeviceFcb = Fcb;
+
+    /* Create the root directory FCB */
     Fcb = ExAllocatePool(NonPagedPool, sizeof(NPFS_FCB));
     Fcb->Type = FCB_DIRECTORY;
     Fcb->Vcb = Vcb;
-
-
-
     Vcb->RootFcb = Fcb;
 
     return STATUS_SUCCESS;

Modified: trunk/reactos/drivers/filesystems/npfs/npfs.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/filesystems/npfs/npfs.h?rev=49713&r1=49712&r2=49713&view=diff
==============================================================================
--- trunk/reactos/drivers/filesystems/npfs/npfs.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/filesystems/npfs/npfs.h [iso-8859-1] Mon Nov 22 23:08:11 2010
@@ -28,6 +28,7 @@
     ULONG MinQuota;
     ULONG DefaultQuota;
     ULONG MaxQuota;
+    struct _NPFS_FCB *DeviceFcb;
     struct _NPFS_FCB *RootFcb;
 } NPFS_VCB, *PNPFS_VCB;
 




More information about the Ros-diffs mailing list