ReactOS  0.4.13-dev-990-g6d23816
lockctl.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: GNU GENERAL PUBLIC LICENSE VERSION 2
3  * PROJECT: ReiserFs file system driver for Windows NT/2000/XP/Vista.
4  * FILE: lockctl.c
5  * PURPOSE:
6  * PROGRAMMER: Mark Piper, Matt Wu, Bo BrantÚn.
7  * HOMEPAGE:
8  * UPDATE HISTORY:
9  */
10 
11 /* INCLUDES *****************************************************************/
12 
13 #include "rfsd.h"
14 
15 /* GLOBALS ***************************************************************/
16 
18 
19 /* DEFINITIONS *************************************************************/
20 
21 #ifdef ALLOC_PRAGMA
22 #pragma alloc_text(PAGE, RfsdLockControl)
23 #endif
24 
27 {
32  PRFSD_FCB Fcb;
33  PIRP Irp;
34 
35  PAGED_CODE();
36 
37  _SEH2_TRY {
38 
39  ASSERT(IrpContext != NULL);
40 
41  ASSERT((IrpContext->Identifier.Type == RFSDICX) &&
42  (IrpContext->Identifier.Size == sizeof(RFSD_IRP_CONTEXT)));
43 
44  DeviceObject = IrpContext->DeviceObject;
45 
47 
51  }
52 
53  FileObject = IrpContext->FileObject;
54 
55  Fcb = (PRFSD_FCB) FileObject->FsContext;
56 
57  ASSERT(Fcb != NULL);
58 
59  if (Fcb->Identifier.Type == RFSDVCB) {
60 
64  }
65 
67  (Fcb->Identifier.Size == sizeof(RFSD_FCB)));
68 
69  if (FlagOn(Fcb->RfsdMcb->FileAttr, FILE_ATTRIBUTE_DIRECTORY)) {
70 
74  }
75 
76  Irp = IrpContext->Irp;
77 
78  //
79  // While the file has any byte range locks we set IsFastIoPossible to
80  // FastIoIsQuestionable so that the FastIoCheckIfPossible function is
81  // called to check the locks for any fast I/O read/write operation.
82  //
83  if (Fcb->Header.IsFastIoPossible != FastIoIsQuestionable) {
84 
86  "RfsdLockControl: %-16.16s %-31s %s\n",
88  "FastIoIsQuestionable",
89  Fcb->AnsiFileName.Buffer
90  ));
91 
92  Fcb->Header.IsFastIoPossible = FastIoIsQuestionable;
93  }
94 
95  //
96  // FsRtlProcessFileLock acquires FileObject->FsContext->Resource while
97  // modifying the file locks and calls IoCompleteRequest when it's done.
98  //
99 
101 
103  &Fcb->FileLockAnchor,
104  Irp,
105  NULL );
106 
107  if (!NT_SUCCESS(Status)) {
109  "RfsdLockControl: %-16.16s %-31s *** Status: %s (%#x) ***\n",
111  "IRP_MJ_LOCK_CONTROL",
113  Status ));
114  }
115 
116  } _SEH2_FINALLY {
117 
118  if (!IrpContext->ExceptionInProgress) {
119  if (!CompleteRequest) {
120  IrpContext->Irp = NULL;
121  }
122 
123  RfsdCompleteIrpContext(IrpContext, Status);
124  }
125  } _SEH2_END;
126 
127  return Status;
128 }
PRFSD_GLOBAL RfsdGlobal
Definition: init.c:17
#define IN
Definition: typedefs.h:38
NTSTATUS RfsdCompleteIrpContext(IN PRFSD_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: memory.c:160
#define TRUE
Definition: types.h:120
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: rfsd.h:323
#define PAGED_CODE()
Definition: video.h:57
PDEVICE_OBJECT DeviceObject
Definition: rfsd.h:407
_SEH2_TRY
Definition: create.c:4250
Definition: rfsd.h:324
NTSTATUS RfsdLockControl(IN PRFSD_IRP_CONTEXT IrpContext)
Definition: lockctl.c:26
PUCHAR RfsdNtStatusToString(IN NTSTATUS Status)
struct _RFSD_FCB * PRFSD_FCB
NTFSIDENTIFIER Identifier
Definition: ntfs.h:511
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
Definition: rfsd.h:326
_Inout_ PFILE_OBJECT FileObject
Definition: cdprocs.h:593
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define RfsdGetCurrentProcessName()
Definition: rfsd.h:1095
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
* PFILE_OBJECT
Definition: iotypes.h:1954
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
#define RfsdPrint(arg)
Definition: rfsd.h:1069
ULONG Type
Definition: ntfs.h:95
#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
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