ReactOS 0.4.16-dev-125-g798ea90
lock.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYRIGHT.TXT
3 * PROJECT: Ext2 File System Driver for WinNT/2K/XP
4 * FILE: lock.c
5 * PROGRAMMER: Matt Wu <mattwu@163.com>
6 * HOMEPAGE: http://www.ext2fsd.com
7 * UPDATE HISTORY:
8 */
9
10/* INCLUDES *****************************************************************/
11
12#include "ext2fs.h"
13
14/* GLOBALS ***************************************************************/
15
17
18/* DEFINITIONS *************************************************************/
19
20#ifdef ALLOC_PRAGMA
21#pragma alloc_text(PAGE, Ext2LockControl)
22#endif
23
26{
30 PIRP Irp = NULL;
31
33 BOOLEAN CompleteContext = TRUE;
35 BOOLEAN bFcbAcquired = FALSE;
36
37 _SEH2_TRY {
38
39 ASSERT(IrpContext != NULL);
40
41 ASSERT((IrpContext->Identifier.Type == EXT2ICX) &&
42 (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT)));
43
44 DeviceObject = IrpContext->DeviceObject;
45
49 }
50
51 FileObject = IrpContext->FileObject;
52
53 Fcb = (PEXT2_FCB) FileObject->FsContext;
54 ASSERT(Fcb != NULL);
55 if (Fcb->Identifier.Type == EXT2VCB) {
58 }
59
61 (Fcb->Identifier.Size == sizeof(EXT2_FCB)));
62
63 if (FlagOn(Fcb->Mcb->FileAttr, FILE_ATTRIBUTE_DIRECTORY)) {
66 }
67
69 bFcbAcquired = TRUE;
70
71 Irp = IrpContext->Irp;
72
74
75 Status = FsRtlCheckOplock( &Fcb->Oplock,
76 Irp,
77 IrpContext,
79 NULL );
80
81 if (Status != STATUS_SUCCESS) {
82 CompleteContext = FALSE;
84 }
85
86 //
87 // FsRtlProcessFileLock acquires FileObject->FsContext->Resource while
88 // modifying the file locks and calls IoCompleteRequest when it's done.
89 //
90
92 &Fcb->FileLockAnchor,
93 Irp,
94 NULL );
95#if EXT2_DEBUG
96 if (!NT_SUCCESS(Status)) {
97 DEBUG(DL_ERR, (
98 "Ext2LockControl: %-16.16s %-31s Status: %#x ***\n",
100 "IRP_MJ_LOCK_CONTROL",
101 Status ));
102 }
103#endif
104 Fcb->Header.IsFastIoPossible = Ext2IsFastIoPossible(Fcb);
105
106 } _SEH2_FINALLY {
107
108 if (bFcbAcquired) {
110 }
111
112 if (!IrpContext->ExceptionInProgress) {
113
114 if (!CompleteIrp) {
115 IrpContext->Irp = NULL;
116 }
117
118 if (CompleteContext) {
119 Ext2CompleteIrpContext(IrpContext, Status);
120 }
121 }
122 } _SEH2_END;
123
124 return Status;
125}
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define DEBUG(args)
Definition: rdesktop.h:129
_In_ PFCB Fcb
Definition: cdprocs.h:159
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
PEXT2_GLOBAL Ext2Global
Definition: init.c:16
NTSTATUS Ext2LockControl(IN PEXT2_IRP_CONTEXT IrpContext)
Definition: lock.c:25
VOID CompleteIrp(IN PIRP Irp, IN NTSTATUS Status, IN ULONG_PTR Information)
Definition: pnp.c:12
#define ExAcquireResourceSharedLite(res, wait)
Definition: env_spec_w32.h:621
#define Ext2GetCurrentProcessName()
Definition: ext2fs.h:1489
#define FlagOn(_F, _SF)
Definition: ext2fs.h:179
VOID Ext2OplockComplete(IN PVOID Context, IN PIRP Irp)
Definition: dispatch.c:45
@ EXT2FCB
Definition: ext2fs.h:463
@ EXT2ICX
Definition: ext2fs.h:465
@ EXT2VCB
Definition: ext2fs.h:462
#define IsExt2FsDevice(DO)
Definition: ext2fs.h:616
#define DL_ERR
Definition: ext2fs.h:1434
struct _EXT2_FCB * PEXT2_FCB
NTSTATUS Ext2CompleteIrpContext(IN PEXT2_IRP_CONTEXT IrpContext, IN NTSTATUS Status)
Definition: read.c:32
FAST_IO_POSSIBLE Ext2IsFastIoPossible(IN PEXT2_FCB Fcb)
Definition: fastio.c:38
NTSTATUS NTAPI FsRtlProcessFileLock(IN PFILE_LOCK FileLock, IN PIRP Irp, IN PVOID Context OPTIONAL)
Definition: filelock.c:1152
#define _SEH2_FINALLY
Definition: filesup.c:21
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
#define _SEH2_LEAVE
Definition: filesup.c:20
Status
Definition: gdiplustypes.h:25
#define ASSERT(a)
Definition: mode.c:44
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
VOID FASTCALL ExReleaseResourceLite(IN PERESOURCE Resource)
Definition: resource.c:1822
NTSTATUS NTAPI FsRtlCheckOplock(IN POPLOCK Oplock, IN PIRP Irp, IN PVOID Context, IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL)
Definition: oplock.c:1170
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG Type
Definition: ntfs.h:95
ULONG Size
Definition: ntfs.h:96
CD_MCB Mcb
Definition: cdstruc.h:1016
NTFSIDENTIFIER Identifier
Definition: ntfs.h:515
FSRTL_ADVANCED_FCB_HEADER Header
Definition: cdstruc.h:925
ERESOURCE MainResource
Definition: ntfs.h:528
#define IN
Definition: typedefs.h:39
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
* PFILE_OBJECT
Definition: iotypes.h:1998