VfatCreate函数创建或者打开一个文件。具体实现代码如下:
#001 NTSTATUS
#002 VfatCreate (PVFAT_IRP_CONTEXT IrpContext)
#003 /*
#004 * FUNCTION: Create or open a file
#005 */
#006 {
#007 NTSTATUS Status;
#008
#009 ASSERT(IrpContext);
#010
检查当前上下文里的设备是否与全局里保存的设备一致。
#011 if (IrpContext->DeviceObject == VfatGlobalData->DeviceObject)
#012 {
如果文件系统已经打开,就直接返回。
#013 /* DeviceObject represents FileSystem instead of logical volume */
#014 DPRINT ("FsdCreate called with file system/n");
#015 IrpContext->Irp->IoStatus.Information = FILE_OPENED;
#016 IrpContext->Irp->IoStatus.Status = STATUS_SUCCESS;
#017 IoCompleteRequest (IrpContext->Irp,IO_DISK_INCREMENT);
#018 VfatFreeIrpContext(IrpContext);
#019 return(STATUS_SUCCESS);
#020 }
#021
如果标记为不能等,就直接放到队列里执行。
#022 if (!(IrpContext->Flags & IRPCONTEXT_CANWAIT))
#023 {
#024 return(VfatQueueRequest (IrpContext));
#025 }
#026
#027 IrpContext->Irp->IoStatus.Information = 0;
#028 ExAcquireResourceExclusiveLite (&IrpContext->DeviceExt->DirResource,TRUE);
创建或者打开一个文件。
#029 Status = VfatCreateFile (IrpContext->DeviceObject,IrpContext->Irp);
#030 ExReleaseResourceLite (&IrpContext->DeviceExt->DirResource);
#031
已经完成IPR,设置标记为完成状态。
#032 IrpContext->Irp->IoStatus.Status = Status;
#033 IoCompleteRequest (IrpContext->Irp,
#034 (CCHAR)(NT_SUCCESS(Status) ? IO_DISK_INCREMENT : IO_NO_INCREMENT));
#035 VfatFreeIrpContext(IrpContext);
#036 return(Status);
#037}
原文链接:https://www.f2er.com/react/308399.html