mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 09:03:25 +00:00
[fastfat_new]
- Start implementing volume open requests. svn path=/trunk/; revision=43397
This commit is contained in:
parent
6be2aea1b3
commit
0f711aae4c
2 changed files with 128 additions and 7 deletions
|
@ -113,6 +113,100 @@ FatiOpenExistingFile(IN PFAT_IRP_CONTEXT IrpContext,
|
||||||
return Iosb;
|
return Iosb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IO_STATUS_BLOCK
|
||||||
|
NTAPI
|
||||||
|
FatiOpenVolume(IN PFAT_IRP_CONTEXT IrpContext,
|
||||||
|
IN PFILE_OBJECT FileObject,
|
||||||
|
IN PVCB Vcb,
|
||||||
|
IN PACCESS_MASK DesiredAccess,
|
||||||
|
IN USHORT ShareAccess,
|
||||||
|
IN ULONG CreateDisposition)
|
||||||
|
{
|
||||||
|
PCCB Ccb;
|
||||||
|
IO_STATUS_BLOCK Iosb = {{0}};
|
||||||
|
BOOLEAN VolumeFlushed = FALSE;
|
||||||
|
|
||||||
|
/* Check parameters */
|
||||||
|
if (CreateDisposition != FILE_OPEN &&
|
||||||
|
CreateDisposition != FILE_OPEN_IF)
|
||||||
|
{
|
||||||
|
/* Deny access */
|
||||||
|
Iosb.Status = STATUS_ACCESS_DENIED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if it's exclusive open */
|
||||||
|
if (!FlagOn(ShareAccess, FILE_SHARE_WRITE) &&
|
||||||
|
!FlagOn(ShareAccess, FILE_SHARE_DELETE))
|
||||||
|
{
|
||||||
|
// TODO: Check if exclusive read access requested
|
||||||
|
// and opened handles count is not 0
|
||||||
|
//if (!FlagOn(ShareAccess, FILE_SHARE_READ)
|
||||||
|
|
||||||
|
DPRINT1("Exclusive voume open\n");
|
||||||
|
|
||||||
|
// TODO: Flush the volume
|
||||||
|
VolumeFlushed = TRUE;
|
||||||
|
}
|
||||||
|
else if (FlagOn(*DesiredAccess, FILE_READ_DATA | FILE_WRITE_DATA | FILE_APPEND_DATA))
|
||||||
|
{
|
||||||
|
DPRINT1("Shared open\n");
|
||||||
|
|
||||||
|
// TODO: Flush the volume
|
||||||
|
VolumeFlushed = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (VolumeFlushed &&
|
||||||
|
!FlagOn(Vcb->State, VCB_STATE_MOUNTED_DIRTY) &&
|
||||||
|
FlagOn(Vcb->State, VCB_STATE_FLAG_DIRTY) &&
|
||||||
|
CcIsThereDirtyData(Vcb->Vpb))
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set share access */
|
||||||
|
if (Vcb->DirectOpenCount > 0)
|
||||||
|
{
|
||||||
|
/* This volume has already been opened */
|
||||||
|
Iosb.Status = IoCheckShareAccess(*DesiredAccess,
|
||||||
|
ShareAccess,
|
||||||
|
FileObject,
|
||||||
|
&Vcb->ShareAccess,
|
||||||
|
TRUE);
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(Iosb.Status))
|
||||||
|
{
|
||||||
|
ASSERT(FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* This is the first time open */
|
||||||
|
IoSetShareAccess(*DesiredAccess,
|
||||||
|
ShareAccess,
|
||||||
|
FileObject,
|
||||||
|
&Vcb->ShareAccess);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set file object pointers */
|
||||||
|
Ccb = FatCreateCcb(IrpContext);
|
||||||
|
FatSetFileObject(FileObject, UserVolumeOpen, Vcb, Ccb);
|
||||||
|
FileObject->SectionObjectPointer = &Vcb->SectionObjectPointers;
|
||||||
|
|
||||||
|
/* Increase direct open count */
|
||||||
|
Vcb->DirectOpenCount++;
|
||||||
|
Vcb->OpenFileCount++;
|
||||||
|
|
||||||
|
/* Set no buffering flag */
|
||||||
|
FileObject->Flags |= FO_NO_INTERMEDIATE_BUFFERING;
|
||||||
|
|
||||||
|
// TODO: User's access check
|
||||||
|
|
||||||
|
Iosb.Status = STATUS_SUCCESS;
|
||||||
|
Iosb.Information = FILE_OPENED;
|
||||||
|
|
||||||
|
return Iosb;
|
||||||
|
}
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
FatiCreate(IN PFAT_IRP_CONTEXT IrpContext,
|
FatiCreate(IN PFAT_IRP_CONTEXT IrpContext,
|
||||||
|
@ -297,17 +391,36 @@ FatiCreate(IN PFAT_IRP_CONTEXT IrpContext,
|
||||||
if (!RelatedFO ||
|
if (!RelatedFO ||
|
||||||
FatDecodeFileObject(RelatedFO, &DecodedVcb, &Fcb, &Ccb) == UserVolumeOpen)
|
FatDecodeFileObject(RelatedFO, &DecodedVcb, &Fcb, &Ccb) == UserVolumeOpen)
|
||||||
{
|
{
|
||||||
|
/* Check parameters */
|
||||||
|
if (DirectoryFile || OpenTargetDirectory)
|
||||||
|
{
|
||||||
|
Status = DirectoryFile ? STATUS_NOT_A_DIRECTORY : STATUS_INVALID_PARAMETER;
|
||||||
|
|
||||||
|
/* Unlock VCB */
|
||||||
|
FatReleaseVcb(IrpContext, Vcb);
|
||||||
|
|
||||||
|
/* Complete the request and return */
|
||||||
|
FatCompleteRequest(IrpContext, Irp, Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
/* It is indeed a volume open request */
|
/* It is indeed a volume open request */
|
||||||
DPRINT1("Volume open request, not implemented now!\n");
|
Iosb = FatiOpenVolume(IrpContext,
|
||||||
UNIMPLEMENTED;
|
FileObject,
|
||||||
|
Vcb,
|
||||||
|
DesiredAccess,
|
||||||
|
ShareAccess,
|
||||||
|
CreateDisposition);
|
||||||
|
|
||||||
|
/* Set resulting information */
|
||||||
|
Irp->IoStatus.Information = Iosb.Information;
|
||||||
|
|
||||||
/* Unlock VCB */
|
/* Unlock VCB */
|
||||||
FatReleaseVcb(IrpContext, Vcb);
|
FatReleaseVcb(IrpContext, Vcb);
|
||||||
|
|
||||||
/* Complete the request */
|
/* Complete the request and return */
|
||||||
FatCompleteRequest(IrpContext, Irp, STATUS_NOT_IMPLEMENTED);
|
FatCompleteRequest(IrpContext, Irp, Iosb.Status);
|
||||||
|
return Iosb.Status;
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,9 @@ typedef struct _FAT_METHODS {
|
||||||
PFAT_SETFAT_VALUE_RUN_ROUTINE SetValueRun;
|
PFAT_SETFAT_VALUE_RUN_ROUTINE SetValueRun;
|
||||||
} FAT_METHODS, *PFAT_METHODS;
|
} FAT_METHODS, *PFAT_METHODS;
|
||||||
|
|
||||||
#define VCB_STATE_FLAG_LOCKED 0x01
|
#define VCB_STATE_FLAG_LOCKED 0x01
|
||||||
|
#define VCB_STATE_FLAG_DIRTY 0x02
|
||||||
|
#define VCB_STATE_MOUNTED_DIRTY 0x04
|
||||||
|
|
||||||
typedef enum _VCB_CONDITION
|
typedef enum _VCB_CONDITION
|
||||||
{
|
{
|
||||||
|
@ -157,6 +159,10 @@ typedef struct _VCB
|
||||||
VCB_CONDITION Condition;
|
VCB_CONDITION Condition;
|
||||||
ERESOURCE Resource;
|
ERESOURCE Resource;
|
||||||
|
|
||||||
|
/* Direct volume access */
|
||||||
|
ULONG DirectOpenCount;
|
||||||
|
SHARE_ACCESS ShareAccess;
|
||||||
|
|
||||||
/* Notifications support */
|
/* Notifications support */
|
||||||
PNOTIFY_SYNC NotifySync;
|
PNOTIFY_SYNC NotifySync;
|
||||||
LIST_ENTRY NotifyList;
|
LIST_ENTRY NotifyList;
|
||||||
|
@ -179,7 +185,9 @@ typedef struct _VCB
|
||||||
/* Root Directory Control block */
|
/* Root Directory Control block */
|
||||||
struct _FCB *RootDcb;
|
struct _FCB *RootDcb;
|
||||||
|
|
||||||
|
/* Counters */
|
||||||
ULONG MediaChangeCount;
|
ULONG MediaChangeCount;
|
||||||
|
ULONG OpenFileCount;
|
||||||
|
|
||||||
/* FullFAT integration */
|
/* FullFAT integration */
|
||||||
FF_IOMAN *Ioman;
|
FF_IOMAN *Ioman;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue