mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-25 01:42:24 -05:00
sys: IRP_MJ_READ, IRP_MJ_WRITE: file lock support
This commit is contained in:
parent
218ad0be8c
commit
66dbfb24ff
@ -97,10 +97,6 @@ static NTSTATUS FspFsvolReadCached(
|
|||||||
FSP_FILE_NODE *FileNode = FileObject->FsContext;
|
FSP_FILE_NODE *FileNode = FileObject->FsContext;
|
||||||
LARGE_INTEGER ReadOffset = IrpSp->Parameters.Read.ByteOffset;
|
LARGE_INTEGER ReadOffset = IrpSp->Parameters.Read.ByteOffset;
|
||||||
ULONG ReadLength = IrpSp->Parameters.Read.Length;
|
ULONG ReadLength = IrpSp->Parameters.Read.Length;
|
||||||
#if 0
|
|
||||||
/* !!!: lock support! */
|
|
||||||
ULONG ReadKey = IrpSp->Parameters.Read.Key;
|
|
||||||
#endif
|
|
||||||
BOOLEAN SynchronousIo = BooleanFlagOn(FileObject->Flags, FO_SYNCHRONOUS_IO);
|
BOOLEAN SynchronousIo = BooleanFlagOn(FileObject->Flags, FO_SYNCHRONOUS_IO);
|
||||||
FSP_FSCTL_FILE_INFO FileInfo;
|
FSP_FSCTL_FILE_INFO FileInfo;
|
||||||
CC_FILE_SIZES FileSizes;
|
CC_FILE_SIZES FileSizes;
|
||||||
@ -112,6 +108,13 @@ static NTSTATUS FspFsvolReadCached(
|
|||||||
if (!Success)
|
if (!Success)
|
||||||
return FspWqRepostIrpWorkItem(Irp, FspFsvolReadCached, 0);
|
return FspWqRepostIrpWorkItem(Irp, FspFsvolReadCached, 0);
|
||||||
|
|
||||||
|
/* check the file locks */
|
||||||
|
if (!FsRtlCheckLockForReadAccess(&FileNode->FileLock, Irp))
|
||||||
|
{
|
||||||
|
FspFileNodeRelease(FileNode, Main);
|
||||||
|
return STATUS_FILE_LOCK_CONFLICT;
|
||||||
|
}
|
||||||
|
|
||||||
/* trim ReadLength; the cache manager does not tolerate reads beyond file size */
|
/* trim ReadLength; the cache manager does not tolerate reads beyond file size */
|
||||||
ASSERT(FspTimeoutInfinity32 ==
|
ASSERT(FspTimeoutInfinity32 ==
|
||||||
FspFsvolDeviceExtension(FsvolDeviceObject)->VolumeParams.FileInfoTimeout);
|
FspFsvolDeviceExtension(FsvolDeviceObject)->VolumeParams.FileInfoTimeout);
|
||||||
@ -234,6 +237,13 @@ static NTSTATUS FspFsvolReadNonCached(
|
|||||||
if (!Success)
|
if (!Success)
|
||||||
return FspWqRepostIrpWorkItem(Irp, FspFsvolReadNonCached, 0);
|
return FspWqRepostIrpWorkItem(Irp, FspFsvolReadNonCached, 0);
|
||||||
|
|
||||||
|
/* check the file locks */
|
||||||
|
if (!PagingIo && !FsRtlCheckLockForReadAccess(&FileNode->FileLock, Irp))
|
||||||
|
{
|
||||||
|
FspFileNodeRelease(FileNode, Full);
|
||||||
|
return STATUS_FILE_LOCK_CONFLICT;
|
||||||
|
}
|
||||||
|
|
||||||
/* if this is a non-cached transfer on a cached file then flush the file */
|
/* if this is a non-cached transfer on a cached file then flush the file */
|
||||||
if (!PagingIo && 0 != FileObject->SectionObjectPointer->DataSectionObject)
|
if (!PagingIo && 0 != FileObject->SectionObjectPointer->DataSectionObject)
|
||||||
{
|
{
|
||||||
|
@ -98,10 +98,6 @@ static NTSTATUS FspFsvolWriteCached(
|
|||||||
FSP_FILE_NODE *FileNode = FileObject->FsContext;
|
FSP_FILE_NODE *FileNode = FileObject->FsContext;
|
||||||
LARGE_INTEGER WriteOffset = IrpSp->Parameters.Write.ByteOffset;
|
LARGE_INTEGER WriteOffset = IrpSp->Parameters.Write.ByteOffset;
|
||||||
ULONG WriteLength = IrpSp->Parameters.Write.Length;
|
ULONG WriteLength = IrpSp->Parameters.Write.Length;
|
||||||
#if 0
|
|
||||||
/* !!!: lock support! */
|
|
||||||
ULONG WriteKey = IrpSp->Parameters.Write.Key;
|
|
||||||
#endif
|
|
||||||
BOOLEAN WriteToEndOfFile =
|
BOOLEAN WriteToEndOfFile =
|
||||||
FILE_WRITE_TO_END_OF_FILE == WriteOffset.LowPart && -1L == WriteOffset.HighPart;
|
FILE_WRITE_TO_END_OF_FILE == WriteOffset.LowPart && -1L == WriteOffset.HighPart;
|
||||||
BOOLEAN SynchronousIo = BooleanFlagOn(FileObject->Flags, FO_SYNCHRONOUS_IO);
|
BOOLEAN SynchronousIo = BooleanFlagOn(FileObject->Flags, FO_SYNCHRONOUS_IO);
|
||||||
@ -134,6 +130,13 @@ static NTSTATUS FspFsvolWriteCached(
|
|||||||
if (!Success)
|
if (!Success)
|
||||||
return FspWqRepostIrpWorkItem(Irp, FspFsvolWriteCached, 0);
|
return FspWqRepostIrpWorkItem(Irp, FspFsvolWriteCached, 0);
|
||||||
|
|
||||||
|
/* check the file locks */
|
||||||
|
if (!FsRtlCheckLockForWriteAccess(&FileNode->FileLock, Irp))
|
||||||
|
{
|
||||||
|
FspFileNodeRelease(FileNode, Main);
|
||||||
|
return STATUS_FILE_LOCK_CONFLICT;
|
||||||
|
}
|
||||||
|
|
||||||
/* compute new file size */
|
/* compute new file size */
|
||||||
ASSERT(FspTimeoutInfinity32 ==
|
ASSERT(FspTimeoutInfinity32 ==
|
||||||
FspFsvolDeviceExtension(FsvolDeviceObject)->VolumeParams.FileInfoTimeout);
|
FspFsvolDeviceExtension(FsvolDeviceObject)->VolumeParams.FileInfoTimeout);
|
||||||
@ -300,6 +303,13 @@ static NTSTATUS FspFsvolWriteNonCached(
|
|||||||
if (!Success)
|
if (!Success)
|
||||||
return FspWqRepostIrpWorkItem(Irp, FspFsvolWriteNonCached, 0);
|
return FspWqRepostIrpWorkItem(Irp, FspFsvolWriteNonCached, 0);
|
||||||
|
|
||||||
|
/* check the file locks */
|
||||||
|
if (!PagingIo && !FsRtlCheckLockForWriteAccess(&FileNode->FileLock, Irp))
|
||||||
|
{
|
||||||
|
FspFileNodeRelease(FileNode, Full);
|
||||||
|
return STATUS_FILE_LOCK_CONFLICT;
|
||||||
|
}
|
||||||
|
|
||||||
/* if this is a non-cached transfer on a cached file then flush and purge the file */
|
/* if this is a non-cached transfer on a cached file then flush and purge the file */
|
||||||
if (!PagingIo && 0 != FileObject->SectionObjectPointer->DataSectionObject)
|
if (!PagingIo && 0 != FileObject->SectionObjectPointer->DataSectionObject)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user