2 * FFS File System Driver for Windows
8 * Lee Jae-Hong, http://www.pyrasis.com
19 extern PFFS_GLOBAL FFSGlobal
;
25 #pragma alloc_text(PAGE, FFSLockControl)
28 __drv_mustHoldCriticalRegion
31 IN PFFS_IRP_CONTEXT IrpContext
)
33 PDEVICE_OBJECT DeviceObject
;
34 BOOLEAN CompleteRequest
;
35 NTSTATUS Status
= STATUS_UNSUCCESSFUL
;
36 PFILE_OBJECT FileObject
;
44 ASSERT(IrpContext
!= NULL
);
46 ASSERT((IrpContext
->Identifier
.Type
== FFSICX
) &&
47 (IrpContext
->Identifier
.Size
== sizeof(FFS_IRP_CONTEXT
)));
49 DeviceObject
= IrpContext
->DeviceObject
;
51 if (DeviceObject
== FFSGlobal
->DeviceObject
)
53 CompleteRequest
= TRUE
;
54 Status
= STATUS_INVALID_DEVICE_REQUEST
;
58 FileObject
= IrpContext
->FileObject
;
60 Fcb
= (PFFS_FCB
)FileObject
->FsContext
;
64 if (Fcb
->Identifier
.Type
== FFSVCB
)
66 CompleteRequest
= TRUE
;
67 Status
= STATUS_INVALID_PARAMETER
;
71 ASSERT((Fcb
->Identifier
.Type
== FFSFCB
) &&
72 (Fcb
->Identifier
.Size
== sizeof(FFS_FCB
)));
74 if (FlagOn(Fcb
->FFSMcb
->FileAttr
, FILE_ATTRIBUTE_DIRECTORY
))
76 CompleteRequest
= TRUE
;
77 Status
= STATUS_INVALID_PARAMETER
;
81 Irp
= IrpContext
->Irp
;
84 // While the file has any byte range locks we set IsFastIoPossible to
85 // FastIoIsQuestionable so that the FastIoCheckIfPossible function is
86 // called to check the locks for any fast I/O read/write operation.
88 if (Fcb
->Header
.IsFastIoPossible
!= FastIoIsQuestionable
)
92 "FFSLockControl: %-16.16s %-31s %s\n",
93 FFSGetCurrentProcessName(),
94 "FastIoIsQuestionable",
95 Fcb
->AnsiFileName
.Buffer
));
97 Fcb
->Header
.IsFastIoPossible
= FastIoIsQuestionable
;
101 // FsRtlProcessFileLock acquires FileObject->FsContext->Resource while
102 // modifying the file locks and calls IoCompleteRequest when it's done.
105 CompleteRequest
= FALSE
;
107 Status
= FsRtlProcessFileLock(
108 &Fcb
->FileLockAnchor
,
112 if (!NT_SUCCESS(Status
))
115 "FFSLockControl: %-16.16s %-31s *** Status: %s (%#x) ***\n",
116 FFSGetCurrentProcessName(),
117 "IRP_MJ_LOCK_CONTROL",
118 FFSNtStatusToString(Status
),
125 if (!IrpContext
->ExceptionInProgress
)
127 if (!CompleteRequest
)
129 IrpContext
->Irp
= NULL
;
132 FFSCompleteIrpContext(IrpContext
, Status
);