| 147 | |
| 148 | |
| 149 | NTSTATUS |
| 150 | Ext2PnpQueryRemove ( |
| 151 | PEXT2_IRP_CONTEXT IrpContext, |
| 152 | PEXT2_VCB Vcb |
| 153 | ) |
| 154 | { |
| 155 | NTSTATUS Status = STATUS_SUCCESS; |
| 156 | KEVENT Event; |
| 157 | BOOLEAN bDeleted = FALSE; |
| 158 | BOOLEAN VcbAcquired = FALSE; |
| 159 | |
| 160 | __try { |
| 161 | |
| 162 | CcWaitForCurrentLazyWriterActivity(); |
| 163 | |
| 164 | VcbAcquired = ExAcquireResourceExclusiveLite( |
| 165 | &Vcb->MainResource, TRUE ); |
| 166 | |
| 167 | Ext2FlushFiles(IrpContext, Vcb, FALSE); |
| 168 | Ext2FlushVolume(IrpContext, Vcb, FALSE); |
| 169 | |
| 170 | DEBUG(DL_PNP, ("Ext2PnpQueryRemove: Ext2LockVcb: Vcb=%xh FileObject=%xh ...\n", |
| 171 | Vcb, IrpContext->FileObject)); |
| 172 | Status = Ext2LockVcb(Vcb, IrpContext->FileObject); |
| 173 | |
| 174 | if (VcbAcquired) { |
| 175 | ExReleaseResourceLite(&Vcb->MainResource); |
| 176 | VcbAcquired = FALSE; |
| 177 | } |
| 178 | |
| 179 | DEBUG(DL_PNP, ("Ext2PnpQueryRemove: Ext2PurgeVolume ...\n")); |
| 180 | Ext2PurgeVolume(Vcb, TRUE); |
| 181 | |
| 182 | if (!NT_SUCCESS(Status)) { |
| 183 | __leave; |
| 184 | } |
| 185 | |
| 186 | IoCopyCurrentIrpStackLocationToNext(IrpContext->Irp); |
| 187 | |
| 188 | KeInitializeEvent( &Event, NotificationEvent, FALSE ); |
| 189 | IoSetCompletionRoutine( IrpContext->Irp, |
| 190 | Ext2PnpCompletionRoutine, |
| 191 | &Event, |
| 192 | TRUE, |
| 193 | TRUE, |
| 194 | TRUE ); |
| 195 | |
| 196 | DEBUG(DL_PNP, ("Ext2PnpQueryRemove: Call lower level driver...\n")); |
| 197 | Status = IoCallDriver( Vcb->TargetDeviceObject, |
| 198 | IrpContext->Irp); |
| 199 | |
| 200 | if (Status == STATUS_PENDING) { |
| 201 | KeWaitForSingleObject( &Event, |
| 202 | Executive, |
| 203 | KernelMode, |
| 204 | FALSE, |
| 205 | NULL ); |
| 206 | Status = IrpContext->Irp->IoStatus.Status; |
no test coverage detected