| 133 | |
| 134 | |
| 135 | NTSTATUS |
| 136 | Ext2LockVolume (IN PEXT2_IRP_CONTEXT IrpContext) |
| 137 | { |
| 138 | PIO_STACK_LOCATION IrpSp; |
| 139 | PDEVICE_OBJECT DeviceObject; |
| 140 | PEXT2_VCB Vcb = NULL; |
| 141 | NTSTATUS Status; |
| 142 | BOOLEAN VcbResourceAcquired = FALSE; |
| 143 | |
| 144 | __try { |
| 145 | |
| 146 | ASSERT(IrpContext != NULL); |
| 147 | |
| 148 | ASSERT((IrpContext->Identifier.Type == EXT2ICX) && |
| 149 | (IrpContext->Identifier.Size == sizeof(EXT2_IRP_CONTEXT))); |
| 150 | |
| 151 | DeviceObject = IrpContext->DeviceObject; |
| 152 | |
| 153 | Status = STATUS_UNSUCCESSFUL; |
| 154 | |
| 155 | // |
| 156 | // This request is not allowed on the main device object |
| 157 | // |
| 158 | if (IsExt2FsDevice(DeviceObject)) { |
| 159 | Status = STATUS_INVALID_PARAMETER; |
| 160 | __leave; |
| 161 | } |
| 162 | |
| 163 | Vcb = (PEXT2_VCB) DeviceObject->DeviceExtension; |
| 164 | |
| 165 | ASSERT(Vcb != NULL); |
| 166 | |
| 167 | ASSERT((Vcb->Identifier.Type == EXT2VCB) && |
| 168 | (Vcb->Identifier.Size == sizeof(EXT2_VCB))); |
| 169 | |
| 170 | ASSERT(IsMounted(Vcb)); |
| 171 | |
| 172 | IrpSp = IoGetCurrentIrpStackLocation(IrpContext->Irp); |
| 173 | |
| 174 | #if (_WIN32_WINNT >= 0x0500) |
| 175 | CcWaitForCurrentLazyWriterActivity(); |
| 176 | #endif |
| 177 | ExAcquireResourceExclusiveLite( |
| 178 | &Vcb->MainResource, |
| 179 | TRUE ); |
| 180 | |
| 181 | VcbResourceAcquired = TRUE; |
| 182 | |
| 183 | /* flush dirty data before locking the volume */ |
| 184 | if (!IsVcbReadOnly(Vcb)) { |
| 185 | Ext2FlushFiles(IrpContext, Vcb, FALSE); |
| 186 | Ext2FlushVolume(IrpContext, Vcb, FALSE); |
| 187 | } |
| 188 | |
| 189 | Status = Ext2LockVcb(Vcb, IrpSp->FileObject); |
| 190 | |
| 191 | } __finally { |
| 192 |
no test coverage detected