[fastfat_new]
authorAleksey Bragin <aleksey@reactos.org>
Tue, 20 Oct 2009 12:51:13 +0000 (12:51 +0000)
committerAleksey Bragin <aleksey@reactos.org>
Tue, 20 Oct 2009 12:51:13 +0000 (12:51 +0000)
- Implement root directory open operation.
- Add OpenCount counter to FCB.

svn path=/trunk/; revision=43646

reactos/drivers/filesystems/fastfat_new/create.c
reactos/drivers/filesystems/fastfat_new/fatstruc.h

index a01cece..e76dc9a 100644 (file)
@@ -23,10 +23,64 @@ FatiOpenRootDcb(IN PFAT_IRP_CONTEXT IrpContext,
                 IN ULONG CreateDisposition)
 {
     IO_STATUS_BLOCK Iosb;
+    PFCB Dcb;
+    NTSTATUS Status;
+    PCCB Ccb;
+
+    /* Reference our DCB */
+    Dcb = Vcb->RootDcb;
+
+    DPRINT("Opening root directory\n");
+
+    /* Exclusively lock this DCB */
+    (VOID)FatAcquireExclusiveFcb(IrpContext, Dcb);
+
+    do
+    {
+        /* Validate parameters */
+        if (CreateDisposition != FILE_OPEN &&
+            CreateDisposition != FILE_OPEN_IF)
+        {
+            Iosb.Status = STATUS_ACCESS_DENIED;
+            break;
+        }
+
+        // TODO: Check file access
+
+        /* Is it a first time open? */
+        if (Dcb->OpenCount == 0)
+        {
+            /* Set share access */
+            IoSetShareAccess(*DesiredAccess,
+                             ShareAccess,
+                             FileObject,
+                             &Dcb->ShareAccess);
+        }
+        else
+        {
+            /* Check share access */
+            Status = IoCheckShareAccess(*DesiredAccess,
+                                        ShareAccess,
+                                        FileObject,
+                                        &Dcb->ShareAccess,
+                                        TRUE);
+        }
+
+        /* Set file object pointers */
+        Ccb = FatCreateCcb(IrpContext);
+        FatSetFileObject(FileObject, UserDirectoryOpen, Dcb, Ccb);
+
+        /* Increment counters */
+        Dcb->OpenCount++;
+        Vcb->OpenFileCount++;
 
-    DPRINT1("Opening root directory\n");
+        /* Set success statuses */
+        Iosb.Status = STATUS_SUCCESS;
+        Iosb.Information = FILE_OPENED;
+    } while (FALSE);
 
-    Iosb.Status = STATUS_NOT_IMPLEMENTED;
+    /* Release the DCB lock */
+    FatReleaseFcb(IrpContext, Dcb);
 
     return Iosb;
 }
index 4f8d684..17d8fd4 100644 (file)
@@ -305,6 +305,8 @@ typedef struct _FCB
     ULONG OutstandingAsyncWrites;
     /* The outstanding async writes sync event */
     PKEVENT OutstandingAsyncEvent;
+    /* Counters */
+    ULONG OpenCount;
     union
     {
         struct