X-Git-Url: https://git.reactos.org/?p=reactos.git;a=blobdiff_plain;f=drivers%2Ffilesystems%2Ffastfat_new%2Fdir.c;h=991971545bfbef9e0d4fc8462eb2b8183b7a2a49;hp=ca04e84c191ece85805bf6a02a1b0a6248be21fc;hb=f9862d34b49fdd947295bdb4197f9cb1feb8d2ac;hpb=d4933ee771a930736e6d821b5bd25d903651b4ef diff --git a/drivers/filesystems/fastfat_new/dir.c b/drivers/filesystems/fastfat_new/dir.c index ca04e84c191..991971545bf 100644 --- a/drivers/filesystems/fastfat_new/dir.c +++ b/drivers/filesystems/fastfat_new/dir.c @@ -82,9 +82,6 @@ FatCreateRootDcb(IN PFAT_IRP_CONTEXT IrpContext, ExInitializeFastMutex(&Dcb->HeaderMutex); FsRtlSetupAdvancedHeader(&Dcb->Header, &Dcb->HeaderMutex); - /* Initialize MCB */ - FsRtlInitializeLargeMcb(&Dcb->Mcb, NonPagedPool); - /* Set up first cluster field depending on FAT type */ if (TRUE/*FatIsFat32(Vcb)*/) { @@ -114,13 +111,6 @@ FatCreateRootDcb(IN PFAT_IRP_CONTEXT IrpContext, #endif UNIMPLEMENTED; } - - /* Initialize free dirent bitmap */ - RtlInitializeBitMap(&Dcb->Dcb.FreeBitmap, NULL, 0); - - /* Fill the dirent bitmap */ - DPRINT1("Filling the free dirent bitmap is missing\n"); - //FatCheckFreeDirentBitmap( IrpContext, Dcb ); } PFCB @@ -191,9 +181,98 @@ FatiOpenExistingDcb(IN PFAT_IRP_CONTEXT IrpContext, IN BOOLEAN DeleteOnClose) { IO_STATUS_BLOCK Iosb = {{0}}; + PCCB Ccb; + + /* Exclusively lock this FCB */ + FatAcquireExclusiveFcb(IrpContext, Dcb); + + /* Check if it's a delete-on-close of a root DCB */ + if (FatNodeType(Dcb) == FAT_NTC_ROOT_DCB && DeleteOnClose) + { + Iosb.Status = STATUS_CANNOT_DELETE; + + /* Release the lock and return */ + FatReleaseFcb(IrpContext, Dcb); + return Iosb; + } + + /*if (NoEaKnowledge && NodeType(Dcb) != FAT_NTC_ROOT_DCB && + !FatIsFat32(Vcb)) + { + UNIMPLEMENTED; + }*/ + + /* Check the create disposition and desired access */ + if ((CreateDisposition != FILE_OPEN) && + (CreateDisposition != FILE_OPEN_IF)) + { + Iosb.Status = STATUS_OBJECT_NAME_COLLISION; + + /* Release the lock and return */ + FatReleaseFcb(IrpContext, Dcb); + return Iosb; + } + +#if 0 + if (!FatCheckFileAccess(IrpContext, + Dcb->DirentFatFlags, + DesiredAccess)) + { + Iosb.Status = STATUS_ACCESS_DENIED; + try_return( Iosb ); + } +#endif + + /* If it's already opened - check share access */ + if (Dcb->OpenCount > 0) + { + Iosb.Status = IoCheckShareAccess(*DesiredAccess, + ShareAccess, + FileObject, + &Dcb->ShareAccess, + TRUE); + + if (!NT_SUCCESS(Iosb.Status)) + { + /* Release the lock and return */ + FatReleaseFcb(IrpContext, Dcb); + return Iosb; + } + } + else + { + IoSetShareAccess(*DesiredAccess, + ShareAccess, + FileObject, + &Dcb->ShareAccess); + } + + /* Set the file object */ + Ccb = FatCreateCcb(IrpContext); + FatSetFileObject(FileObject, + UserDirectoryOpen, + Dcb, + Ccb); + + /* Increase counters */ + Dcb->UncleanCount++; + Dcb->OpenCount++; + Vcb->OpenFileCount++; + if (IsFileObjectReadOnly(FileObject)) Vcb->ReadOnlyCount++; + + /* Set delete on close */ + if (DeleteOnClose) + SetFlag(Ccb->Flags, CCB_DELETE_ON_CLOSE); + + /* Clear delay close flag */ + ClearFlag(Dcb->State, FCB_STATE_DELAY_CLOSE); + + /* That's it */ + Iosb.Status = STATUS_SUCCESS; + Iosb.Information = FILE_OPENED; - Iosb.Status = STATUS_NOT_IMPLEMENTED; - UNIMPLEMENTED; + /* Release the lock */ + FatReleaseFcb(IrpContext, Dcb); return Iosb; }