22#define UDF_BUG_CHECK_ID UDF_FILE_CLEANUP
62 Irp->IoStatus.Status = RC;
63 Irp->IoStatus.Information = 0;
66 UDFPrint((
"Deregister Autoformat\n"));
86 Irp->IoStatus.Status = RC;
87 Irp->IoStatus.Information = 0;
159 TmPrint((
"UDFCommonCleanup\n"));
182 AdPrint((
" %s\n", CanWait ?
"Wt" :
"nw"));
200 AdPrint((
"Cleaning up Volume\n"));
222 Vcb->VolumeLockFileObject =
NULL;
223 Vcb->VolumeLockPID = -1;
224 Vcb->VCBFlags &= ~UDF_VCB_FLAGS_VOLUME_LOCKED;
225 Vcb->Vpb->Flags &= ~VPB_LOCKED;
229 MmPrint((
" CcUninitializeCacheMap()\n"));
253 AdPrint((
"Cleaning up file: ??? \n"));
259 if(
Fcb->FileInfo->ParentFile) {
265 AcquiredParentFCB =
TRUE;
279#ifndef UDF_READ_ONLY_BUILD
305#ifndef UDF_READ_ONLY_BUILD
325 if(
Fcb->FileInfo->ParentFile) {
331 AcquiredParentFCB =
FALSE;
339#ifdef UDF_DELAYED_CLOSE
347 if(
Fcb->FileInfo->ParentFile) {
353 AcquiredParentFCB =
TRUE;
365 NtReqFcb->CommonFCBHeader.FileSize.QuadPart =
366 NtReqFcb->CommonFCBHeader.ValidDataLength.QuadPart = 0;
374#ifdef UDF_DELAYED_CLOSE
375 if ((
Fcb->ReferenceCount == 1) &&
382 NextFileInfo =
Fcb->FileInfo;
384#ifndef UDF_READ_ONLY_BUILD
394 Fcb->FCBFlags &= ~UDF_FCB_DELETE_ON_CLOSE;
405 if(AcquiredPagingIo) {
418 AdPrint((
"Error flushing file !!!\n"));
430 if(NextFileInfo->
Dloc &&
449 goto DiscardDelete_1;
456 ForcedCleanUp =
TRUE;
458 Fcb->FCBFlags &= ~UDF_FCB_DELETE_ON_CLOSE;
496 ForcedCleanUp =
FALSE;
500 (
NtReqFcb->SectionObject.DataSectionObject) ) {
501 BOOLEAN LastNonCached = (!
Fcb->CachedOpenHandleCount &&
514#ifndef UDF_READ_ONLY_BUILD
517 if( (OldFileSize =
NtReqFcb->CommonFCBHeader.ValidDataLength.QuadPart) <
527 MmPrint((
" CcFlushCache()\n"));
536 if(ForcedCleanUp || LastNonCached) {
537 if(
NtReqFcb->SectionObject.DataSectionObject) {
538 MmPrint((
" CcPurgeCacheSection()\n"));
547#ifndef UDF_READ_ONLY_BUILD
589 NtReqFcb->CommonFCBHeader.AllocationSize.QuadPart;
617 MmPrint((
" CcUninitializeCacheMap()\n"));
620 MmPrint((
" CcUninitializeCacheMap()\n"));
630 if(
Fcb->FileInfo->ParentFile) {
636 AcquiredParentFCB =
FALSE;
663 if(AcquiredParentFCB) {
664 if(
Fcb->FileInfo->ParentFile) {
679 Irp->IoStatus.Status = RC;
680 Irp->IoStatus.Information = 0;
713 AdPrint((
"UDFCloseFileInfoChain\n"));
714 for(; TreeLength && fi; TreeLength--) {
731 AdPrint((
"Acquiring VCB...\n"));
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
VOID UDFSetFileXTime(IN PUDF_FILE_INFO FileInfo, IN LONGLONG *CrtTime, IN LONGLONG *AccTime, IN LONGLONG *AttrTime, IN LONGLONG *ChgTime)
VOID UDFAttributesToUDF(IN PDIR_INDEX_ITEM FileDirNdx, IN tag *FileEntry, IN ULONG NTAttr)
ULONG UDFAttributesToNT(IN PDIR_INDEX_ITEM FileDirNdx, IN tag *FileEntry)
VOID NTAPI CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, OUT OPTIONAL PIO_STATUS_BLOCK IoStatus)
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
NTSTATUS NTAPI UDFCleanup(PDEVICE_OBJECT DeviceObject, PIRP Irp)
NTSTATUS UDFCommonCleanup(PtrUDFIrpContext PtrIrpContext, PIRP Irp)
NTSTATUS UDFCloseFileInfoChain(IN PVCB Vcb, IN PUDF_FILE_INFO fi, IN ULONG TreeLength, IN BOOLEAN VcbAcquired)
PDIR_INDEX_HDR UDFGetDirIndexByFileInfo(IN PUDF_FILE_INFO FileInfo)
#define NT_SUCCESS(StatCode)
_In_ PIO_STACK_LOCATION IrpSp
NTSTATUS UDFExceptionHandler(PtrUDFIrpContext PtrIrpContext, PIRP Irp)
BOOLEAN UDFAcquireResourceExclusiveWithCheck(IN PERESOURCE Resource)
BOOLEAN __fastcall UDFIsIrpTopLevel(PIRP Irp)
VOID UDFLogEvent(NTSTATUS UDFEventLogId, NTSTATUS RC)
PtrUDFIrpContext UDFAllocateIrpContext(PIRP Irp, PDEVICE_OBJECT PtrTargetDeviceObject)
VOID UDFReleaseIrpContext(PtrUDFIrpContext PtrIrpContext)
long UDFExceptionFilter(PtrUDFIrpContext PtrIrpContext, PEXCEPTION_POINTERS PtrExceptionPointers)
#define UDFNotifyVolumeEvent(FileObject, EventCode)
__inline VOID UDFNotifyFullReportChange(PVCB V, PUDF_FILE_INFO FI, ULONG E, ULONG A)
#define UDFReleaseResource(Resource)
#define ValidateFileInfo(fi)
#define UDFAcquireResourceShared(Resource, CanWait)
#define UDFAcquireResourceExclusive(Resource, CanWait)
#define KeQuerySystemTime(t)
#define UDFInterlockedDecrement(addr)
#define UDF_ERROR_INTERNAL_ERROR
FAST_IO_POSSIBLE NTAPI UDFIsFastIoPossible(IN PtrUDFFCB Fcb)
_In_ PLARGE_INTEGER NtTime
NTSTATUS UDFMarkStreamsForDeletion(IN PVCB Vcb, IN PtrUDFFCB Fcb, IN BOOLEAN ForDel)
NTSTATUS NTAPI FsRtlFastUnlockAll(IN PFILE_LOCK FileLock, IN PFILE_OBJECT FileObject, IN PEPROCESS Process, IN PVOID Context OPTIONAL)
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
VOID NTAPI CcSetFileSizes(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes)
BOOLEAN NTAPI CcUninitializeCacheMap(IN PFILE_OBJECT FileObject, IN OPTIONAL PLARGE_INTEGER TruncateSize, IN OPTIONAL PCACHE_UNINITIALIZE_EVENT UninitializeEvent)
BOOLEAN NTAPI CcPurgeCacheSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN UninitializeCacheMaps)
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
#define FILE_ATTRIBUTE_ARCHIVE
#define FSRTL_VOLUME_UNLOCK
VOID NTAPI FsRtlNotifyCleanup(IN PNOTIFY_SYNC NotifySync, IN PLIST_ENTRY NotifyList, IN PVOID FsContext)
VOID NTAPI FsRtlNotifyFullChangeDirectory(IN PNOTIFY_SYNC NotifySync, IN PLIST_ENTRY NotifyList, IN PVOID FsContext, IN PSTRING FullDirectoryName, IN BOOLEAN WatchTree, IN BOOLEAN IgnoreBuffer, IN ULONG CompletionFilter, IN PIRP NotifyIrp, IN PCHECK_FOR_TRAVERSE_ACCESS TraverseCallback OPTIONAL, IN PSECURITY_SUBJECT_CONTEXT SubjectContext OPTIONAL)
VOID NTAPI IoRemoveShareAccess(IN PFILE_OBJECT FileObject, IN PSHARE_ACCESS ShareAccess)
#define IoCompleteRequest
PEPROCESS NTAPI IoGetRequestorProcess(IN PIRP Irp)
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
OSSTATUS UDFResetDeviceDriver(IN PVCB Vcb, IN PDEVICE_OBJECT TargetDeviceObject, IN BOOLEAN Unlock)
NTSTATUS UDFWriteSecurity(IN PVCB Vcb, IN PtrUDFFCB Fcb, IN PSECURITY_DESCRIPTOR *SecurityDesc)
#define UDFRemoveFromSystemDelayedQueue(Fcb)
#define UDFRemoveFromDelayedQueue(Fcb)
#define _SEH2_AbnormalTermination()
#define _SEH2_EXCEPT(...)
#define _SEH2_GetExceptionInformation()
#define STATUS_CANNOT_DELETE
#define UDF_NODE_TYPE_NT_REQ_FCB
#define UDF_CCB_CREATE_TIME_SET
#define UDF_CCB_ATTRIBUTES_SET
#define UDF_IRP_CONTEXT_CAN_BLOCK
struct _UDFContextControlBlock * PtrUDFCCB
#define UDF_CCB_ACCESS_TIME_SET
#define UDF_FCB_ROOT_DIRECTORY
#define UDF_NTREQ_FCB_DELETED
#define UDF_NODE_TYPE_FCB
#define UDF_CCB_MODIFY_TIME_SET
#define UDF_NODE_TYPE_VCB
#define UDF_FCB_DELETE_ON_CLOSE
#define UDF_FCB_DIRECTORY
#define UDF_FCB_DELETE_PARENT
#define UDF_FCB_DELAY_CLOSE
#define UDF_CCB_WRITE_TIME_SET
#define UDF_CCB_DELETE_ON_CLOSE
struct _FCB::@729::@732 Fcb
PDEVICE_OBJECT TargetDeviceObject
struct _UDF_FILE_INFO * SDirInfo
struct _UDF_FILE_INFO * ParentFile
#define UDF_VCB_IC_UPDATE_MODIFY_TIME
#define UDF_VCB_FLAGS_VOLUME_MOUNTED
#define UDF_VCB_IC_UPDATE_ATTR_TIME
#define UDF_VCB_FLAGS_VOLUME_READ_ONLY
#define UDF_VCB_IC_UPDATE_ARCH_BIT
#define UDF_VCB_IC_UPDATE_ACCESS_TIME
#define UDF_VCB_FLAGS_OUR_DEVICE_DRIVER
uint16 UDFGetFileLinkCount(IN PUDF_FILE_INFO FileInfo)
OSSTATUS UDFCloseFile__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo)
OSSTATUS UDFFlushFile__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN ULONG FlushFlags)
OSSTATUS UDFUnlinkFile__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN BOOLEAN FreeSpace)
void UDFSetFileSizeInDirNdx(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN int64 *ASize)
OSSTATUS UDFResizeFile__(IN PVCB Vcb, IN OUT PUDF_FILE_INFO FileInfo, IN int64 NewLength)
OSSTATUS UDFPretendFileDeleted__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo)
#define UDFIsSDirDeleted(FI)
#define UDFGetFileAllocationSize(Vcb, FileInfo)
#define UDFIsDirEmpty__(fi)
__inline PDIR_INDEX_ITEM UDFDirIndex(IN PDIR_INDEX_HDR hDirNdx, IN uint_di i)
#define UDFIsAStreamDir(FI)
#define UDFIsADirectory(FileInfo)
#define STATUS_INVALID_PARAMETER
#define STATUS_INSUFFICIENT_RESOURCES
#define UDF_CHECK_PAGING_IO_RESOURCE(NTReqFCB)
_In_ PDEVICE_OBJECT DeviceObject
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
#define FILE_ACTION_MODIFIED_STREAM
#define FILE_ACTION_MODIFIED
#define FO_FILE_FAST_IO_READ
#define FILE_NOTIFY_CHANGE_STREAM_NAME
#define FILE_ACTION_REMOVED_STREAM
#define FILE_NOTIFY_CHANGE_LAST_ACCESS
#define FILE_NOTIFY_CHANGE_ATTRIBUTES
#define FILE_ACTION_REMOVED
#define FILE_NOTIFY_CHANGE_FILE_NAME
#define FO_CLEANUP_COMPLETE
#define FO_FILE_SIZE_CHANGED
#define IO_DISK_INCREMENT
#define FO_CACHE_SUPPORTED
#define FILE_NOTIFY_CHANGE_LAST_WRITE
#define FILE_NOTIFY_CHANGE_DIR_NAME
_In_opt_ PLARGE_INTEGER NewFileSize