Author: fireball
Date: Wed Oct 28 12:29:34 2009
New Revision: 43809
URL:
http://svn.reactos.org/svn/reactos?rev=43809&view=rev
Log:
[fastfat_new]
- Implement overwrite/supersede operations on an existing FCB, no on-disk writing yet.
Modified:
trunk/reactos/drivers/filesystems/fastfat_new/create.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] Wed Oct 28
12:29:34 2009
@@ -115,6 +115,113 @@
/* Return status */
return Error;
+}
+
+IO_STATUS_BLOCK
+NTAPI
+FatiOverwriteFile(PFAT_IRP_CONTEXT IrpContext,
+ PFILE_OBJECT FileObject,
+ PFCB Fcb,
+ ULONG AllocationSize,
+ PFILE_FULL_EA_INFORMATION EaBuffer,
+ ULONG EaLength,
+ UCHAR FileAttributes,
+ ULONG CreateDisposition,
+ BOOLEAN NoEaKnowledge)
+{
+ IO_STATUS_BLOCK Iosb = {{0}};
+ PCCB Ccb;
+ LARGE_INTEGER Zero;
+ ULONG NotifyFilter;
+
+ Zero.QuadPart = 0;
+
+ /* Check Ea mismatch first */
+ if (NoEaKnowledge && EaLength > 0)
+ {
+ Iosb.Status = STATUS_ACCESS_DENIED;
+ return Iosb;
+ }
+
+ do
+ {
+ /* Check if it's not still mapped */
+ if (!MmCanFileBeTruncated(&Fcb->SectionObjectPointers,
+ &Zero))
+ {
+ /* Fail */
+ Iosb.Status = STATUS_USER_MAPPED_FILE;
+ break;
+ }
+
+ /* Set file object pointers */
+ Ccb = FatCreateCcb();
+ FatSetFileObject(FileObject,
+ UserFileOpen,
+ Fcb,
+ Ccb);
+
+ FileObject->SectionObjectPointer = &Fcb->SectionObjectPointers;
+
+ /* Indicate that create is in progress */
+ Fcb->Vcb->State |= VCB_STATE_CREATE_IN_PROGRESS;
+
+ /* Purge the cache section */
+ CcPurgeCacheSection(&Fcb->SectionObjectPointers, NULL, 0, FALSE);
+
+ /* Add Eas */
+ if (EaLength > 0)
+ {
+ ASSERT(FALSE);
+ }
+
+ /* Acquire the paging resource */
+ (VOID)ExAcquireResourceExclusiveLite(Fcb->Header.PagingIoResource, TRUE);
+
+ /* Initialize FCB header */
+ Fcb->Header.FileSize.QuadPart = 0;
+ Fcb->Header.ValidDataLength.QuadPart = 0;
+
+ /* Let CC know about changed file size */
+ CcSetFileSizes(FileObject, (PCC_FILE_SIZES)&Fcb->Header.AllocationSize);
+
+ // TODO: Actually truncate the file
+ DPRINT1("TODO: Actually truncate the file with a fullfat handle %x\n",
Fcb->FatHandle);
+
+ /* Release the paging resource */
+ ExReleaseResourceLite(Fcb->Header.PagingIoResource);
+
+ /* Specify truncate on close */
+ Fcb->State |= FCB_STATE_TRUNCATE_ON_CLOSE;
+
+ // TODO: Delete previous EA if needed
+
+ /* Send notification about changes */
+ NotifyFilter = FILE_NOTIFY_CHANGE_LAST_WRITE |
+ FILE_NOTIFY_CHANGE_ATTRIBUTES |
+ FILE_NOTIFY_CHANGE_SIZE;
+
+ FsRtlNotifyFullReportChange(Fcb->Vcb->NotifySync,
+ &Fcb->Vcb->NotifyList,
+ (PSTRING)&Fcb->FullFileName,
+ Fcb->FullFileName.Length -
Fcb->FileNameLength,
+ NULL,
+ NULL,
+ NotifyFilter,
+ FILE_ACTION_MODIFIED,
+ NULL);
+
+ /* Set success status */
+ Iosb.Status = STATUS_SUCCESS;
+
+ /* Set correct information code */
+ Iosb.Information = (CreateDisposition == FILE_SUPERSEDE) ? FILE_SUPERSEDED :
FILE_OVERWRITTEN;
+ } while (0);
+
+ /* Remove the create in progress flag */
+ ClearFlag(Fcb->Vcb->State, VCB_STATE_CREATE_IN_PROGRESS);
+
+ return Iosb;
}
IO_STATUS_BLOCK
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] Wed Oct 28
12:29:34 2009
@@ -94,6 +94,18 @@
IN BOOLEAN DeleteOnClose);
/* -------------------------------------------------------- create.c */
+
+IO_STATUS_BLOCK
+NTAPI
+FatiOverwriteFile(PFAT_IRP_CONTEXT IrpContext,
+ PFILE_OBJECT FileObject,
+ PFCB Fcb,
+ ULONG AllocationSize,
+ PFILE_FULL_EA_INFORMATION EaBuffer,
+ ULONG EaLength,
+ UCHAR FileAttributes,
+ ULONG CreateDisposition,
+ BOOLEAN NoEaKnowledge);
NTSTATUS NTAPI
FatCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp);
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] Wed Oct 28
12:29:34 2009
@@ -248,10 +248,11 @@
FcbNeedsToBeVerified
} FCB_CONDITION;
-#define FCB_STATE_HAS_NAMES 0x01
-#define FCB_STATE_HAS_UNICODE_NAME 0x02
-#define FCB_STATE_PAGEFILE 0x04
-#define FCB_STATE_DELAY_CLOSE 0x08
+#define FCB_STATE_HAS_NAMES 0x01
+#define FCB_STATE_HAS_UNICODE_NAME 0x02
+#define FCB_STATE_PAGEFILE 0x04
+#define FCB_STATE_DELAY_CLOSE 0x08
+#define FCB_STATE_TRUNCATE_ON_CLOSE 0x10
typedef struct _FCB
{
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] Wed Oct 28 12:29:34
2009
@@ -195,7 +195,7 @@
BOOLEAN Hidden;
BOOLEAN System;
PCCB Ccb = NULL;
- NTSTATUS Status;
+ NTSTATUS Status, StatusPrev;
/* Acquire exclusive FCB lock */
(VOID)FatAcquireExclusiveFcb(IrpContext, Fcb);
@@ -383,8 +383,27 @@
(CreateDisposition == FILE_OVERWRITE) ||
(CreateDisposition == FILE_OVERWRITE_IF))
{
- UNIMPLEMENTED;
- ASSERT(FALSE);
+ /* Remember previous status */
+ StatusPrev = Iosb.Status;
+
+ // TODO: Check system security access
+
+ /* Perform overwrite operation */
+ Iosb = FatiOverwriteFile(IrpContext,
+ FileObject,
+ Fcb,
+ AllocationSize,
+ EaBuffer,
+ EaLength,
+ FileAttributes,
+ CreateDisposition,
+ NoEaKnowledge);
+
+ /* Restore previous status in case of success */
+ if (Iosb.Status == STATUS_SUCCESS)
+ Iosb.Status = StatusPrev;
+
+ /* Fall down to completion */
}
else
{