ReactOS  0.4.14-dev-77-gd9e7c48
lock.c
Go to the documentation of this file.
1 /*
2  * FFS File System Driver for Windows
3  *
4  * lock.c
5  *
6  * 2004.5.6 ~
7  *
8  * Lee Jae-Hong, http://www.pyrasis.com
9  *
10  * See License.txt
11  *
12  */
13 
14 #include "ntifs.h"
15 #include "ffsdrv.h"
16 
17 /* Globals */
18 
19 extern PFFS_GLOBAL FFSGlobal;
20 
21 
22 /* Definitions */
23 
24 #ifdef ALLOC_PRAGMA
25 #pragma alloc_text(PAGE, FFSLockControl)
26 #endif
27 
31  IN PFFS_IRP_CONTEXT IrpContext)
32 {
37  PFFS_FCB Fcb;
38  PIRP Irp;
39 
40  PAGED_CODE();
41 
42  _SEH2_TRY
43  {
44  ASSERT(IrpContext != NULL);
45 
46  ASSERT((IrpContext->Identifier.Type == FFSICX) &&
47  (IrpContext->Identifier.Size == sizeof(FFS_IRP_CONTEXT)));
48 
49  DeviceObject = IrpContext->DeviceObject;
50 
52  {
56  }
57 
58  FileObject = IrpContext->FileObject;
59 
60  Fcb = (PFFS_FCB)FileObject->FsContext;
61 
62  ASSERT(Fcb != NULL);
63 
64  if (Fcb->Identifier.Type == FFSVCB)
65  {
69  }
70 
72  (Fcb->Identifier.Size == sizeof(FFS_FCB)));
73 
74  if (FlagOn(Fcb->FFSMcb->FileAttr, FILE_ATTRIBUTE_DIRECTORY))
75  {
79  }
80 
81  Irp = IrpContext->Irp;
82 
83  //
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.
87  //
88  if (Fcb->Header.IsFastIoPossible != FastIoIsQuestionable)
89  {
90 
92  "FFSLockControl: %-16.16s %-31s %s\n",
94  "FastIoIsQuestionable",
95  Fcb->AnsiFileName.Buffer));
96 
97  Fcb->Header.IsFastIoPossible = FastIoIsQuestionable;
98  }
99 
100  //
101  // FsRtlProcessFileLock acquires FileObject->FsContext->Resource while
102  // modifying the file locks and calls IoCompleteRequest when it's done.
103  //
104 
106 
108  &Fcb->FileLockAnchor,
109  Irp,
110  NULL);
111 
112  if (!NT_SUCCESS(Status))
113  {
115  "FFSLockControl: %-16.16s %-31s *** Status: %s (%#x) ***\n",
117  "IRP_MJ_LOCK_CONTROL",
119  Status));
120  }
121  }
122 
124  {
125  if (!IrpContext->ExceptionInProgress)
126  {
127  if (!CompleteRequest)
128  {
129  IrpContext->Irp = NULL;
130  }
131 
132  FFSCompleteIrpContext(IrpContext, Status);
133  }
134  } _SEH2_END;
135 
136  return Status;
137 }
Definition: ffsdrv.h:281
#define IN
Definition: typedefs.h:38
PCHAR FFSNtStatusToString(IN NTSTATUS Status)
#define TRUE
Definition: types.h:120
#define __drv_mustHoldCriticalRegion
Definition: ffsdrv.h:34
FSRTL_ADVANCED_FCB_HEADER Header
Definition: cdstruc.h:931
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
Definition: ffsdrv.h:283
struct _FFS_FCB * PFFS_FCB
PDEVICE_OBJECT DeviceObject
Definition: ffsdrv.h:371
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
NTFSIDENTIFIER Identifier
Definition: ntfs.h:511
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
#define FFSGetCurrentProcessName()
Definition: ffsdrv.h:1070
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
__drv_mustHoldCriticalRegion NTSTATUS FFSLockControl(IN PFFS_IRP_CONTEXT IrpContext)
Definition: lock.c:30
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
* PFILE_OBJECT
Definition: iotypes.h:1955
NTSTATUS NTAPI CompleteRequest(IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
Definition: dispatch.c:19
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
__drv_mustHoldCriticalRegion NTSTATUS FFSCompleteIrpContext(IN PFFS_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:53
ULONG Type
Definition: ntfs.h:95
Definition: ffsdrv.h:280
#define DBG_ERROR
Definition: ffsdrv.h:1031
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
NTSTATUS NTAPI FsRtlProcessFileLock(IN PFILE_LOCK FileLock, IN PIRP Irp, IN PVOID Context OPTIONAL)
Definition: filelock.c:1153
Status
Definition: gdiplustypes.h:24
#define FFSPrint(arg)
Definition: ffsdrv.h:1047
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
#define DBG_INFO
Definition: ffsdrv.h:1034
#define _SEH2_LEAVE
Definition: filesup.c:20
_In_ PFCB Fcb
Definition: cdprocs.h:151
ULONG Size
Definition: ntfs.h:96
PFFS_GLOBAL FFSGlobal
Definition: init.c:22