mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-23 00:43:00 -05:00
sys: IRP_MJ_READ, IRP_MJ_WRITE
This commit is contained in:
parent
55a86ba8c6
commit
8b9e8499aa
@ -300,6 +300,10 @@ typedef struct
|
|||||||
FSP_FSCTL_FILE_INFO FileInfo;
|
FSP_FSCTL_FILE_INFO FileInfo;
|
||||||
} Overwrite;
|
} Overwrite;
|
||||||
struct
|
struct
|
||||||
|
{
|
||||||
|
FSP_FSCTL_FILE_INFO FileInfo;
|
||||||
|
} Read;
|
||||||
|
struct
|
||||||
{
|
{
|
||||||
FSP_FSCTL_FILE_INFO FileInfo;
|
FSP_FSCTL_FILE_INFO FileInfo;
|
||||||
} Write;
|
} Write;
|
||||||
|
@ -35,6 +35,9 @@ enum
|
|||||||
RequestSafeMdl = 1,
|
RequestSafeMdl = 1,
|
||||||
RequestAddress = 2,
|
RequestAddress = 2,
|
||||||
RequestProcess = 3,
|
RequestProcess = 3,
|
||||||
|
|
||||||
|
/* ReadNonCachedComplete retry */
|
||||||
|
RequestInfoChangeNumber = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
static NTSTATUS FspFsvolRead(
|
static NTSTATUS FspFsvolRead(
|
||||||
@ -277,13 +280,6 @@ NTSTATUS FspFsvolReadComplete(
|
|||||||
{
|
{
|
||||||
FSP_ENTER_IOC(PAGED_CODE());
|
FSP_ENTER_IOC(PAGED_CODE());
|
||||||
|
|
||||||
FSP_FSCTL_TRANSACT_REQ *Request = FspIrpRequest(Irp);
|
|
||||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
|
||||||
FSP_FILE_NODE *FileNode = FileObject->FsContext;
|
|
||||||
LARGE_INTEGER ReadOffset = IrpSp->Parameters.Read.ByteOffset;
|
|
||||||
BOOLEAN PagingIo = BooleanFlagOn(Irp->Flags, IRP_PAGING_IO);
|
|
||||||
BOOLEAN SynchronousIo = BooleanFlagOn(FileObject->Flags, FO_SYNCHRONOUS_IO);
|
|
||||||
|
|
||||||
if (!NT_SUCCESS(Response->IoStatus.Status))
|
if (!NT_SUCCESS(Response->IoStatus.Status))
|
||||||
{
|
{
|
||||||
Irp->IoStatus.Information = 0;
|
Irp->IoStatus.Information = 0;
|
||||||
@ -291,16 +287,47 @@ NTSTATUS FspFsvolReadComplete(
|
|||||||
FSP_RETURN();
|
FSP_RETURN();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FSP_FSCTL_TRANSACT_REQ *Request = FspIrpRequest(Irp);
|
||||||
|
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||||
|
FSP_FILE_NODE *FileNode = FileObject->FsContext;
|
||||||
|
LARGE_INTEGER ReadOffset = IrpSp->Parameters.Read.ByteOffset;
|
||||||
|
BOOLEAN PagingIo = BooleanFlagOn(Irp->Flags, IRP_PAGING_IO);
|
||||||
|
BOOLEAN SynchronousIo = BooleanFlagOn(FileObject->Flags, FO_SYNCHRONOUS_IO);
|
||||||
|
ULONG InfoChangeNumber;
|
||||||
|
BOOLEAN Success;
|
||||||
|
|
||||||
if (!PagingIo)
|
if (!PagingIo)
|
||||||
{
|
{
|
||||||
|
if (FspFsctlTransactReadKind == Request->Kind)
|
||||||
|
{
|
||||||
|
InfoChangeNumber = FileNode->InfoChangeNumber;
|
||||||
|
FspIopResetRequest(Request, 0);
|
||||||
|
|
||||||
|
Request->Kind = FspFsctlTransactReservedKind;
|
||||||
|
FspIopRequestContext(Request, RequestInfoChangeNumber) = (PVOID)InfoChangeNumber;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
InfoChangeNumber = (ULONG)(UINT_PTR)FspIopRequestContext(Request, RequestInfoChangeNumber);
|
||||||
|
|
||||||
|
Success = DEBUGTEST(90, TRUE) && FspFileNodeTryAcquireExclusive(FileNode, Main);
|
||||||
|
if (!Success)
|
||||||
|
{
|
||||||
|
FspIopRetryCompleteIrp(Irp, Response, &Result);
|
||||||
|
FSP_RETURN();
|
||||||
|
}
|
||||||
|
|
||||||
|
FspFileNodeTrySetFileInfo(FileNode, FileObject, &Response->Rsp.Read.FileInfo,
|
||||||
|
InfoChangeNumber);
|
||||||
|
|
||||||
/* update the current file offset if synchronous I/O (and not paging I/O) */
|
/* update the current file offset if synchronous I/O (and not paging I/O) */
|
||||||
if (SynchronousIo)
|
if (SynchronousIo)
|
||||||
FileObject->CurrentByteOffset.QuadPart =
|
FileObject->CurrentByteOffset.QuadPart =
|
||||||
ReadOffset.QuadPart + Response->IoStatus.Information;
|
ReadOffset.QuadPart + Response->IoStatus.Information;
|
||||||
}
|
|
||||||
|
|
||||||
FspFileNodeReleaseOwner(FileNode, Full, Request);
|
FspFileNodeRelease(FileNode, Main);
|
||||||
/* will also clear FspIrpFlags() */
|
}
|
||||||
|
else
|
||||||
|
FspIopResetRequest(Request, 0);
|
||||||
|
|
||||||
Irp->IoStatus.Information = Response->IoStatus.Information;
|
Irp->IoStatus.Information = Response->IoStatus.Information;
|
||||||
Result = STATUS_SUCCESS;
|
Result = STATUS_SUCCESS;
|
||||||
@ -343,7 +370,7 @@ static VOID FspFsvolReadNonCachedRequestFini(FSP_FSCTL_TRANSACT_REQ *Request, PV
|
|||||||
if (0 != SafeMdl)
|
if (0 != SafeMdl)
|
||||||
FspSafeMdlDelete(SafeMdl);
|
FspSafeMdlDelete(SafeMdl);
|
||||||
|
|
||||||
if (0 != Irp && 0 != FspIrpFlags(Irp))
|
if (0 != Irp)
|
||||||
{
|
{
|
||||||
PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||||
FSP_FILE_NODE *FileNode = IrpSp->FileObject->FsContext;
|
FSP_FILE_NODE *FileNode = IrpSp->FileObject->FsContext;
|
||||||
|
@ -368,6 +368,13 @@ NTSTATUS FspFsvolWriteComplete(
|
|||||||
{
|
{
|
||||||
FSP_ENTER_IOC(PAGED_CODE());
|
FSP_ENTER_IOC(PAGED_CODE());
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(Response->IoStatus.Status))
|
||||||
|
{
|
||||||
|
Irp->IoStatus.Information = 0;
|
||||||
|
Result = Response->IoStatus.Status;
|
||||||
|
FSP_RETURN();
|
||||||
|
}
|
||||||
|
|
||||||
FSP_FSCTL_TRANSACT_REQ *Request = FspIrpRequest(Irp);
|
FSP_FSCTL_TRANSACT_REQ *Request = FspIrpRequest(Irp);
|
||||||
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
PFILE_OBJECT FileObject = IrpSp->FileObject;
|
||||||
FSP_FILE_NODE *FileNode = FileObject->FsContext;
|
FSP_FILE_NODE *FileNode = FileObject->FsContext;
|
||||||
@ -377,13 +384,6 @@ NTSTATUS FspFsvolWriteComplete(
|
|||||||
BOOLEAN PagingIo = BooleanFlagOn(Irp->Flags, IRP_PAGING_IO);
|
BOOLEAN PagingIo = BooleanFlagOn(Irp->Flags, IRP_PAGING_IO);
|
||||||
BOOLEAN SynchronousIo = BooleanFlagOn(FileObject->Flags, FO_SYNCHRONOUS_IO);
|
BOOLEAN SynchronousIo = BooleanFlagOn(FileObject->Flags, FO_SYNCHRONOUS_IO);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Response->IoStatus.Status))
|
|
||||||
{
|
|
||||||
Irp->IoStatus.Information = 0;
|
|
||||||
Result = Response->IoStatus.Status;
|
|
||||||
FSP_RETURN();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!PagingIo)
|
if (!PagingIo)
|
||||||
{
|
{
|
||||||
/* update file info */
|
/* update file info */
|
||||||
@ -396,8 +396,7 @@ NTSTATUS FspFsvolWriteComplete(
|
|||||||
WriteOffset.QuadPart + Response->IoStatus.Information;
|
WriteOffset.QuadPart + Response->IoStatus.Information;
|
||||||
}
|
}
|
||||||
|
|
||||||
FspFileNodeReleaseOwner(FileNode, Full, Request);
|
FspIopResetRequest(Request, 0);
|
||||||
/* will also clear FspIrpFlags() */
|
|
||||||
|
|
||||||
Irp->IoStatus.Information = Response->IoStatus.Information;
|
Irp->IoStatus.Information = Response->IoStatus.Information;
|
||||||
Result = STATUS_SUCCESS;
|
Result = STATUS_SUCCESS;
|
||||||
@ -440,7 +439,7 @@ static VOID FspFsvolWriteNonCachedRequestFini(FSP_FSCTL_TRANSACT_REQ *Request, P
|
|||||||
if (0 != SafeMdl)
|
if (0 != SafeMdl)
|
||||||
FspSafeMdlDelete(SafeMdl);
|
FspSafeMdlDelete(SafeMdl);
|
||||||
|
|
||||||
if (0 != Irp && 0 != FspIrpFlags(Irp))
|
if (0 != Irp)
|
||||||
{
|
{
|
||||||
PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
PIO_STACK_LOCATION IrpSp = IoGetCurrentIrpStackLocation(Irp);
|
||||||
FSP_FILE_NODE *FileNode = IrpSp->FileObject->FsContext;
|
FSP_FILE_NODE *FileNode = IrpSp->FileObject->FsContext;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user