ReactOS 0.4.15-dev-7889-g76290a6
protos.h File Reference
#include "mem.h"
#include "namesup.h"
Include dependency graph for protos.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define UDF_CLOSE_NTREQFCB_DELETED   0x01
 
#define UDF_CLOSE_FCB_DELETED   0x02
 
#define UDFCloseAllDelayedInDir(Vcb, FI)    UDFCloseAllXXXDelayedInDir(Vcb,FI,FALSE);
 
#define UDFCloseAllSystemDelayedInDir(Vcb, FI)    UDFCloseAllXXXDelayedInDir(Vcb,FI,TRUE);
 
#define UDFRemoveFromDelayedQueue(Fcb)    UDFCloseAllDelayedInDir((Fcb)->Vcb, (Fcb)->FileInfo)
 
#define UDFRemoveFromSystemDelayedQueue(Fcb)    UDFCloseAllSystemDelayedInDir((Fcb)->Vcb, (Fcb)->FileInfo)
 
#define UDFRemoveFileId__(Vcb, fi)    UDFRemoveFileId(Vcb, UDFGetNTFileId(Vcb, fi, &(fi->Fcb->FCBName->ObjectName)));
 
#define UDFZeroDataEx(NtReqFcb, Offset, Length, CanWait, Vcb, FileObject)    UDFPurgeCacheEx_(NtReqFcb, Offset, Length, CanWait, Vcb, FileObject)
 
#define UDFPurgeCacheEx(NtReqFcb, Offset, Length, CanWait, Vcb, FileObject)    UDFPurgeCacheEx_(NtReqFcb, Offset, Length, CanWait, Vcb, FileObject)
 

Functions

NTSTATUS NTAPI UDFCreate (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS UDFCommonCreate (IN PtrUDFIrpContext PtrIrpContext, IN PIRP Irp)
 
NTSTATUS UDFFirstOpenFile (IN PVCB Vcb, IN PFILE_OBJECT PtrNewFileObject, OUT PtrUDFFCB *PtrNewFcb, IN PUDF_FILE_INFO RelatedFileInfo, IN PUDF_FILE_INFO NewFileInfo, IN PUNICODE_STRING LocalPath, IN PUNICODE_STRING CurName)
 
NTSTATUS UDFOpenFile (IN PVCB Vcb, IN PFILE_OBJECT PtrNewFileObject, IN PtrUDFFCB PtrNewFcb)
 
NTSTATUS UDFInitializeFCB (IN PtrUDFFCB PtrNewFcb, IN PVCB Vcb, IN PtrUDFObjectName PtrObjectName, IN ULONG Flags, IN PFILE_OBJECT FileObject)
 
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)
 
NTSTATUS NTAPI UDFClose (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS UDFCommonClose (PtrUDFIrpContext PtrIrpContext, PIRP Irp)
 
ULONG UDFCleanUpFcbChain (IN PVCB Vcb, IN PUDF_FILE_INFO fi, IN ULONG TreeLength, IN BOOLEAN VcbAcquired)
 
VOID UDFCloseAllDelayed (PVCB Vcb)
 
VOID NTAPI UDFDelayedClose (PVOID unused=NULL)
 
NTSTATUS UDFCloseAllXXXDelayedInDir (IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN BOOLEAN System)
 
NTSTATUS UDFQueueDelayedClose (PtrUDFIrpContext IrpContext, PtrUDFFCB Fcb)
 
NTSTATUS NTAPI UDFDirControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI UDFCommonDirControl (PtrUDFIrpContext PtrIrpContext, PIRP Irp)
 
NTSTATUS NTAPI UDFQueryDirectory (PtrUDFIrpContext PtrIrpContext, PIRP Irp, PIO_STACK_LOCATION IrpSp, PFILE_OBJECT FileObject, PtrUDFFCB Fcb, PtrUDFCCB Ccb)
 
NTSTATUS NTAPI UDFNotifyChangeDirectory (PtrUDFIrpContext PtrIrpContext, PIRP Irp, PIO_STACK_LOCATION IrpSp, PFILE_OBJECT FileObject, PtrUDFFCB Fcb, PtrUDFCCB Ccb)
 
NTSTATUS NTAPI UDFDeviceControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI UDFCommonDeviceControl (PtrUDFIrpContext PtrIrpContext, PIRP Irp)
 
NTSTATUS NTAPI UDFDevIoctlCompletion (PDEVICE_OBJECT PtrDeviceObject, PIRP Irp, PVOID Context)
 
NTSTATUS NTAPI UDFHandleQueryPath (PVOID BufferPointer)
 
BOOLEAN NTAPI UDFFastIoCheckIfPossible (IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN Wait, IN ULONG LockKey, IN BOOLEAN CheckForReadOperation, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
 
FAST_IO_POSSIBLE NTAPI UDFIsFastIoPossible (IN PtrUDFFCB Fcb)
 
BOOLEAN NTAPI UDFFastIoQueryBasicInfo (IN PFILE_OBJECT FileObject, IN BOOLEAN Wait, OUT PFILE_BASIC_INFORMATION Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
 
BOOLEAN NTAPI UDFFastIoQueryStdInfo (IN PFILE_OBJECT FileObject, IN BOOLEAN Wait, OUT PFILE_STANDARD_INFORMATION Buffer, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
 
VOID NTAPI UDFFastIoAcqCreateSec (IN PFILE_OBJECT FileObject)
 
VOID NTAPI UDFFastIoRelCreateSec (IN PFILE_OBJECT FileObject)
 
BOOLEAN NTAPI UDFAcqLazyWrite (IN PVOID Context, IN BOOLEAN Wait)
 
VOID NTAPI UDFRelLazyWrite (IN PVOID Context)
 
BOOLEAN NTAPI UDFAcqReadAhead (IN PVOID Context, IN BOOLEAN Wait)
 
VOID NTAPI UDFRelReadAhead (IN PVOID Context)
 
VOID NTAPI UDFDriverUnload (IN PDRIVER_OBJECT DriverObject)
 
NTSTATUS NTAPI UDFFileInfo (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS UDFCommonFileInfo (PtrUDFIrpContext PtrIrpContext, PIRP Irp)
 
NTSTATUS UDFGetBasicInformation (IN PFILE_OBJECT FileObject, IN PtrUDFFCB Fcb, IN PFILE_BASIC_INFORMATION PtrBuffer, IN OUT LONG *PtrReturnedLength)
 
NTSTATUS UDFGetNetworkInformation (IN PtrUDFFCB Fcb, IN PFILE_NETWORK_OPEN_INFORMATION PtrBuffer, IN OUT PLONG PtrReturnedLength)
 
NTSTATUS UDFGetStandardInformation (IN PtrUDFFCB Fcb, IN PFILE_STANDARD_INFORMATION PtrBuffer, IN OUT PLONG PtrReturnedLength)
 
NTSTATUS UDFGetInternalInformation (PtrUDFIrpContext PtrIrpContext, IN PtrUDFFCB Fcb, IN PtrUDFCCB Ccb, IN PFILE_INTERNAL_INFORMATION PtrBuffer, IN OUT PLONG PtrReturnedLength)
 
NTSTATUS UDFGetEaInformation (PtrUDFIrpContext PtrIrpContext, IN PtrUDFFCB Fcb, IN PFILE_EA_INFORMATION PtrBuffer, IN OUT PLONG PtrReturnedLength)
 
NTSTATUS UDFGetFullNameInformation (IN PFILE_OBJECT FileObject, IN PFILE_NAME_INFORMATION PtrBuffer, IN OUT PLONG PtrReturnedLength)
 
NTSTATUS UDFGetAltNameInformation (IN PtrUDFFCB Fcb, IN PFILE_NAME_INFORMATION PtrBuffer, IN OUT PLONG PtrReturnedLength)
 
NTSTATUS UDFGetPositionInformation (IN PFILE_OBJECT FileObject, IN PFILE_POSITION_INFORMATION PtrBuffer, IN OUT PLONG PtrReturnedLength)
 
NTSTATUS UDFGetFileStreamInformation (IN PtrUDFFCB Fcb, IN PFILE_STREAM_INFORMATION PtrBuffer, IN OUT PLONG PtrReturnedLength)
 
NTSTATUS UDFSetBasicInformation (IN PtrUDFFCB Fcb, IN PtrUDFCCB Ccb, IN PFILE_OBJECT FileObject, IN PFILE_BASIC_INFORMATION PtrBuffer)
 
NTSTATUS UDFMarkStreamsForDeletion (IN PVCB Vcb, IN PtrUDFFCB Fcb, IN BOOLEAN ForDel)
 
NTSTATUS UDFSetDispositionInformation (IN PtrUDFFCB Fcb, IN PtrUDFCCB Ccb, IN PVCB Vcb, IN PFILE_OBJECT FileObject, IN BOOLEAN Delete)
 
NTSTATUS UDFSetAllocationInformation (IN PtrUDFFCB Fcb, IN PtrUDFCCB Ccb, IN PVCB Vcb, IN PFILE_OBJECT FileObject, IN PtrUDFIrpContext PtrIrpContext, IN PIRP Irp, IN PFILE_ALLOCATION_INFORMATION PtrBuffer)
 
NTSTATUS UDFSetEOF (IN PIO_STACK_LOCATION PtrSp, IN PtrUDFFCB Fcb, IN PtrUDFCCB Ccb, IN PVCB Vcb, IN PFILE_OBJECT FileObject, IN PIRP Irp, IN PFILE_END_OF_FILE_INFORMATION PtrBuffer)
 
NTSTATUS UDFRename (IN PIO_STACK_LOCATION IrpSp, IN PtrUDFFCB Fcb, IN PtrUDFCCB Ccb, IN PFILE_OBJECT FileObject, IN PFILE_RENAME_INFORMATION PtrBuffer)
 
NTSTATUS UDFStoreFileId (IN PVCB Vcb, IN PtrUDFCCB Ccb, IN PUDF_FILE_INFO fi, IN LONGLONG Id)
 
NTSTATUS UDFRemoveFileId (IN PVCB Vcb, IN LONGLONG Id)
 
VOID UDFReleaseFileIdCache (IN PVCB Vcb)
 
NTSTATUS UDFGetOpenParamsByFileId (IN PVCB Vcb, IN LONGLONG Id, OUT PUNICODE_STRING *FName, OUT BOOLEAN *CaseSens)
 
NTSTATUS UDFHardLink (IN PIO_STACK_LOCATION PtrSp, IN PtrUDFFCB Fcb1, IN PtrUDFCCB Ccb1, IN PFILE_OBJECT FileObject1, IN PFILE_LINK_INFORMATION PtrBuffer)
 
NTSTATUS NTAPI UDFFlush (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS UDFCommonFlush (PtrUDFIrpContext PtrIrpContext, PIRP Irp)
 
ULONG UDFFlushAFile (PtrUDFFCB Fcb, PtrUDFCCB Ccb, PIO_STATUS_BLOCK PtrIoStatus, IN ULONG FlushFlags=0)
 
ULONG UDFFlushADirectory (IN PVCB Vcb, IN PUDF_FILE_INFO FI, OUT PIO_STATUS_BLOCK PtrIoStatus, ULONG FlushFlags=0)
 
ULONG UDFFlushLogicalVolume (PtrUDFIrpContext PtrIrpContext, PIRP Irp, PVCB Vcb, ULONG FlushFlags=0)
 
NTSTATUS NTAPI UDFFlushCompletion (PDEVICE_OBJECT PtrDeviceObject, PIRP Irp, PVOID Context)
 
BOOLEAN UDFFlushIsBreaking (IN PVCB Vcb, IN ULONG FlushFlags=0)
 
VOID UDFFlushTryBreak (IN PVCB Vcb)
 
NTSTATUS NTAPI UDFFSControl (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS NTAPI UDFCommonFSControl (PtrUDFIrpContext PtrIrpContext, PIRP Irp)
 
NTSTATUS NTAPI UDFUserFsCtrlRequest (PtrUDFIrpContext PtrIrpContext, PIRP Irp)
 
NTSTATUS NTAPI UDFMountVolume (PtrUDFIrpContext PtrIrpContext, PIRP Irp)
 
NTSTATUS UDFStartEjectWaiter (IN PVCB Vcb)
 
VOID UDFScanForDismountedVcb (IN PtrUDFIrpContext IrpContext)
 
NTSTATUS UDFCompleteMount (IN PVCB Vcb)
 
VOID UDFCloseResidual (IN PVCB Vcb)
 
VOID UDFCleanupVCB (IN PVCB Vcb)
 
NTSTATUS UDFIsVolumeMounted (IN PtrUDFIrpContext IrpContext, IN PIRP Irp)
 
NTSTATUS UDFIsVolumeDirty (IN PtrUDFIrpContext IrpContext, IN PIRP Irp)
 
NTSTATUS UDFGetStatistics (IN PtrUDFIrpContext IrpContext, IN PIRP Irp)
 
NTSTATUS UDFLockVolume (IN PtrUDFIrpContext IrpContext, IN PIRP Irp, IN ULONG PID=-1)
 
NTSTATUS UDFUnlockVolume (IN PtrUDFIrpContext IrpContext, IN PIRP Irp, IN ULONG PID=-1)
 
NTSTATUS UDFIsPathnameValid (IN PtrUDFIrpContext IrpContext, IN PIRP Irp)
 
NTSTATUS UDFDismountVolume (IN PtrUDFIrpContext IrpContext, IN PIRP Irp)
 
NTSTATUS UDFGetVolumeBitmap (IN PtrUDFIrpContext IrpContext, IN PIRP Irp)
 
NTSTATUS UDFGetRetrievalPointers (IN PtrUDFIrpContext IrpContext, IN PIRP Irp, IN ULONG Special)
 
NTSTATUS UDFInvalidateVolumes (IN PtrUDFIrpContext IrpContext, IN PIRP Irp)
 
NTSTATUS NTAPI UDFLockControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI UDFCommonLockControl (IN PtrUDFIrpContext PtrIrpContext, IN PIRP Irp)
 
BOOLEAN NTAPI UDFFastLock (IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, PEPROCESS ProcessId, ULONG Key, BOOLEAN FailImmediately, BOOLEAN ExclusiveLock, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
 
BOOLEAN NTAPI UDFFastUnlockSingle (IN PFILE_OBJECT FileObject, IN PLARGE_INTEGER FileOffset, IN PLARGE_INTEGER Length, PEPROCESS ProcessId, ULONG Key, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
 
BOOLEAN NTAPI UDFFastUnlockAll (IN PFILE_OBJECT FileObject, PEPROCESS ProcessId, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
 
BOOLEAN NTAPI UDFFastUnlockAllByKey (IN PFILE_OBJECT FileObject, PEPROCESS ProcessId, ULONG Key, OUT PIO_STATUS_BLOCK IoStatus, IN PDEVICE_OBJECT DeviceObject)
 
NTSTATUS UDFInitializeZones (VOID)
 
VOID UDFDestroyZones (VOID)
 
BOOLEAN __fastcall UDFIsIrpTopLevel (PIRP Irp)
 
long UDFExceptionFilter (PtrUDFIrpContext PtrIrpContext, PEXCEPTION_POINTERS PtrExceptionPointers)
 
NTSTATUS UDFExceptionHandler (PtrUDFIrpContext PtrIrpContext, PIRP Irp)
 
VOID UDFLogEvent (NTSTATUS UDFEventLogId, NTSTATUS RC)
 
PtrUDFObjectName UDFAllocateObjectName (VOID)
 
VOID __fastcall UDFReleaseObjectName (PtrUDFObjectName PtrObjectName)
 
PtrUDFCCB UDFAllocateCCB (VOID)
 
VOID __fastcall UDFReleaseCCB (PtrUDFCCB Ccb)
 
VOID __fastcall UDFCleanUpCCB (PtrUDFCCB Ccb)
 
PtrUDFFCB UDFAllocateFCB (VOID)
 
__inline VOID UDFReleaseFCB (PtrUDFFCB Fcb)
 
VOID __fastcall UDFCleanUpFCB (PtrUDFFCB Fcb)
 
PtrUDFIrpContext UDFAllocateIrpContext (PIRP Irp, PDEVICE_OBJECT PtrTargetDeviceObject)
 
VOID UDFReleaseIrpContext (PtrUDFIrpContext PtrIrpContext)
 
NTSTATUS UDFPostRequest (PtrUDFIrpContext PtrIrpContext, PIRP Irp)
 
VOID NTAPI UDFCommonDispatch (VOID *Context)
 
NTSTATUS UDFInitializeVCB (PDEVICE_OBJECT PtrVolumeDeviceObject, PDEVICE_OBJECT PtrTargetDeviceObject, PVPB PtrVPB)
 
VOID UDFReadRegKeys (PVCB Vcb, BOOLEAN Update, BOOLEAN UseCfg)
 
ULONG UDFGetRegParameter (IN PVCB Vcb, IN PCWSTR Name, IN ULONG DefValue=0)
 
ULONG UDFGetCfgParameter (IN PVCB Vcb, IN PCWSTR Name, IN ULONG DefValue)
 
VOID UDFReleaseVCB (PVCB Vcb)
 
ULONG UDFRegCheckParameterValue (IN PUNICODE_STRING RegistryPath, IN PCWSTR Name, IN PUNICODE_STRING PtrVolumePath, IN PCWSTR DefaultPath, IN ULONG DefValue=0)
 
VOID UDFInitializeIrpContextFromLite (OUT PtrUDFIrpContext *IrpContext, IN PtrUDFIrpContextLite IrpContextLite)
 
NTSTATUS UDFInitializeIrpContextLite (OUT PtrUDFIrpContextLite *IrpContextLite, IN PtrUDFIrpContext IrpContext, IN PtrUDFFCB Fcb)
 
NTSTATUS NTAPI UDFQuerySetEA (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
ULONG UDFIsResourceAcquired (IN PERESOURCE Resource)
 
BOOLEAN UDFAcquireResourceExclusiveWithCheck (IN PERESOURCE Resource)
 
BOOLEAN UDFAcquireResourceSharedWithCheck (IN PERESOURCE Resource)
 
NTSTATUS UDFWCacheErrorHandler (IN PVOID Context, IN PWCACHE_ERROR_CONTEXT ErrorInfo)
 
NTSTATUS UDFPnp (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
OSSTATUS NTAPI UDFRead (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS UDFPostStackOverflowRead (IN PtrUDFIrpContext PtrIrpContext, IN PIRP Irp, IN PtrUDFFCB Fcb)
 
VOID NTAPI UDFStackOverflowRead (IN PVOID Context, IN PKEVENT Event)
 
NTSTATUS UDFCommonRead (PtrUDFIrpContext PtrIrpContext, PIRP Irp)
 
PVOID UDFGetCallersBuffer (PtrUDFIrpContext PtrIrpContext, PIRP Irp)
 
NTSTATUS UDFLockCallersBuffer (PtrUDFIrpContext PtrIrpContext, PIRP Irp, BOOLEAN IsReadOperation, uint32 Length)
 
NTSTATUS UDFUnlockCallersBuffer (PtrUDFIrpContext PtrIrpContext, PIRP Irp, PVOID SystemBuffer)
 
VOID UDFMdlComplete (PtrUDFIrpContext PtrIrpContext, PIRP Irp, PIO_STACK_LOCATION IrpSp, BOOLEAN ReadCompletion)
 
NTSTATUS UDFGetSecurity (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS UDFSetSecurity (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS UDFCommonGetSecurity (PtrUDFIrpContext PtrIrpContext, PIRP Irp)
 
NTSTATUS UDFCommonSetSecurity (PtrUDFIrpContext PtrIrpContext, PIRP Irp)
 
NTSTATUS UDFReadSecurity (IN PVCB Vcb, IN PtrUDFFCB Fcb, IN PSECURITY_DESCRIPTOR *SecurityDesc)
 
NTSTATUS UDFAssignAcl (IN PVCB Vcb, IN PFILE_OBJECT FileObject, IN PtrUDFFCB Fcb, IN PtrUDFNTRequiredFCB NtReqFcb)
 
VOID UDFDeassignAcl (IN PtrUDFNTRequiredFCB NtReqFcb, IN BOOLEAN AutoInherited)
 
NTSTATUS UDFWriteSecurity (IN PVCB Vcb, IN PtrUDFFCB Fcb, IN PSECURITY_DESCRIPTOR *SecurityDesc)
 
NTSTATUS UDFCheckAccessRights (PFILE_OBJECT FileObject, PACCESS_STATE AccessState, PtrUDFFCB Fcb, PtrUDFCCB Ccb, ACCESS_MASK DesiredAccess, USHORT ShareAccess)
 
NTSTATUS UDFSetAccessRights (PFILE_OBJECT FileObject, PACCESS_STATE AccessState, PtrUDFFCB Fcb, PtrUDFCCB Ccb, ACCESS_MASK DesiredAccess, USHORT ShareAccess)
 
NTSTATUS NTAPI UDFShutdown (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS UDFCommonShutdown (PtrUDFIrpContext PtrIrpContext, PIRP Irp)
 
BOOLEAN UDFDebugAcquireResourceSharedLite (IN PERESOURCE Resource, IN BOOLEAN Wait, ULONG BugCheckId, ULONG Line)
 
BOOLEAN UDFDebugAcquireSharedStarveExclusive (IN PERESOURCE Resource, IN BOOLEAN Wait, ULONG BugCheckId, ULONG Line)
 
BOOLEAN UDFDebugAcquireResourceExclusiveLite (IN PERESOURCE Resource, IN BOOLEAN Wait, ULONG BugCheckId, ULONG Line)
 
VOID UDFDebugReleaseResourceForThreadLite (IN PERESOURCE Resource, IN ERESOURCE_THREAD ResourceThreadId, ULONG BugCheckId, ULONG Line)
 
VOID UDFDebugDeleteResource (IN PERESOURCE Resource, IN ERESOURCE_THREAD ResourceThreadId, ULONG BugCheckId, ULONG Line)
 
NTSTATUS UDFDebugInitializeResourceLite (IN PERESOURCE Resource, IN ERESOURCE_THREAD ResourceThreadId, ULONG BugCheckId, ULONG Line)
 
VOID UDFDebugConvertExclusiveToSharedLite (IN PERESOURCE Resource, IN ERESOURCE_THREAD ResourceThreadId, ULONG BugCheckId, ULONG Line)
 
BOOLEAN UDFDebugAcquireSharedWaitForExclusive (IN PERESOURCE Resource, IN BOOLEAN Wait, ULONG BugCheckId, ULONG Line)
 
LONG UDFDebugInterlockedIncrement (IN PLONG addr, ULONG BugCheckId, ULONG Line)
 
LONG UDFDebugInterlockedDecrement (IN PLONG addr, ULONG BugCheckId, ULONG Line)
 
LONG UDFDebugInterlockedExchangeAdd (IN PLONG addr, IN LONG i, ULONG BugCheckId, ULONG Line)
 
NTSTATUS NTAPI DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath)
 
VOID NTAPI UDFInitializeFunctionPointers (PDRIVER_OBJECT DriverObject)
 
VOID NTAPI UDFFsNotification (IN PDEVICE_OBJECT DeviceObject, IN BOOLEAN FsActive)
 
BOOLEAN UDFGetInstallVersion (PULONG iVer)
 
BOOLEAN UDFGetInstallTime (PULONG iTime)
 
BOOLEAN UDFGetTrialEnd (PULONG iTrial)
 
NTSTATUS UDFVerifyVcb (IN PtrUDFIrpContext IrpContext, IN PVCB Vcb)
 
NTSTATUS UDFVerifyVolume (IN PIRP Irp)
 
NTSTATUS UDFPerformVerify (IN PtrUDFIrpContext IrpContext, IN PIRP Irp, IN PDEVICE_OBJECT DeviceToVerify)
 
BOOLEAN UDFCheckForDismount (IN PtrUDFIrpContext IrpContext, IN PVCB Vcb, IN BOOLEAN VcbAcquired)
 
BOOLEAN UDFDismountVcb (IN PVCB Vcb, IN BOOLEAN VcbAcquired)
 
NTSTATUS UDFCompareVcb (IN PVCB OldVcb, IN PVCB NewVcb, IN BOOLEAN PhysicalOnly)
 
NTSTATUS NTAPI UDFQueryVolInfo (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS UDFCommonQueryVolInfo (PtrUDFIrpContext PtrIrpContext, PIRP Irp)
 
NTSTATUS NTAPI UDFSetVolInfo (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS UDFCommonSetVolInfo (PtrUDFIrpContext PtrIrpContext, PIRP Irp)
 
NTSTATUS NTAPI UDFWrite (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS UDFCommonWrite (PtrUDFIrpContext PtrIrpContext, PIRP Irp)
 
VOID NTAPI UDFDeferredWriteCallBack (VOID *Context1, VOID *Context2)
 
VOID UDFPurgeCacheEx_ (PtrUDFNTRequiredFCB NtReqFcb, LONGLONG Offset, LONGLONG Length, BOOLEAN CanWait, PVCB Vcb, PFILE_OBJECT FileObject)
 

Macro Definition Documentation

◆ UDF_CLOSE_FCB_DELETED

#define UDF_CLOSE_FCB_DELETED   0x02

Definition at line 81 of file protos.h.

◆ UDF_CLOSE_NTREQFCB_DELETED

#define UDF_CLOSE_NTREQFCB_DELETED   0x01

Definition at line 80 of file protos.h.

◆ UDFCloseAllDelayedInDir

#define UDFCloseAllDelayedInDir (   Vcb,
  FI 
)     UDFCloseAllXXXDelayedInDir(Vcb,FI,FALSE);

Definition at line 96 of file protos.h.

◆ UDFCloseAllSystemDelayedInDir

#define UDFCloseAllSystemDelayedInDir (   Vcb,
  FI 
)     UDFCloseAllXXXDelayedInDir(Vcb,FI,TRUE);

Definition at line 99 of file protos.h.

◆ UDFPurgeCacheEx

#define UDFPurgeCacheEx (   NtReqFcb,
  Offset,
  Length,
  CanWait,
  Vcb,
  FileObject 
)     UDFPurgeCacheEx_(NtReqFcb, Offset, Length, CanWait, Vcb, FileObject)

Definition at line 1148 of file protos.h.

◆ UDFRemoveFileId__

#define UDFRemoveFileId__ (   Vcb,
  fi 
)     UDFRemoveFileId(Vcb, UDFGetNTFileId(Vcb, fi, &(fi->Fcb->FCBName->ObjectName)));

Definition at line 407 of file protos.h.

◆ UDFRemoveFromDelayedQueue

#define UDFRemoveFromDelayedQueue (   Fcb)     UDFCloseAllDelayedInDir((Fcb)->Vcb, (Fcb)->FileInfo)

Definition at line 106 of file protos.h.

◆ UDFRemoveFromSystemDelayedQueue

#define UDFRemoveFromSystemDelayedQueue (   Fcb)     UDFCloseAllSystemDelayedInDir((Fcb)->Vcb, (Fcb)->FileInfo)

Definition at line 109 of file protos.h.

◆ UDFZeroDataEx

#define UDFZeroDataEx (   NtReqFcb,
  Offset,
  Length,
  CanWait,
  Vcb,
  FileObject 
)     UDFPurgeCacheEx_(NtReqFcb, Offset, Length, CanWait, Vcb, FileObject)

Definition at line 1146 of file protos.h.

Function Documentation

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( PDRIVER_OBJECT  DriverObject,
PUNICODE_STRING  RegistryPath 
)

Definition at line 16 of file battc.c.

18{
19 DPRINT("Battery class driver initialized\n");
20
21 return STATUS_SUCCESS;
22}
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71

◆ UDFAcqLazyWrite()

BOOLEAN NTAPI UDFAcqLazyWrite ( IN PVOID  Context,
IN BOOLEAN  Wait 
)

Definition at line 423 of file fastio.cpp.

426{
427 // The context is whatever we passed to the Cache Manager when invoking
428 // the CcInitializeCacheMaps() function. In the case of the UDF FSD
429 // implementation, this context is a pointer to the NT_REQ_FCB structure.
431
432 MmPrint((" UDFAcqLazyWrite()\n"));
433
434 // Acquire the PagingIoResource in the NT_REQ_FCB exclusively. Then, set the
435 // lazy-writer thread id in the NT_REQ_FCB structure for identification
436 // when an actual write request is received by the FSD.
437 // Note: The lazy-writer typically always supplies WAIT set to TRUE.
438 if (!UDFAcquireResourceExclusive(&(NtReqFcb->PagingIoResource), Wait))
439 return FALSE;
440
441 // Now, set the lazy-writer thread id.
442 ASSERT(!(NtReqFcb->LazyWriterThreadID));
443 NtReqFcb->LazyWriterThreadID = HandleToUlong(PsGetCurrentThreadId());
444
447
448 // If our FSD needs to perform some special preparations in anticipation
449 // of receving a lazy-writer request, do so now.
450 return TRUE;
451} // end UDFAcqLazyWrite()
#define HandleToUlong(h)
Definition: basetsd.h:79
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define UDFAcquireResourceExclusive(Resource, CanWait)
Definition: env_spec_w32.h:656
#define MmPrint(_x_)
Definition: env_spec_w32.h:289
#define NtReqFcb
PsGetCurrentThreadId
Definition: CrNtStubs.h:8
#define FSRTL_CACHE_TOP_LEVEL_IRP
Definition: fsrtltypes.h:60
#define ASSERT(a)
Definition: mode.c:44
PIRP NTAPI IoGetTopLevelIrp(VOID)
Definition: irp.c:1843
VOID NTAPI IoSetTopLevelIrp(IN PIRP Irp)
Definition: irp.c:2000
struct _UDFNTRequiredFCB * PtrUDFNTRequiredFCB
_In_ WDFDPC _In_ BOOLEAN Wait
Definition: wdfdpc.h:170

Referenced by UDFInitializeFunctionPointers().

◆ UDFAcqReadAhead()

BOOLEAN NTAPI UDFAcqReadAhead ( IN PVOID  Context,
IN BOOLEAN  Wait 
)

Definition at line 514 of file fastio.cpp.

518{
519 // The context is whatever we passed to the Cache Manager when invoking
520 // the CcInitializeCacheMaps() function. In the case of the UDF FSD
521 // implementation, this context is a pointer to the NT_REQ_FCB structure.
522#define NtReqFcb ((PtrUDFNTRequiredFCB)Context)
523
524 MmPrint((" AcqForReadAhead()\n"));
525
526 // Acquire the MainResource in the NT_REQ_FCB shared.
527 // Note: The read-ahead thread typically always supplies WAIT set to TRUE.
529 if (!UDFAcquireResourceShared(&(NtReqFcb->MainResource), Wait))
530 return FALSE;
531
534
535 return TRUE;
536#undef NtReqFcb
537
538} // end UDFAcqReadAhead()
#define UDFAcquireResourceShared(Resource, CanWait)
Definition: env_spec_w32.h:658
#define UDF_CHECK_PAGING_IO_RESOURCE(NTReqFCB)
Definition: udffs.h:260

Referenced by UDFInitializeFunctionPointers().

◆ UDFAcquireResourceExclusiveWithCheck()

BOOLEAN UDFAcquireResourceExclusiveWithCheck ( IN PERESOURCE  Resource)

Definition at line 2529 of file misc.cpp.

2532{
2533 ULONG ReAcqRes =
2536 if(ReAcqRes) {
2537 UDFPrint(("UDFAcquireResourceExclusiveWithCheck: ReAcqRes, %x\n", ReAcqRes));
2538 } else {
2539// BrutePoint();
2540 }
2541
2542 if(ReAcqRes == 1) {
2543 // OK
2544 } else
2545 if(ReAcqRes == 2) {
2546 UDFPrint(("UDFAcquireResourceExclusiveWithCheck: !!! Shared !!!\n"));
2547 //BrutePoint();
2548 } else {
2550 return TRUE;
2551 }
2552 return FALSE;
2553} // end UDFAcquireResourceExclusiveWithCheck()
_Acquires_exclusive_lock_ Resource _Acquires_shared_lock_ Resource _Inout_ PERESOURCE Resource
Definition: cdprocs.h:843
BOOLEAN NTAPI ExIsResourceAcquiredExclusiveLite(IN PERESOURCE Resource)
Definition: resource.c:1624
ULONG NTAPI ExIsResourceAcquiredSharedLite(IN PERESOURCE Resource)
Definition: resource.c:1663
uint32_t ULONG
Definition: typedefs.h:59
#define UDFPrint(Args)
Definition: udffs.h:223

Referenced by UDFCommonCleanup(), UDFCommonWrite(), UDFSetAllocationInformation(), UDFSetEOF(), and UDFTSendIOCTL().

◆ UDFAcquireResourceSharedWithCheck()

BOOLEAN UDFAcquireResourceSharedWithCheck ( IN PERESOURCE  Resource)

Definition at line 2556 of file misc.cpp.

2559{
2560 ULONG ReAcqRes =
2563 if(ReAcqRes) {
2564 UDFPrint(("UDFAcquireResourceSharedWithCheck: ReAcqRes, %x\n", ReAcqRes));
2565/* } else {
2566 BrutePoint();*/
2567 }
2568
2569 if(ReAcqRes == 2) {
2570 // OK
2571 } else
2572 if(ReAcqRes == 1) {
2573 UDFPrint(("UDFAcquireResourceSharedWithCheck: Exclusive\n"));
2574 //BrutePoint();
2575 } else {
2577 return TRUE;
2578 }
2579 return FALSE;
2580} // end UDFAcquireResourceSharedWithCheck()

Referenced by UDFCommonRead().

◆ UDFAllocateCCB()

PtrUDFCCB UDFAllocateCCB ( VOID  )

Definition at line 707 of file misc.cpp.

708{
710 BOOLEAN AllocatedFromZone = TRUE;
711 KIRQL CurrentIrql;
712
713 // first, __try to allocate out of the zone
714 KeAcquireSpinLock(&(UDFGlobalData.ZoneAllocationSpinLock), &CurrentIrql);
715 if (!ExIsFullZone(&(UDFGlobalData.CCBZoneHeader))) {
716 // we have enough memory
717 Ccb = (PtrUDFCCB)ExAllocateFromZone(&(UDFGlobalData.CCBZoneHeader));
718
719 // release the spinlock
720 KeReleaseSpinLock(&(UDFGlobalData.ZoneAllocationSpinLock), CurrentIrql);
721 } else {
722 // release the spinlock
723 KeReleaseSpinLock(&(UDFGlobalData.ZoneAllocationSpinLock), CurrentIrql);
724
725 // if we failed to obtain from the zone, get it directly from the VMM
727 AllocatedFromZone = FALSE;
728// UDFPrint((" CCB allocated @%x\n",Ccb));
729 }
730
731 if (!Ccb) {
732 return NULL;
733 }
734
735 // zero out the allocated memory block
737
738 // set up some fields ...
739 Ccb->NodeIdentifier.NodeType = UDF_NODE_TYPE_CCB;
740 Ccb->NodeIdentifier.NodeSize = UDFQuadAlign(sizeof(UDFCCB));
741
742
743 if (!AllocatedFromZone) {
745 }
746
747 UDFPrint(("UDFAllocateCCB: %x\n", Ccb));
748 return(Ccb);
749} // end UDFAllocateCCB()
unsigned char BOOLEAN
_Inout_ PFILE_OBJECT _In_ TYPE_OF_OPEN PFCB _In_opt_ PCCB Ccb
Definition: cdprocs.h:592
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define NonPagedPool
Definition: env_spec_w32.h:307
#define MyAllocatePool__(type, size)
Definition: mem_tools.h:149
#define UDF_CCB_NOT_FROM_ZONE
Definition: struct.h:175
#define UDF_NODE_TYPE_CCB
Definition: struct.h:59
struct _UDFContextControlBlock * PtrUDFCCB
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define UDFQuadAlign(Value)
Definition: udffs.h:194
#define UDFSetFlag(Flag, Value)
Definition: udffs.h:189
UDFData UDFGlobalData
Definition: udfinit.cpp:25
#define ExIsFullZone(Zone)
Definition: exfuncs.h:329

Referenced by UDFOpenFile().

◆ UDFAllocateFCB()

PtrUDFFCB UDFAllocateFCB ( VOID  )

Definition at line 854 of file misc.cpp.

855{
857
859
860 if (!Fcb) {
861 return NULL;
862 }
863
864 // zero out the allocated memory block
866
867 // set up some fields ...
868 Fcb->NodeIdentifier.NodeType = UDF_NODE_TYPE_FCB;
869 Fcb->NodeIdentifier.NodeSize = UDFQuadAlign(sizeof(UDFFCB));
870
871 UDFPrint(("UDFAllocateFCB: %x\n", Fcb));
872 return(Fcb);
873} // end UDFAllocateFCB()
_In_ PFCB Fcb
Definition: cdprocs.h:159
struct _UDFFileControlBlock * PtrUDFFCB
#define UDF_NODE_TYPE_FCB
Definition: struct.h:60
#define UDF_FCB_MT
Definition: struct.h:241

Referenced by UDFBlankMount(), UDFCompleteMount(), and UDFFirstOpenFile().

◆ UDFAllocateIrpContext()

PtrUDFIrpContext UDFAllocateIrpContext ( PIRP  Irp,
PDEVICE_OBJECT  PtrTargetDeviceObject 
)

Definition at line 985 of file misc.cpp.

989{
990 PtrUDFIrpContext PtrIrpContext = NULL;
991 BOOLEAN AllocatedFromZone = TRUE;
992 KIRQL CurrentIrql;
994
995 // first, __try to allocate out of the zone
996 KeAcquireSpinLock(&(UDFGlobalData.ZoneAllocationSpinLock), &CurrentIrql);
997 if (!ExIsFullZone(&(UDFGlobalData.IrpContextZoneHeader))) {
998 // we have enough memory
999 PtrIrpContext = (PtrUDFIrpContext)ExAllocateFromZone(&(UDFGlobalData.IrpContextZoneHeader));
1000
1001 // release the spinlock
1002 KeReleaseSpinLock(&(UDFGlobalData.ZoneAllocationSpinLock), CurrentIrql);
1003 } else {
1004 // release the spinlock
1005 KeReleaseSpinLock(&(UDFGlobalData.ZoneAllocationSpinLock), CurrentIrql);
1006
1007 // if we failed to obtain from the zone, get it directly from the VMM
1009 AllocatedFromZone = FALSE;
1010 }
1011
1012 // if we could not obtain the required memory, bug-check.
1013 // Do NOT do this in your commercial driver, instead handle the error gracefully ...
1014 if (!PtrIrpContext) {
1015 return NULL;
1016 }
1017
1018#ifdef UDF_DBG
1019 IrpContextCounter++;
1020#endif //UDF_DBG
1021
1022 // zero out the allocated memory block
1023 RtlZeroMemory(PtrIrpContext, UDFQuadAlign(sizeof(UDFIrpContext)));
1024
1025 // set up some fields ...
1027 PtrIrpContext->NodeIdentifier.NodeSize = UDFQuadAlign(sizeof(UDFIrpContext));
1028
1029
1030 PtrIrpContext->Irp = Irp;
1031 PtrIrpContext->TargetDeviceObject = PtrTargetDeviceObject;
1032
1033 // copy over some fields from the IRP and set appropriate flag values
1034 if (Irp) {
1036 ASSERT(IrpSp);
1037
1038 PtrIrpContext->MajorFunction = IrpSp->MajorFunction;
1039 PtrIrpContext->MinorFunction = IrpSp->MinorFunction;
1040
1041 // Often, a FSD cannot honor a request for asynchronous processing
1042 // of certain critical requests. For example, a "close" request on
1043 // a file object can typically never be deferred. Therefore, do not
1044 // be surprised if sometimes our FSD (just like all other FSD
1045 // implementations on the Windows NT system) has to override the flag
1046 // below.
1047 if (IrpSp->FileObject == NULL) {
1049 } else {
1052 }
1053 }
1054 }
1055
1056 if (!AllocatedFromZone) {
1058 }
1059
1060 // Are we top-level ? This information is used by the dispatching code
1061 // later (and also by the FSD dispatch routine)
1062 if (IoGetTopLevelIrp() != Irp) {
1063 // We are not top-level. Note this fact in the context structure
1065 }
1066
1067 return(PtrIrpContext);
1068} // end UDFAllocateIrpContext()
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
_In_ PIRP Irp
Definition: csq.h:116
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
BOOLEAN NTAPI IoIsOperationSynchronous(IN PIRP Irp)
Definition: irp.c:1882
#define UDF_IRP_CONTEXT_NOT_TOP_LEVEL
Definition: struct.h:390
#define UDF_IRP_CONTEXT_CAN_BLOCK
Definition: struct.h:385
struct _UDFIrpContext * PtrUDFIrpContext
#define UDF_IRP_CONTEXT_NOT_FROM_ZONE
Definition: struct.h:399
#define UDF_NODE_TYPE_IRP_CONTEXT
Definition: struct.h:62
PFILE_OBJECT FileObject
Definition: iotypes.h:3169
uint32 NodeType
Definition: struct.h:75
uint32 NodeSize
Definition: struct.h:76
UDFIdentifier NodeIdentifier
Definition: struct.h:363
uint32 IrpContextFlags
Definition: struct.h:364
uint8 MinorFunction
Definition: struct.h:368
uint8 MajorFunction
Definition: struct.h:366
PDEVICE_OBJECT TargetDeviceObject
Definition: struct.h:374

Referenced by UDFCleanup(), UDFClose(), UDFCreate(), UDFDeviceControl(), UDFDirControl(), UDFFileInfo(), UDFFlush(), UDFFSControl(), UDFInitializeIrpContextFromLite(), UDFLockControl(), UDFPnp(), UDFQueryVolInfo(), UDFRead(), UDFSetVolInfo(), UDFShutdown(), and UDFWrite().

◆ UDFAllocateObjectName()

PtrUDFObjectName UDFAllocateObjectName ( VOID  )

Definition at line 611 of file misc.cpp.

612{
613 PtrUDFObjectName PtrObjectName = NULL;
614 BOOLEAN AllocatedFromZone = TRUE;
615 KIRQL CurrentIrql;
616
617 // first, __try to allocate out of the zone
618 KeAcquireSpinLock(&(UDFGlobalData.ZoneAllocationSpinLock), &CurrentIrql);
619 if (!ExIsFullZone(&(UDFGlobalData.ObjectNameZoneHeader))) {
620 // we have enough memory
621 PtrObjectName = (PtrUDFObjectName)ExAllocateFromZone(&(UDFGlobalData.ObjectNameZoneHeader));
622
623 // release the spinlock
624 KeReleaseSpinLock(&(UDFGlobalData.ZoneAllocationSpinLock), CurrentIrql);
625 } else {
626 // release the spinlock
627 KeReleaseSpinLock(&(UDFGlobalData.ZoneAllocationSpinLock), CurrentIrql);
628
629 // if we failed to obtain from the zone, get it directly from the VMM
631 AllocatedFromZone = FALSE;
632 }
633
634 if (!PtrObjectName) {
635 return NULL;
636 }
637
638 // zero out the allocated memory block
639 RtlZeroMemory(PtrObjectName, UDFQuadAlign(sizeof(UDFObjectName)));
640
641 // set up some fields ...
643 PtrObjectName->NodeIdentifier.NodeSize = UDFQuadAlign(sizeof(UDFObjectName));
644
645
646 if (!AllocatedFromZone) {
648 }
649
650 return(PtrObjectName);
651} // end UDFAllocateObjectName()
#define UDF_NODE_TYPE_OBJECT_NAME
Definition: struct.h:58
struct _UDFObjectName * PtrUDFObjectName
#define UDF_OBJ_NAME_NOT_FROM_ZONE
Definition: struct.h:97
UDFIdentifier NodeIdentifier
Definition: struct.h:91
uint32 ObjectNameFlags
Definition: struct.h:92

Referenced by UDFBlankMount(), UDFCompleteMount(), UDFFirstOpenFile(), and UDFRename().

◆ UDFAssignAcl()

NTSTATUS UDFAssignAcl ( IN PVCB  Vcb,
IN PFILE_OBJECT  FileObject,
IN PtrUDFFCB  Fcb,
IN PtrUDFNTRequiredFCB  NtReqFcb 
)

Definition at line 706 of file secursup.cpp.

712{
714#ifdef UDF_ENABLE_SECURITY
715// SECURITY_INFORMATION SecurityInformation;
716
717// UDFPrint((" UDFAssignAcl\n"));
718 if(!NtReqFcb->SecurityDesc) {
719
720 PSECURITY_DESCRIPTOR ExplicitSecurity = NULL;
721
722 if(UDFIsAStreamDir(Fcb->FileInfo) || UDFIsAStream(Fcb->FileInfo)) {
723 // Stream/SDir security
724 NtReqFcb->SecurityDesc = Fcb->FileInfo->ParentFile->Dloc->CommonFcb->SecurityDesc;
725 return STATUS_SUCCESS;
726 } else
727 if(!Fcb->FileInfo) {
728 // Volume security
729 if(Vcb->RootDirFCB &&
730 Vcb->RootDirFCB->FileInfo &&
731 Vcb->RootDirFCB->FileInfo->Dloc &&
732 Vcb->RootDirFCB->FileInfo->Dloc->CommonFcb) {
733 RC = UDFInheritAcl(Vcb, &(Vcb->RootDirFCB->FileInfo->Dloc->CommonFcb->SecurityDesc), &ExplicitSecurity);
734 } else {
735 NtReqFcb->SecurityDesc = NULL;
737 }
738 return RC;
739 }
740
741 RC = UDFReadSecurity(Vcb, Fcb, &ExplicitSecurity);
743 if(!Fcb->FileInfo->ParentFile) {
744 RC = UDFBuildFullControlAcl(Vcb, &ExplicitSecurity);
745 } else {
746 RC = UDFInheritAcl(Vcb, &(Fcb->FileInfo->ParentFile->Dloc->CommonFcb->SecurityDesc), &ExplicitSecurity);
747 }
748/* if(NT_SUCCESS(RC)) {
749 NtReqFcb->NtReqFCBFlags |= UDF_NTREQ_FCB_SD_MODIFIED;
750 }*/
751 }
752 if(NT_SUCCESS(RC)) {
753
754// SecurityInformation = FULL_SECURITY_INFORMATION;
755 NtReqFcb->SecurityDesc = ExplicitSecurity;
756
757/* RC = SeSetSecurityDescriptorInfo(FileObject,
758 &SecurityInformation,
759 ExplicitSecurity,
760 &(NtReqFcb->SecurityDesc),
761 NonPagedPool,
762 IoGetFileObjectGenericMapping() );*/
763
764 }
765 }
766#endif //UDF_ENABLE_SECURITY
767 return RC;
768} // end UDFAssignAcl()
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_NO_SECURITY_ON_OBJECT
Definition: ntstatus.h:451
#define Vcb
Definition: cdprocs.h:1415
NTSTATUS UDFReadSecurity(IN PVCB Vcb, IN PtrUDFFCB Fcb, IN PSECURITY_DESCRIPTOR *SecurityDesc)
Definition: secursup.cpp:420
#define UDFIsAStreamDir(FI)
Definition: udf_info.h:998
#define UDFIsAStream(FI)
Definition: udf_info.h:1002

Referenced by UDFCompleteMount(), and UDFLookUpAcl().

◆ UDFCheckAccessRights()

NTSTATUS UDFCheckAccessRights ( PFILE_OBJECT  FileObject,
PACCESS_STATE  AccessState,
PtrUDFFCB  Fcb,
PtrUDFCCB  Ccb,
ACCESS_MASK  DesiredAccess,
USHORT  ShareAccess 
)

Definition at line 927 of file secursup.cpp.

935{
936 NTSTATUS RC;
937 BOOLEAN ROCheck = FALSE;
938#ifdef UDF_ENABLE_SECURITY
939 BOOLEAN SecurityCheck;
940 PSECURITY_DESCRIPTOR SecDesc;
942 ACCESS_MASK LocalAccessMask;
943#endif //UDF_ENABLE_SECURITY
944
945 // Check attr compatibility
946 ASSERT(Fcb);
947 ASSERT(Fcb->Vcb);
948#ifdef UDF_READ_ONLY_BUILD
949 goto treat_as_ro;
950#endif //UDF_READ_ONLY_BUILD
951
952 if(Fcb->FCBFlags & UDF_FCB_READ_ONLY) {
953 ROCheck = TRUE;
954 } else
955 if((Fcb->Vcb->origIntegrityType == INTEGRITY_TYPE_OPEN) &&
956 Ccb && !(Ccb->CCBFlags & UDF_CCB_VOLUME_OPEN) &&
957 (Fcb->Vcb->CompatFlags & UDF_VCB_IC_DIRTY_RO)) {
958 AdPrint(("force R/O on dirty\n"));
959 ROCheck = TRUE;
960 }
961 if(ROCheck) {
962#ifdef UDF_READ_ONLY_BUILD
963treat_as_ro:
964#endif //UDF_READ_ONLY_BUILD
965 ACCESS_MASK DesiredAccessMask = 0;
966
967 if(Fcb->Vcb->CompatFlags & UDF_VCB_IC_WRITE_IN_RO_DIR) {
968 if(Fcb->FCBFlags & UDF_FCB_DIRECTORY) {
969 DesiredAccessMask = (FILE_WRITE_EA |
970 DELETE);
971 } else {
972 DesiredAccessMask = (FILE_WRITE_DATA |
975 DELETE);
976 }
977 } else {
978 DesiredAccessMask = (FILE_WRITE_DATA |
984 DELETE);
985 }
986 if(DesiredAccess & DesiredAccessMask)
988 }
989#ifdef UDF_ENABLE_SECURITY
990 // Check Security
991 // NOTE: we should not perform security check if an empty DesiredAccess
992 // was specified. AFAIU, SeAccessCheck() will return FALSE in this case.
993 SecDesc = UDFLookUpAcl(Fcb->Vcb, FileObject, Fcb);
994 if(SecDesc && DesiredAccess) {
996 SecurityCheck =
997 SeAccessCheck(SecDesc,
999 FALSE,
1001 Ccb ? Ccb->PreviouslyGrantedAccess : 0,
1002 NULL,
1004 UserMode,
1005 Ccb ? &(Ccb->PreviouslyGrantedAccess) : &LocalAccessMask,
1006 &RC);
1008
1009 if(!SecurityCheck) {
1010 return RC;
1011 } else
1012#endif //UDF_ENABLE_SECURITY
1015 return STATUS_ACCESS_DENIED;
1016 Ccb->PreviouslyGrantedAccess |= ACCESS_SYSTEM_SECURITY;
1017 }
1018#ifdef UDF_ENABLE_SECURITY
1019 }
1020#endif //UDF_ENABLE_SECURITY
1021 if(FileObject) {
1022 if (Fcb->OpenHandleCount) {
1023 // The FCB is currently in use by some thread.
1024 // We must check whether the requested access/share access
1025 // conflicts with the existing open operations.
1027 &(Fcb->NTRequiredFCB->FCBShareAccess), TRUE);
1028#ifndef UDF_ENABLE_SECURITY
1029 if(Ccb)
1030 Ccb->PreviouslyGrantedAccess |= DesiredAccess;
1031 IoUpdateShareAccess(FileObject, &(Fcb->NTRequiredFCB->FCBShareAccess));
1032#endif //UDF_ENABLE_SECURITY
1033 } else {
1034 IoSetShareAccess(DesiredAccess, ShareAccess, FileObject, &(Fcb->NTRequiredFCB->FCBShareAccess));
1035#ifndef UDF_ENABLE_SECURITY
1036 if(Ccb)
1037 Ccb->PreviouslyGrantedAccess = DesiredAccess;
1038#endif //UDF_ENABLE_SECURITY
1039 RC = STATUS_SUCCESS;
1040 }
1041 } else {
1042 // we get here if given file was opened for internal purposes
1043 RC = STATUS_SUCCESS;
1044 }
1045 return RC;
1046} // end UDFCheckAccessRights()
BOOLEAN NTAPI SeAccessCheck(_In_ PSECURITY_DESCRIPTOR SecurityDescriptor, _In_ PSECURITY_SUBJECT_CONTEXT SubjectSecurityContext, _In_ BOOLEAN SubjectContextLocked, _In_ ACCESS_MASK DesiredAccess, _In_ ACCESS_MASK PreviouslyGrantedAccess, _Out_ PPRIVILEGE_SET *Privileges, _In_ PGENERIC_MAPPING GenericMapping, _In_ KPROCESSOR_MODE AccessMode, _Out_ PACCESS_MASK GrantedAccess, _Out_ PNTSTATUS AccessStatus)
Determines whether security access rights can be given to an object depending on the security descrip...
Definition: accesschk.c:1994
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB _In_ PDCB _In_ PDIRENT _In_ ULONG _In_ ULONG _In_ PUNICODE_STRING _In_ PACCESS_MASK _In_ USHORT ShareAccess
Definition: create.c:4147
#define INTEGRITY_TYPE_OPEN
Definition: ecma_167.h:357
#define AdPrint(_x_)
Definition: env_spec_w32.h:292
_Inout_ PLIST_ENTRY _In_ PVOID _In_ PSTRING _In_ BOOLEAN _In_ BOOLEAN _In_ ULONG _In_ PFLT_CALLBACK_DATA _In_opt_ PCHECK_FOR_TRAVERSE_ACCESS _In_opt_ PSECURITY_SUBJECT_CONTEXT SubjectContext
Definition: fltkernel.h:2246
#define UserMode
Definition: asm.h:35
#define FILE_WRITE_DATA
Definition: nt_native.h:631
ULONG ACCESS_MASK
Definition: nt_native.h:40
#define ACCESS_SYSTEM_SECURITY
Definition: nt_native.h:77
#define FILE_DELETE_CHILD
Definition: nt_native.h:645
#define FILE_APPEND_DATA
Definition: nt_native.h:634
#define DELETE
Definition: nt_native.h:57
#define FILE_ADD_SUBDIRECTORY
Definition: nt_native.h:635
#define FILE_ADD_FILE
Definition: nt_native.h:632
#define FILE_WRITE_EA
Definition: nt_native.h:640
VOID NTAPI IoSetShareAccess(IN ACCESS_MASK DesiredAccess, IN ULONG DesiredShareAccess, IN PFILE_OBJECT FileObject, OUT PSHARE_ACCESS ShareAccess)
Definition: file.c:3517
NTSTATUS NTAPI IoCheckShareAccess(IN ACCESS_MASK DesiredAccess, IN ULONG DesiredShareAccess, IN PFILE_OBJECT FileObject, IN PSHARE_ACCESS ShareAccess, IN BOOLEAN Update)
Definition: file.c:3390
PGENERIC_MAPPING NTAPI IoGetFileObjectGenericMapping(VOID)
Definition: file.c:3267
VOID NTAPI IoUpdateShareAccess(IN PFILE_OBJECT FileObject, OUT PSHARE_ACCESS ShareAccess)
Definition: file.c:3351
BOOLEAN NTAPI SeSinglePrivilegeCheck(_In_ LUID PrivilegeValue, _In_ KPROCESSOR_MODE PreviousMode)
Checks if a single privilege is present in the context of the calling thread.
Definition: priv.c:744
PSECURITY_DESCRIPTOR UDFLookUpAcl(IN PVCB Vcb, PFILE_OBJECT FileObject, IN PtrUDFFCB Fcb)
Definition: secursup.cpp:915
PSE_EXPORTS SeExports
Definition: semgr.c:21
#define UDF_FCB_READ_ONLY
Definition: struct.h:312
#define UDF_CCB_VOLUME_OPEN
Definition: struct.h:166
#define UDF_FCB_DIRECTORY
Definition: struct.h:303
PVCB Vcb
Definition: cdstruc.h:933
ULONG OpenHandleCount
Definition: ntfs.h:537
LUID SeSecurityPrivilege
Definition: setypes.h:1201
VOID NTAPI SeReleaseSubjectContext(_In_ PSECURITY_SUBJECT_CONTEXT SubjectContext)
Releases both the primary and client tokens of a security subject context.
Definition: subject.c:171
VOID NTAPI SeCaptureSubjectContext(_Out_ PSECURITY_SUBJECT_CONTEXT SubjectContext)
Captures the security subject context of the calling thread and calling process.
Definition: subject.c:85
#define UDF_VCB_IC_DIRTY_RO
Definition: udf_common.h:516
#define UDF_VCB_IC_WRITE_IN_RO_DIR
Definition: udf_common.h:499
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
Definition: wdfdevice.h:2658
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550

Referenced by UDFCommonCreate(), UDFDoesOSAllowFileToBeTargetForRename__(), UDFSetAccessRights(), and UDFSetDispositionInformation().

◆ UDFCheckForDismount()

BOOLEAN UDFCheckForDismount ( IN PtrUDFIrpContext  IrpContext,
IN PVCB  Vcb,
IN BOOLEAN  VcbAcquired 
)

Definition at line 629 of file verfysup.cpp.

634{
635 BOOLEAN VcbPresent = TRUE;
636 KIRQL SavedIrql;
637 BOOLEAN VcbAcquired;
638 ULONG ResidualReferenceCount;
639
640 UDFPrint(("UDFCheckForDismount:\n"));
641 if(!Vcb) return FALSE;
642
643 // GlobalDataResource is already acquired
644 if(!_VcbAcquired) {
645 VcbAcquired = UDFAcquireResourceExclusive(&(Vcb->VCBResource), TRUE/*FALSE*/ );
646 if(!VcbAcquired)
647 return TRUE;
648 } else {
649 VcbAcquired = TRUE;
650 }
651
652 if ((IrpContext->MajorFunction == IRP_MJ_CREATE) &&
653 (IrpContext->TargetDeviceObject == Vcb->TargetDeviceObject)) {
654
655 ResidualReferenceCount = 2;
656
657 } else {
658
659 ResidualReferenceCount = 1;
660 }
661
662 // If the dismount is not already underway then check if the
663 // user reference count has gone to zero. If so start the teardown
664 // on the Vcb.
665 if (!(Vcb->VCBFlags & UDF_VCB_FLAGS_BEING_DISMOUNTED)) {
666 if (Vcb->VCBOpenCount <= UDF_RESIDUAL_REFERENCE) {
667 VcbPresent = UDFDismountVcb(Vcb, VcbAcquired);
668 }
669 VcbAcquired = VcbAcquired && VcbPresent;
670
671 // If the teardown is underway and there are absolutely no references
672 // remaining then delete the Vcb. References here include the
673 // references in the Vcb and Vpb.
674 } else if (!(Vcb->VCBOpenCount)) {
675
676 IoAcquireVpbSpinLock( &SavedIrql );
677 // If there are no file objects and no reference counts in the
678 // Vpb we can delete the Vcb. Don't forget that we have the
679 // last reference in the Vpb.
680 if (Vcb->Vpb->ReferenceCount <= ResidualReferenceCount) {
681
682 IoReleaseVpbSpinLock( SavedIrql );
683 if(VcbAcquired)
684 UDFReleaseResource(&(Vcb->VCBResource));
687 VcbAcquired =
688 VcbPresent = FALSE;
689
690 } else {
691
692 IoReleaseVpbSpinLock( SavedIrql );
693 }
694 }
695
696 // Release any resources still acquired.
697 if (!_VcbAcquired && VcbAcquired) {
698 UDFReleaseResource(&(Vcb->VCBResource));
699 }
700
701 return VcbPresent;
702} // end UDFCheckForDismount()
VOID UDFReleaseVCB(PVCB Vcb)
Definition: misc.cpp:2137
#define UDFReleaseResource(Resource)
Definition: env_spec_w32.h:661
VOID NTAPI IoReleaseVpbSpinLock(IN KIRQL Irql)
Definition: volume.c:1215
VOID NTAPI IoAcquireVpbSpinLock(OUT PKIRQL Irql)
Definition: volume.c:1204
VOID UDFStopEjectWaiter(PVCB Vcb)
Definition: phys_eject.cpp:673
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define UDF_RESIDUAL_REFERENCE
Definition: struct.h:336
#define UDF_VCB_FLAGS_BEING_DISMOUNTED
Definition: udf_common.h:461
BOOLEAN UDFDismountVcb(IN PVCB Vcb, IN BOOLEAN VcbAcquired)
Definition: verfysup.cpp:727

Referenced by UDFCommonClose(), UDFPerformVerify(), UDFPnpQueryRemove(), UDFPnpRemove(), UDFPnpSurpriseRemove(), and UDFScanForDismountedVcb().

◆ UDFCleanup()

NTSTATUS NTAPI UDFCleanup ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 43 of file cleanup.cpp.

47{
49 PtrUDFIrpContext PtrIrpContext = NULL;
50 BOOLEAN AreWeTopLevel = FALSE;
51
52 TmPrint(("UDFCleanup\n"));
53
56 ASSERT(Irp);
57
58 // If we were called with our file system device object instead of a
59 // volume device object, just complete this request with STATUS_SUCCESS
60 if (UDFIsFSDevObj(DeviceObject)) {
61 // this is a cleanup of the FSD itself
62 Irp->IoStatus.Status = RC;
63 Irp->IoStatus.Information = 0;
64
66 UDFPrint(("Deregister Autoformat\n"));
68 }
69
72 return(RC);
73 }
74
75 // set the top level context
76 AreWeTopLevel = UDFIsIrpTopLevel(Irp);
77
78 _SEH2_TRY {
79
80 // get an IRP context structure and issue the request
81 PtrIrpContext = UDFAllocateIrpContext(Irp, DeviceObject);
82 if(PtrIrpContext) {
83 RC = UDFCommonCleanup(PtrIrpContext, Irp);
84 } else {
86 Irp->IoStatus.Status = RC;
87 Irp->IoStatus.Information = 0;
88 // complete the IRP
90 }
91
93
94 RC = UDFExceptionHandler(PtrIrpContext, Irp);
95
97 } _SEH2_END;
98
99 if (AreWeTopLevel) {
101 }
102
104
105 return(RC);
106} // end UDFCleanup()
NTSTATUS UDFCommonCleanup(PtrUDFIrpContext PtrIrpContext, PIRP Irp)
Definition: cleanup.cpp:126
NTSTATUS UDFExceptionHandler(PtrUDFIrpContext PtrIrpContext, PIRP Irp)
Definition: misc.cpp:358
BOOLEAN __fastcall UDFIsIrpTopLevel(PIRP Irp)
Definition: misc.cpp:228
VOID UDFLogEvent(NTSTATUS UDFEventLogId, NTSTATUS RC)
Definition: misc.cpp:575
PtrUDFIrpContext UDFAllocateIrpContext(PIRP Irp, PDEVICE_OBJECT PtrTargetDeviceObject)
Definition: misc.cpp:985
long UDFExceptionFilter(PtrUDFIrpContext PtrIrpContext, PEXCEPTION_POINTERS PtrExceptionPointers)
Definition: misc.cpp:265
#define TmPrint(_x_)
Definition: env_spec_w32.h:290
#define UDF_ERROR_INTERNAL_ERROR
Definition: errmsg.h:71
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
#define FsRtlEnterFileSystem
#define FsRtlExitFileSystem
#define IoCompleteRequest
Definition: irp.c:1240
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:34
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:158
PVOID AutoFormatCount
Definition: udf_common.h:629
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define IO_DISK_INCREMENT
Definition: iotypes.h:600

Referenced by UDFInitializeFunctionPointers().

◆ UDFCleanUpCCB()

VOID __fastcall UDFCleanUpCCB ( PtrUDFCCB  Ccb)

Definition at line 805 of file misc.cpp.

807{
808// ASSERT(Ccb);
809 if(!Ccb) return; // probably, we havn't allocated it...
810 ASSERT(Ccb->NodeIdentifier.NodeType == UDF_NODE_TYPE_CCB);
811
812 _SEH2_TRY {
813 if(Ccb->Fcb) {
814 UDFTouch(&(Ccb->Fcb->CcbListResource));
815 UDFAcquireResourceExclusive(&(Ccb->Fcb->CcbListResource),TRUE);
816 RemoveEntryList(&(Ccb->NextCCB));
817 UDFReleaseResource(&(Ccb->Fcb->CcbListResource));
818 } else {
819 BrutePoint();
820 }
821
822 if (Ccb->DirectorySearchPattern) {
823 if (Ccb->DirectorySearchPattern->Buffer) {
824 MyFreePool__(Ccb->DirectorySearchPattern->Buffer);
825 Ccb->DirectorySearchPattern->Buffer = NULL;
826 }
827
828 MyFreePool__(Ccb->DirectorySearchPattern);
829 Ccb->DirectorySearchPattern = NULL;
830 }
831
834 BrutePoint();
835 } _SEH2_END;
836} // end UDFCleanUpCCB()
VOID __fastcall UDFReleaseCCB(PtrUDFCCB Ccb)
Definition: misc.cpp:768
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define UDFTouch(a)
Definition: env_spec_w32.h:303
#define BrutePoint()
Definition: env_spec_w32.h:504
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define MyFreePool__(addr)
Definition: mem_tools.h:152
struct _FCB::@720::@723 Fcb

Referenced by UDFCommonClose(), and UDFCommonCreate().

◆ UDFCleanUpFCB()

VOID __fastcall UDFCleanUpFCB ( PtrUDFFCB  Fcb)

Definition at line 908 of file misc.cpp.

911{
912 UDFPrint(("UDFCleanUpFCB: %x\n", Fcb));
913 if(!Fcb) return;
914
915 ASSERT(Fcb->NodeIdentifier.NodeType == UDF_NODE_TYPE_FCB);
916
917 _SEH2_TRY {
918 // Deinitialize FCBName field
919 if (Fcb->FCBName) {
920 if(Fcb->FCBName->ObjectName.Buffer) {
921 MyFreePool__(Fcb->FCBName->ObjectName.Buffer);
922 Fcb->FCBName->ObjectName.Buffer = NULL;
923#ifdef UDF_DBG
924 Fcb->FCBName->ObjectName.Length =
925 Fcb->FCBName->ObjectName.MaximumLength = 0;
926#endif
927 }
928#ifdef UDF_DBG
929 else {
930 UDFPrint(("UDF: Fcb has invalid FCBName Buffer\n"));
931 BrutePoint();
932 }
933#endif
934 UDFReleaseObjectName(Fcb->FCBName);
935 Fcb->FCBName = NULL;
936 }
937#ifdef UDF_DBG
938 else {
939 UDFPrint(("UDF: Fcb has invalid FCBName field\n"));
940 BrutePoint();
941 }
942#endif
943
944
945 // begin transaction {
946 UDFTouch(&(Fcb->Vcb->FcbListResource));
947 UDFAcquireResourceExclusive(&(Fcb->Vcb->FcbListResource), TRUE);
948 // Remove this FCB from list of all FCB in VCB
949 RemoveEntryList(&(Fcb->NextFCB));
950 UDFReleaseResource(&(Fcb->Vcb->FcbListResource));
951 // } end transaction
952
954 UDFDeleteResource(&(Fcb->CcbListResource));
955
956 // Free memory
959 BrutePoint();
960 } _SEH2_END;
961} // end UDFCleanUpFCB()
VOID __fastcall UDFReleaseObjectName(PtrUDFObjectName PtrObjectName)
Definition: misc.cpp:670
#define UDFDeleteResource(Resource)
Definition: env_spec_w32.h:663
__inline VOID UDFReleaseFCB(PtrUDFFCB Fcb)
Definition: protos.h:620
#define UDF_FCB_INITIALIZED_CCB_LIST_RESOURCE
Definition: struct.h:316
WCHAR * ObjectName
Definition: ntfs.h:524

Referenced by UDFBlankMount(), UDFCleanUpFcbChain(), UDFCommonCreate(), and UDFCompleteMount().

◆ UDFCleanUpFcbChain()

ULONG UDFCleanUpFcbChain ( IN PVCB  Vcb,
IN PUDF_FILE_INFO  fi,
IN ULONG  TreeLength,
IN BOOLEAN  VcbAcquired 
)

Definition at line 400 of file close.cpp.

406{
409 PUDF_FILE_INFO ParentFI;
411 ULONG CleanCode;
412 LONG RefCount, ComRefCount;
414 ULONG ret_val = 0;
415
417 AdPrint(("UDFCleanUpFcbChain\n"));
418
419 ASSERT(TreeLength);
420
421 // we can't process Tree until we can acquire Vcb
422 if(!VcbAcquired)
423 UDFAcquireResourceShared(&(Vcb->VCBResource),TRUE);
424
425 // cleanup parent chain (if any & unused)
426 while(fi) {
427
428 // acquire parent
429 if((ParentFI = fi->ParentFile)) {
430 ASSERT(fi->Fcb);
431 ParentFcb = fi->Fcb->ParentFcb;
433 ASSERT(ParentFcb->NTRequiredFCB);
436 } else {
437 // we get to RootDir, it has no parent
438 if(!VcbAcquired)
439 UDFAcquireResourceShared(&(Vcb->VCBResource),TRUE);
440 }
441 Fcb = fi->Fcb;
442 ASSERT(Fcb->NodeIdentifier.NodeType == UDF_NODE_TYPE_FCB);
443
444 NtReqFcb = Fcb->NTRequiredFCB;
445 ASSERT(NtReqFcb->CommonFCBHeader.NodeTypeCode == UDF_NODE_TYPE_NT_REQ_FCB);
446
447 // acquire current file/dir
448 // we must assure that no more threads try to re-use this object
449#ifdef UDF_DBG
450 _SEH2_TRY {
451#endif // UDF_DBG
453 UDFAcquireResourceExclusive(&(NtReqFcb->MainResource),TRUE);
454#ifdef UDF_DBG
456 BrutePoint();
457 if(ParentFI) {
459 UDFReleaseResource(&(ParentFcb->NTRequiredFCB->MainResource));
460 } else {
461 if(!VcbAcquired)
462 UDFReleaseResource(&(Vcb->VCBResource));
463 }
464 break;
465 } _SEH2_END;
466#endif // UDF_DBG
467 ASSERT_REF((Fcb->ReferenceCount > fi->RefCount) || !TreeLength);
468 // If we haven't pass through all files opened
469 // in UDFCommonCreate before target file (TreeLength specfies
470 // the number of such files) dereference them.
471 // Otherwise we'll just check if the file has no references.
472#ifdef UDF_DBG
473 if(Fcb) {
474 if(TreeLength) {
475 ASSERT(Fcb->ReferenceCount);
476 ASSERT(NtReqFcb->CommonRefCount);
477 RefCount = UDFInterlockedDecrement((PLONG)&(Fcb->ReferenceCount));
478 ComRefCount = UDFInterlockedDecrement((PLONG)&(NtReqFcb->CommonRefCount));
479 }
480 } else {
481 BrutePoint();
482 }
483 if(TreeLength)
484 TreeLength--;
485 ASSERT(Fcb->OpenHandleCount <= Fcb->ReferenceCount);
486#else
487 if(TreeLength) {
488 RefCount = UDFInterlockedDecrement((PLONG)&(Fcb->ReferenceCount));
489 ComRefCount = UDFInterlockedDecrement((PLONG)&(NtReqFcb->CommonRefCount));
490 TreeLength--;
491 }
492#endif
493
494/* if(Fcb && Fcb->FCBName && Fcb->FCBName->ObjectName.Buffer) {
495 AdPrint((" %ws (%x)\n",
496 Fcb->FCBName->ObjectName.Buffer,Fcb->ReferenceCount));
497 } else if (Fcb) {
498 AdPrint((" ??? (%x)\n",Fcb->ReferenceCount));
499 } else {
500 AdPrint((" ??? (??)\n"));
501 }*/
502 // ...and delete if it has gone
503
504 if(!RefCount && !Fcb->OpenHandleCount) {
505 // no more references... current file/dir MUST DIE!!!
506 BOOLEAN AutoInherited = UDFIsAStreamDir(fi) || UDFIsAStream(fi);
507
508 if(Vcb->VCBFlags & UDF_VCB_FLAGS_RAW_DISK) {
509 // do nothing
510 } else
511#ifndef UDF_READ_ONLY_BUILD
512 if(Delete) {
513/* if(!(Fcb->FCBFlags & UDF_FCB_DIRECTORY)) {
514 // set file size to zero (for UdfInfo package)
515 // we should not do this for directories
516 UDFResizeFile__(Vcb, fi, 0);
517 }*/
519 ASSERT(Fcb->ReferenceCount < fi->RefCount);
520 UDFFlushFile__(Vcb, fi);
522 UDFCloseFile__(Vcb, fi);
523 ASSERT(Fcb->ReferenceCount == fi->RefCount);
524 Fcb->FCBFlags |= UDF_FCB_DELETED;
525 Delete = FALSE;
526 } else
527#endif //UDF_READ_ONLY_BUILD
528 if(!(Fcb->FCBFlags & UDF_FCB_DELETED)) {
529 UDFFlushFile__(Vcb, fi);
530 } else {
531// BrutePoint();
532 }
533#ifndef UDF_READ_ONLY_BUILD
534 // check if we should try to delete Parent for the next time
535 if(Fcb->FCBFlags & UDF_FCB_DELETE_PARENT)
536 Delete = TRUE;
537#endif //UDF_READ_ONLY_BUILD
538
539 // remove references to OS-specific structures
540 // to let UDF_INFO release FI & Co
541 fi->Fcb = NULL;
542 if(!ComRefCount) {
543 // CommonFcb is also completly dereferenced
544 // Kill it!
545 fi->Dloc->CommonFcb = NULL;
546 }
547
548 if((CleanCode = UDFCleanUpFile__(Vcb, fi))) {
549 // Check, if we can uninitialize & deallocate CommonFcb part
550 // kill some cross links
551 Fcb->FileInfo = NULL;
552 // release allocated resources
553 if(CleanCode & UDF_FREE_DLOC) {
554 // Obviously, it is a good time & place to release
555 // CommonFcb structure
556
557// NtReqFcb->NtReqFCBFlags &= ~UDF_NTREQ_FCB_VALID;
558 // Unitialize byte-range locks support structure
560 // Remove resources
562 UDFReleaseResource(&(NtReqFcb->MainResource));
563 if(NtReqFcb->CommonFCBHeader.Resource) {
564 UDFDeleteResource(&(NtReqFcb->MainResource));
565 UDFDeleteResource(&(NtReqFcb->PagingIoResource));
566 }
567 NtReqFcb->CommonFCBHeader.Resource =
568 NtReqFcb->CommonFCBHeader.PagingIoResource = NULL;
569 UDFDeassignAcl(NtReqFcb, AutoInherited);
570 UDFPrint(("UDFReleaseNtReqFCB: %x\n", NtReqFcb));
571#ifdef DBG
572// NtReqFcb->FileObject->FsContext2 = NULL;
573// ASSERT(NtReqFcb->FileObject);
574/* if(NtReqFcb->FileObject) {
575 ASSERT(!NtReqFcb->FileObject->FsContext2);
576 NtReqFcb->FileObject->FsContext = NULL;
577 NtReqFcb->FileObject->SectionObjectPointer = NULL;
578 }*/
579#endif //DBG
582 } else {
583 // we usually get here when the file has some opened links
585 UDFReleaseResource(&(NtReqFcb->MainResource));
586 }
587 // remove some references & free Fcb structure
588 Fcb->NTRequiredFCB = NULL;
589 Fcb->ParentFcb = NULL;
591 MyFreePool__(fi);
592 ret_val |= UDF_CLOSE_FCB_DELETED;
593 // get pointer to parent FCB
594 fi = ParentFI;
595 // free old parent's resource...
596 if(fi) {
598 UDFReleaseResource(&(ParentFcb->NTRequiredFCB->MainResource));
599 } else {
600 if(!VcbAcquired)
601 UDFReleaseResource(&(Vcb->VCBResource));
602 }
603 } else {
604 // Stop cleaning up
605
606 // Restore pointers
607 fi->Fcb = Fcb;
608 fi->Dloc->CommonFcb = NtReqFcb;
609 // free all acquired resources
611 UDFReleaseResource(&(NtReqFcb->MainResource));
612 fi = ParentFI;
613 if(fi) {
615 UDFReleaseResource(&(ParentFcb->NTRequiredFCB->MainResource));
616 } else {
617 if(!VcbAcquired)
618 UDFReleaseResource(&(Vcb->VCBResource));
619 }
620 // If we have dereferenced all parents 'associated'
621 // with input file & current file is still in use
622 // then it isn't worth walking down the tree
623 // 'cause in this case all the rest files are also used
624 if(!TreeLength)
625 break;
626// AdPrint(("Stop on referenced File/Dir\n"));
627 }
628 } else {
629 // we get to referenced file/dir. Stop search & release resource
631 UDFReleaseResource(&(NtReqFcb->MainResource));
632 if(ParentFI) {
634 UDFReleaseResource(&(ParentFcb->NTRequiredFCB->MainResource));
635 } else {
636 if(!VcbAcquired)
637 UDFReleaseResource(&(Vcb->VCBResource));
638 }
639 Delete = FALSE;
640 if(!TreeLength)
641 break;
642 fi = ParentFI;
643 }
644 }
645 if(fi) {
646 Fcb = fi->Fcb;
647 for(;TreeLength && fi;TreeLength--) {
648 if(Fcb) {
650 ASSERT(Fcb->ReferenceCount);
651 ASSERT(Fcb->NTRequiredFCB->CommonRefCount);
652 ASSERT_REF(Fcb->ReferenceCount > fi->RefCount);
653 UDFInterlockedDecrement((PLONG)&(Fcb->ReferenceCount));
654 UDFInterlockedDecrement((PLONG)&(Fcb->NTRequiredFCB->CommonRefCount));
655#ifdef UDF_DBG
656 } else {
657 BrutePoint();
658#endif
659 }
660 Fcb = ParentFcb;
661 }
662 }
663 if(!VcbAcquired)
664 UDFReleaseResource(&(Vcb->VCBResource));
665 return ret_val;
666
667} // end UDFCleanUpFcbChain()
BOOL Delete(LPCTSTR ServiceName)
Definition: delete.c:12
_In_ PFCB ParentFcb
Definition: cdprocs.h:736
VOID __fastcall UDFCleanUpFCB(PtrUDFFCB Fcb)
Definition: misc.cpp:908
#define ValidateFileInfo(fi)
Definition: env_spec_w32.h:516
#define UDFInterlockedDecrement(addr)
Definition: env_spec_w32.h:677
VOID NTAPI FsRtlUninitializeFileLock(IN PFILE_LOCK FileLock)
Definition: filelock.c:1279
long LONG
Definition: pedump.c:60
VOID UDFDeassignAcl(IN PtrUDFNTRequiredFCB NtReqFcb, IN BOOLEAN AutoInherited)
Definition: secursup.cpp:772
#define UDF_CLOSE_NTREQFCB_DELETED
Definition: protos.h:80
#define UDF_CLOSE_FCB_DELETED
Definition: protos.h:81
#define UDF_NODE_TYPE_NT_REQ_FCB
Definition: struct.h:57
#define UDF_FCB_DELETED
Definition: struct.h:314
#define UDF_FCB_DELETE_PARENT
Definition: struct.h:319
struct _FCB * ParentFcb
Definition: cdstruc.h:940
LONG RefCount
Definition: ntfs.h:535
ERESOURCE MainResource
Definition: ntfs.h:528
int32_t * PLONG
Definition: typedefs.h:58
#define UDF_VCB_FLAGS_RAW_DISK
Definition: udf_common.h:476
#define ASSERT_REF(_a_)
Definition: udf_dbg.h:267
OSSTATUS UDFCloseFile__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo)
Definition: udf_info.cpp:2994
OSSTATUS UDFFlushFile__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN ULONG FlushFlags)
Definition: udf_info.cpp:4119
uint32 UDFCleanUpFile__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo)
Definition: udf_info.cpp:2276
OSSTATUS UDFUnlinkFile__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN BOOLEAN FreeSpace)
Definition: udf_info.cpp:1766
#define UDFReferenceFile__(fi)
Definition: udf_info.h:1043
#define UDF_FREE_DLOC
Definition: udf_info.h:650

Referenced by UDFCloseResidual(), UDFCommonClose(), UDFCommonCreate(), and UDFRename().

◆ UDFCleanupVCB()

VOID UDFCleanupVCB ( IN PVCB  Vcb)

Definition at line 1428 of file fscntrl.cpp.

1431{
1432 _SEH2_TRY {
1436 BrutePoint();
1437 } _SEH2_END;
1438
1439 if(Vcb->ShutdownRegistered && Vcb->VCBDeviceObject) {
1440 IoUnregisterShutdownNotification(Vcb->VCBDeviceObject);
1441 Vcb->ShutdownRegistered = FALSE;
1442 }
1443
1444 MyFreeMemoryAndPointer(Vcb->Partitions);
1447 MyFreeMemoryAndPointer(Vcb->SparingTable);
1448
1449 if(Vcb->FSBM_Bitmap) {
1450 DbgFreePool(Vcb->FSBM_Bitmap);
1451 Vcb->FSBM_Bitmap = NULL;
1452 }
1453 if(Vcb->ZSBM_Bitmap) {
1454 DbgFreePool(Vcb->ZSBM_Bitmap);
1455 Vcb->ZSBM_Bitmap = NULL;
1456 }
1457 if(Vcb->BSBM_Bitmap) {
1458 DbgFreePool(Vcb->BSBM_Bitmap);
1459 Vcb->BSBM_Bitmap = NULL;
1460 }
1461#ifdef UDF_TRACK_ONDISK_ALLOCATION_OWNERS
1462 if(Vcb->FSBM_Bitmap_owners) {
1463 DbgFreePool(Vcb->FSBM_Bitmap_owners);
1464 Vcb->FSBM_Bitmap_owners = NULL;
1465 }
1466#endif //UDF_TRACK_ONDISK_ALLOCATION_OWNERS
1467 if(Vcb->FSBM_OldBitmap) {
1468 DbgFreePool(Vcb->FSBM_OldBitmap);
1469 Vcb->FSBM_OldBitmap = NULL;
1470 }
1471
1472 MyFreeMemoryAndPointer(Vcb->Statistics);
1473 MyFreeMemoryAndPointer(Vcb->NTRequiredFCB);
1474 MyFreeMemoryAndPointer(Vcb->VolIdent.Buffer);
1475 MyFreeMemoryAndPointer(Vcb->TargetDevName.Buffer);
1476
1477 if(Vcb->ZBuffer) {
1478 DbgFreePool(Vcb->ZBuffer);
1479 Vcb->ZBuffer = NULL;
1480 }
1481
1482 if(Vcb->fZBuffer) {
1483 DbgFreePool(Vcb->fZBuffer);
1484 Vcb->fZBuffer = NULL;
1485 }
1486
1488 MyFreeMemoryAndPointer(Vcb->WParams);
1490 MyFreeMemoryAndPointer(Vcb->TrackMap);
1491
1492} // end UDFCleanupVCB()
void UDFReleaseDlocList(IN PVCB Vcb)
Definition: dirtree.cpp:1396
#define DbgFreePool
Definition: env_spec_w32.h:334
VOID UDFReleaseFileIdCache(IN PVCB Vcb)
Definition: fileinfo.cpp:2456
#define MyFreeMemoryAndPointer(ptr)
Definition: mem_tools.h:13
VOID NTAPI IoUnregisterShutdownNotification(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1725

Referenced by UDFReleaseVCB(), and UDFVerifyVolume().

◆ UDFClose()

NTSTATUS NTAPI UDFClose ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 62 of file close.cpp.

66{
68 PtrUDFIrpContext PtrIrpContext = NULL;
69 BOOLEAN AreWeTopLevel = FALSE;
70
71 AdPrint(("UDFClose: \n"));
72
75 ASSERT(Irp);
76
77 // If we were called with our file system device object instead of a
78 // volume device object, just complete this request with STATUS_SUCCESS
79 if (UDFIsFSDevObj(DeviceObject)) {
80 // this is a close of the FSD itself
81 Irp->IoStatus.Status = RC;
82 Irp->IoStatus.Information = 0;
83
86 return(RC);
87 }
88
89 // set the top level context
90 AreWeTopLevel = UDFIsIrpTopLevel(Irp);
91
92 _SEH2_TRY {
93
94 // get an IRP context structure and issue the request
95 PtrIrpContext = UDFAllocateIrpContext(Irp, DeviceObject);
96 ASSERT(PtrIrpContext);
97
98 RC = UDFCommonClose(PtrIrpContext, Irp);
99
101
102 RC = UDFExceptionHandler(PtrIrpContext, Irp);
103
105 } _SEH2_END;
106
107 if (AreWeTopLevel) {
109 }
110
112
113 return(RC);
114}
NTSTATUS UDFCommonClose(PtrUDFIrpContext PtrIrpContext, PIRP Irp)
Definition: close.cpp:137

Referenced by UDFInitializeFunctionPointers().

◆ UDFCloseAllDelayed()

VOID UDFCloseAllDelayed ( PVCB  Vcb)

◆ UDFCloseAllXXXDelayedInDir()

NTSTATUS UDFCloseAllXXXDelayedInDir ( IN PVCB  Vcb,
IN PUDF_FILE_INFO  FileInfo,
IN BOOLEAN  System 
)

Definition at line 918 of file close.cpp.

923{
924 PUDF_FILE_INFO* PassedList = NULL;
925 ULONG PassedListSize = 0;
926 PUDF_FILE_INFO* FoundList = NULL;
927 ULONG FoundListSize = 0;
928 NTSTATUS RC;
929 ULONG i;
931 _SEH2_VOLATILE BOOLEAN AcquiredVcb = FALSE;
933 PUDF_FILE_INFO CurFileInfo;
934 PFE_LIST_ENTRY CurListPtr;
935 PFE_LIST_ENTRY* ListPtrArray = NULL;
936
937 _SEH2_TRY {
938
939 UDFPrint((" UDFCloseAllXXXDelayedInDir(): Acquire DelayedCloseResource\n"));
940 // Acquire DelayedCloseResource
941 UDFAcquireResourceExclusive(&(UDFGlobalData.DelayedCloseResource), TRUE);
942 ResAcq = TRUE;
943
944 UDFAcquireResourceExclusive(&(Vcb->VCBResource), TRUE);
945 AcquiredVcb = TRUE;
946
949 &PassedList, &PassedListSize, &FoundList, &FoundListSize);
950
951 if(!NT_SUCCESS(RC)) {
952 UDFPrint((" UDFBuildTreeItemsList(): error %x\n", RC));
953 try_return(RC);
954 }
955
956 if(!FoundList || !FoundListSize) {
958 }
959
960 // build array of referenced pointers
961 ListPtrArray = (PFE_LIST_ENTRY*)(MyAllocatePool__(NonPagedPool, FoundListSize*sizeof(PFE_LIST_ENTRY)));
962 if(!ListPtrArray) {
963 UDFPrint((" Can't alloc ListPtrArray for %x items\n", FoundListSize));
965 }
966
967 for(i=0;i<FoundListSize;i++) {
968
969 _SEH2_TRY {
970
971 CurFileInfo = FoundList[i];
972 if(!CurFileInfo->ListPtr) {
974 if(!CurFileInfo->ListPtr) {
975 UDFPrint((" Can't alloc ListPtrEntry for items %x\n", i));
977 }
978 CurFileInfo->ListPtr->FileInfo = CurFileInfo;
979 CurFileInfo->ListPtr->EntryRefCount = 0;
980 }
981 CurFileInfo->ListPtr->EntryRefCount++;
982 ListPtrArray[i] = CurFileInfo->ListPtr;
983
985 BrutePoint();
986 } _SEH2_END;
987 }
988
989 UDFReleaseResource(&(Vcb->VCBResource));
990 AcquiredVcb = FALSE;
991
992 if(System) {
993 // Remove from system queue
996 BOOLEAN NoDelayed = (Vcb->VCBFlags & UDF_VCB_FLAGS_NO_DELAYED_CLOSE) ?
997 TRUE : FALSE;
998
1000 for(i=FoundListSize;i>0;i--) {
1001 UDFAcquireResourceExclusive(&(Vcb->VCBResource), TRUE);
1002 AcquiredVcb = TRUE;
1003 _SEH2_TRY {
1004
1005 CurListPtr = ListPtrArray[i-1];
1006 CurFileInfo = CurListPtr->FileInfo;
1007 if(CurFileInfo &&
1008 (Fcb = CurFileInfo->Fcb)) {
1009 NtReqFcb = Fcb->NTRequiredFCB;
1010 ASSERT((ULONG_PTR)NtReqFcb > 0x1000);
1011// ASSERT((ULONG)(NtReqFcb->SectionObject) > 0x1000);
1012 if(!(NtReqFcb->NtReqFCBFlags & UDF_NTREQ_FCB_DELETED) &&
1013 (NtReqFcb->NtReqFCBFlags & UDF_NTREQ_FCB_MODIFIED)) {
1014 MmPrint((" CcFlushCache()\n"));
1015 CcFlushCache(&(NtReqFcb->SectionObject), NULL, 0, &IoStatus);
1016 }
1017 if(NtReqFcb->SectionObject.ImageSectionObject) {
1018 MmPrint((" MmFlushImageSection()\n"));
1019 MmFlushImageSection(&(NtReqFcb->SectionObject), MmFlushForWrite);
1020 }
1021 if(NtReqFcb->SectionObject.DataSectionObject) {
1022 MmPrint((" CcPurgeCacheSection()\n"));
1023 CcPurgeCacheSection( &(NtReqFcb->SectionObject), NULL, 0, FALSE );
1024 }
1025 } else {
1026 MmPrint((" Skip item: deleted\n"));
1027 }
1028 CurListPtr->EntryRefCount--;
1029 if(!CurListPtr->EntryRefCount) {
1030 if(CurListPtr->FileInfo)
1031 CurListPtr->FileInfo->ListPtr = NULL;
1032 MyFreePool__(CurListPtr);
1033 }
1035 BrutePoint();
1036 } _SEH2_END;
1037 UDFReleaseResource(&(Vcb->VCBResource));
1038 AcquiredVcb = FALSE;
1039 }
1040 if(!NoDelayed)
1041 Vcb->VCBFlags &= ~UDF_VCB_FLAGS_NO_DELAYED_CLOSE;
1042 } else {
1043 // Remove from internal queue
1044 PtrUDFIrpContextLite NextIrpContextLite;
1045
1046 for(i=FoundListSize;i>0;i--) {
1047
1048 UDFAcquireResourceExclusive(&(Vcb->VCBResource), TRUE);
1049 AcquiredVcb = TRUE;
1050
1051 CurListPtr = ListPtrArray[i-1];
1052 CurFileInfo = CurListPtr->FileInfo;
1053
1054 if(CurFileInfo &&
1055 CurFileInfo->Fcb &&
1056 (NextIrpContextLite = CurFileInfo->Fcb->IrpContextLite)) {
1057 RemoveEntryList( &(NextIrpContextLite->DelayedCloseLinks) );
1058 if (NextIrpContextLite->Fcb->FCBFlags & UDF_FCB_DIRECTORY) {
1059// BrutePoint();
1060 UDFGlobalData.DirDelayedCloseCount--;
1061 } else {
1062 UDFGlobalData.DelayedCloseCount--;
1063 }
1064 UDFDoDelayedClose(NextIrpContextLite);
1065 }
1066 CurListPtr->EntryRefCount--;
1067 if(!CurListPtr->EntryRefCount) {
1068 if(CurListPtr->FileInfo)
1069 CurListPtr->FileInfo->ListPtr = NULL;
1070 MyFreePool__(CurListPtr);
1071 }
1072 UDFReleaseResource(&(Vcb->VCBResource));
1073 AcquiredVcb = FALSE;
1074 }
1075 }
1076 RC = STATUS_SUCCESS;
1077
1078try_exit: NOTHING;
1079
1080 } _SEH2_FINALLY {
1081 // release Vcb
1082 if(AcquiredVcb)
1083 UDFReleaseResource(&(Vcb->VCBResource));
1084 // Release DelayedCloseResource
1085 if(ResAcq)
1086 UDFReleaseResource(&(UDFGlobalData.DelayedCloseResource));
1087
1088 if(ListPtrArray)
1089 MyFreePool__(ListPtrArray);
1090 if(PassedList)
1091 MyFreePool__(PassedList);
1092 if(FoundList)
1093 MyFreePool__(FoundList);
1094 } _SEH2_END;
1095
1096 return RC;
1097} // end UDFCloseAllXXXDelayedInDir(
VOID NTAPI CcFlushCache(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, OUT OPTIONAL PIO_STATUS_BLOCK IoStatus)
Definition: cachesub.c:222
#define try_return(S)
Definition: cdprocs.h:2179
VOID UDFDoDelayedClose(IN PtrUDFIrpContextLite NextIrpContextLite)
Definition: close.cpp:670
NTSTATUS UDFBuildTreeItemsList(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN PCHECK_TREE_ITEM CheckItemProc, IN PUDF_DATALOC_INFO **PassedList, IN PULONG PassedListSize, IN PUDF_DATALOC_INFO **FoundList, IN PULONG FoundListSize)
BOOLEAN UDFIsLastClose(PUDF_FILE_INFO FileInfo)
Definition: close.cpp:903
BOOLEAN UDFIsInDelayedCloseQueue(PUDF_FILE_INFO FileInfo)
Definition: close.cpp:895
#define _SEH2_FINALLY
Definition: filesup.c:21
BOOLEAN NTAPI CcPurgeCacheSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN OPTIONAL PLARGE_INTEGER FileOffset, IN ULONG Length, IN BOOLEAN UninitializeCacheMaps)
Definition: fssup.c:386
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define NOTHING
Definition: input_list.c:10
__in UCHAR __in POWER_STATE __in_opt PVOID __in PIO_STATUS_BLOCK IoStatus
Definition: mxum.h:159
#define _SEH2_VOLATILE
Definition: pseh2_64.h:163
BOOLEAN NTAPI MmFlushImageSection(IN PSECTION_OBJECT_POINTERS SectionObjectPointer, IN MMFLUSH_TYPE FlushType)
Definition: section.c:4356
#define UDF_NTREQ_FCB_DELETED
Definition: struct.h:235
#define UDF_NTREQ_FCB_MODIFIED
Definition: struct.h:236
Definition: udf_rel.h:414
ULONG EntryRefCount
Definition: udf_rel.h:416
PUDF_FILE_INFO FileInfo
Definition: udf_rel.h:415
LIST_ENTRY DelayedCloseLinks
Definition: struct.h:410
_UDFFileControlBlock * Fcb
Definition: struct.h:408
struct _FE_LIST_ENTRY * ListPtr
Definition: udf_rel.h:411
struct _UDFFileControlBlock * Fcb
Definition: udf_rel.h:362
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define UDF_VCB_FLAGS_NO_DELAYED_CLOSE
Definition: udf_common.h:480
struct _FE_LIST_ENTRY * PFE_LIST_ENTRY

◆ UDFCloseFileInfoChain()

NTSTATUS UDFCloseFileInfoChain ( IN PVCB  Vcb,
IN PUDF_FILE_INFO  fi,
IN ULONG  TreeLength,
IN BOOLEAN  VcbAcquired 
)

Definition at line 696 of file cleanup.cpp.

702{
703 PUDF_FILE_INFO ParentFI;
707 NTSTATUS RC2;
708
709 // we can't process Tree until we can acquire Vcb
710 if(!VcbAcquired)
711 UDFAcquireResourceShared(&(Vcb->VCBResource),TRUE);
712
713 AdPrint(("UDFCloseFileInfoChain\n"));
714 for(; TreeLength && fi; TreeLength--) {
715
716 // close parent chain (if any)
717 // if we started path parsing not from RootDir on Create,
718 // we would never get RootDir here
720
721 // acquire parent
722 if((ParentFI = fi->ParentFile)) {
723 ParentFcb = fi->Fcb->ParentFcb;
725 ASSERT(ParentFcb->NTRequiredFCB);
728 ASSERT(ParentFcb->NodeIdentifier.NodeType == UDF_NODE_TYPE_FCB);
729 ASSERT(ParentFcb->NTRequiredFCB->CommonFCBHeader.NodeTypeCode == UDF_NODE_TYPE_NT_REQ_FCB);
730 } else {
731 AdPrint(("Acquiring VCB...\n"));
732 UDFAcquireResourceShared(&(Vcb->VCBResource),TRUE);
733 AdPrint(("Done\n"));
734 }
735 // acquire current file/dir
736 // we must assure that no more threads try to reuse this object
737 if((Fcb = fi->Fcb)) {
738 UDF_CHECK_PAGING_IO_RESOURCE(Fcb->NTRequiredFCB);
740 ASSERT_REF(Fcb->ReferenceCount >= fi->RefCount);
741 if(!(Fcb->FCBFlags & UDF_FCB_DELETED) &&
742 (Fcb->FCBFlags & UDF_FCB_VALID))
743 UDFWriteSecurity(Vcb, Fcb, &(Fcb->NTRequiredFCB->SecurityDesc));
744 RC2 = UDFCloseFile__(Vcb,fi);
745 if(!NT_SUCCESS(RC2))
746 RC = RC2;
747 ASSERT_REF(Fcb->ReferenceCount > fi->RefCount);
748 UDF_CHECK_PAGING_IO_RESOURCE(Fcb->NTRequiredFCB);
749 UDFReleaseResource(&(Fcb->NTRequiredFCB->MainResource));
750 } else {
751 BrutePoint();
752 RC2 = UDFCloseFile__(Vcb,fi);
753 if(!NT_SUCCESS(RC2))
754 RC = RC2;
755 }
756
757 if(ParentFI) {
759 UDFReleaseResource(&(ParentFcb->NTRequiredFCB->MainResource));
760 } else {
761 UDFReleaseResource(&(Vcb->VCBResource));
762 }
763 fi = ParentFI;
764 }
765
766 if(!VcbAcquired)
767 UDFReleaseResource(&(Vcb->VCBResource));
768
769 return RC;
770
771} // end UDFCloseFileInfoChain()
NTSTATUS UDFWriteSecurity(IN PVCB Vcb, IN PtrUDFFCB Fcb, IN PSECURITY_DESCRIPTOR *SecurityDesc)
Definition: secursup.cpp:796
#define UDF_FCB_VALID
Definition: struct.h:300

Referenced by UDFCommonCleanup(), and UDFCommonCreate().

◆ UDFCloseResidual()

VOID UDFCloseResidual ( IN PVCB  Vcb)

Definition at line 1349 of file fscntrl.cpp.

1352{
1353 // Deinitialize Non-alloc file
1354 if(Vcb->VCBOpenCount)
1355 UDFInterlockedDecrement((PLONG)&(Vcb->VCBOpenCount));
1356 UDFPrint(("UDFCloseResidual: NonAllocFileInfo %x\n", Vcb->NonAllocFileInfo));
1357 if(Vcb->NonAllocFileInfo) {
1358 UDFCloseFile__(Vcb,Vcb->NonAllocFileInfo);
1359 UDFCleanUpFile__(Vcb, Vcb->NonAllocFileInfo);
1360 MyFreePool__(Vcb->NonAllocFileInfo);
1361 Vcb->NonAllocFileInfo = NULL;
1362 }
1363 // Deinitialize Unique ID Mapping
1364 UDFPrint(("UDFCloseResidual: NonAllocFileInfo %x\n", Vcb->NonAllocFileInfo));
1365 if(Vcb->UniqueIDMapFileInfo) {
1366 UDFCloseFile__(Vcb,Vcb->UniqueIDMapFileInfo);
1367 UDFCleanUpFile__(Vcb, Vcb->UniqueIDMapFileInfo);
1368 MyFreePool__(Vcb->UniqueIDMapFileInfo);
1369 Vcb->UniqueIDMapFileInfo = NULL;
1370 }
1371 // Deinitialize VAT file
1372 UDFPrint(("UDFCloseResidual: VatFileInfo %x\n", Vcb->VatFileInfo));
1373 if(Vcb->VatFileInfo) {
1374 UDFCloseFile__(Vcb,Vcb->VatFileInfo);
1375 UDFCleanUpFile__(Vcb, Vcb->VatFileInfo);
1376 MyFreePool__(Vcb->VatFileInfo);
1377 Vcb->VatFileInfo = NULL;
1378 }
1379 // System StreamDir
1380 UDFPrint(("UDFCloseResidual: SysSDirFileInfo %x\n", Vcb->SysSDirFileInfo));
1381 if(Vcb->SysSDirFileInfo) {
1382 UDFCloseFile__(Vcb, Vcb->SysSDirFileInfo);
1383 UDFCleanUpFile__(Vcb, Vcb->SysSDirFileInfo);
1384 MyFreePool__(Vcb->SysSDirFileInfo);
1385 Vcb->SysSDirFileInfo = NULL;
1386 }
1387/* // Deinitialize root dir fcb
1388 if(Vcb->RootDirFCB) {
1389 UDFCloseFile__(Vcb,Vcb->RootDirFCB->FileInfo);
1390 UDFCleanUpFile__(Vcb, Vcb->RootDirFCB->FileInfo);
1391 MyFreePool__(Vcb->RootDirFCB->FileInfo);
1392 UDFCleanUpFCB(Vcb->RootDirFCB);
1393 // Remove root FCB reference in vcb
1394 if(Vcb->VCBOpenCount) Vcb->VCBOpenCount--;
1395 }
1396
1397 // Deinitialize Non-alloc file
1398 if(Vcb->VCBOpenCount) Vcb->VCBOpenCount--;
1399 if(Vcb->NonAllocFileInfo) {
1400 UDFCloseFile__(Vcb,Vcb->NonAllocFileInfo);
1401 // We must release VCB here !!!!
1402// UDFCleanUpFcbChain(Vcb, Vcb->NonAllocFileInfo, 1);
1403 Vcb->NonAllocFileInfo = NULL;
1404 }
1405 // Deinitialize VAT file
1406 if(Vcb->VatFileInfo) {
1407 UDFCloseFile__(Vcb,Vcb->VatFileInfo);
1408 // We must release VCB here !!!!
1409// UDFCleanUpFcbChain(Vcb, Vcb->VatFileInfo, 1);
1410 Vcb->VatFileInfo = NULL;
1411 }*/
1412
1413 // Deinitialize root dir fcb
1414 UDFPrint(("UDFCloseResidual: RootDirFCB %x\n", Vcb->RootDirFCB));
1415 if(Vcb->RootDirFCB) {
1416 UDFCloseFile__(Vcb,Vcb->RootDirFCB->FileInfo);
1417 if(Vcb->RootDirFCB->OpenHandleCount)
1418 Vcb->RootDirFCB->OpenHandleCount--;
1419 UDFCleanUpFcbChain(Vcb, Vcb->RootDirFCB->FileInfo, 1, TRUE);
1420 // Remove root FCB reference in vcb
1421 if(Vcb->VCBOpenCount)
1422 UDFInterlockedDecrement((PLONG)&(Vcb->VCBOpenCount));
1423 Vcb->RootDirFCB = NULL;
1424 }
1425} // end UDFCloseResidual()
ULONG UDFCleanUpFcbChain(IN PVCB Vcb, IN PUDF_FILE_INFO fi, IN ULONG TreeLength, IN BOOLEAN VcbAcquired)
Definition: close.cpp:400

Referenced by UDFDismountVcb(), and UDFMountVolume().

◆ UDFCommonCleanup()

NTSTATUS UDFCommonCleanup ( PtrUDFIrpContext  PtrIrpContext,
PIRP  Irp 
)

Definition at line 126 of file cleanup.cpp.

129{
132 NTSTATUS RC2;
137 PVCB Vcb = NULL;
139 ULONG lc = 0;
140 BOOLEAN AcquiredVcb = FALSE;
141 BOOLEAN AcquiredFCB = FALSE;
142 BOOLEAN AcquiredParentFCB = FALSE;
143
144// BOOLEAN CompleteIrp = TRUE;
145// BOOLEAN PostRequest = FALSE;
146 BOOLEAN ChangeTime = FALSE;
147#ifdef UDF_DBG
148 BOOLEAN CanWait = FALSE;
149#endif // UDF_DBG
150 BOOLEAN ForcedCleanUp = FALSE;
151
152 PUDF_FILE_INFO NextFileInfo = NULL;
153#ifdef UDF_DBG
154 UNICODE_STRING CurName;
155 PDIR_INDEX_HDR DirNdx;
156#endif // UDF_DBG
157// PUDF_DATALOC_INFO Dloc;
158
159 TmPrint(("UDFCommonCleanup\n"));
160
161// BrutePoint();
162
163 _SEH2_TRY {
164 // First, get a pointer to the current I/O stack location
167
169
170 // Get the FCB and CCB pointers
171 Ccb = (PtrUDFCCB)(FileObject->FsContext2);
172 ASSERT(Ccb);
173 Fcb = Ccb->Fcb;
174 ASSERT(Fcb);
175
176 Vcb = (PVCB)(PtrIrpContext->TargetDeviceObject->DeviceExtension);
177 ASSERT(Vcb);
178 ASSERT(Vcb->NodeIdentifier.NodeType == UDF_NODE_TYPE_VCB);
179// Vcb->VCBFlags |= UDF_VCB_SKIP_EJECT_CHECK;
180#ifdef UDF_DBG
181 CanWait = (PtrIrpContext->IrpContextFlags & UDF_IRP_CONTEXT_CAN_BLOCK) ? TRUE : FALSE;
182 AdPrint((" %s\n", CanWait ? "Wt" : "nw"));
183 ASSERT(CanWait);
184#endif // UDF_DBG
185 UDFAcquireResourceShared(&(Vcb->VCBResource), TRUE);
186 AcquiredVcb = TRUE;
187 // Steps we shall take at this point are:
188 // (a) Acquire the file (FCB) exclusively
189 // (b) Flush file data to disk
190 // (c) Talk to the FSRTL package (if we use it) about pending oplocks.
191 // (d) Notify the FSRTL package for use with pending notification IRPs
192 // (e) Unlock byte-range locks (if any were acquired by process)
193 // (f) Update time stamp values (e.g. fast-IO had been performed)
194 // (g) Inform the Cache Manager to uninitialize Cache Maps ...
195 // and other similar stuff.
196 // BrutePoint();
197 NtReqFcb = Fcb->NTRequiredFCB;
198
199 if (Fcb->NodeIdentifier.NodeType == UDF_NODE_TYPE_VCB) {
200 AdPrint(("Cleaning up Volume\n"));
201 AdPrint(("UDF: OpenHandleCount: %x\n",Fcb->OpenHandleCount));
202
204 UDFInterlockedDecrement((PLONG)&(Vcb->VCBHandleCount));
205 if(FileObject->Flags & FO_CACHE_SUPPORTED) {
206 // we've cached close
207 UDFInterlockedDecrement((PLONG)&(Fcb->CachedOpenHandleCount));
208 }
209 ASSERT(Fcb->OpenHandleCount <= (Fcb->ReferenceCount-1));
210
211 // If this handle had write access, and actually wrote something,
212 // flush the device buffers, and then set the verify bit now
213 // just to be safe (in case there is no dismount).
214 if( FileObject->WriteAccess &&
215 (FileObject->Flags & FO_FILE_MODIFIED)) {
216
217 Vcb->Vpb->RealDevice->Flags |= DO_VERIFY_VOLUME;
218 }
219 // User may decide to close locked volume without call to unlock proc
220 // So, handle this situation properly & unlock it now...
221 if (FileObject == Vcb->VolumeLockFileObject) {
222 Vcb->VolumeLockFileObject = NULL;
223 Vcb->VolumeLockPID = -1;
224 Vcb->VCBFlags &= ~UDF_VCB_FLAGS_VOLUME_LOCKED;
225 Vcb->Vpb->Flags &= ~VPB_LOCKED;
227 }
228
229 MmPrint((" CcUninitializeCacheMap()\n"));
231 // reset device
232 if(!(Vcb->VCBFlags & UDF_VCB_FLAGS_VOLUME_MOUNTED) &&
233 (Vcb->VCBFlags & UDF_VCB_FLAGS_OUR_DEVICE_DRIVER)) {
234 // this call doesn't modify data buffer
235 // it just requires its presence
236 UDFResetDeviceDriver(Vcb, Vcb->TargetDeviceObject, TRUE);
237 }
238 // We must clean up the share access at this time, since we may not
239 // get a Close call for awhile if the file was mapped through this
240 // File Object.
241 IoRemoveShareAccess( FileObject, &(NtReqFcb->FCBShareAccess) );
242
244 }
245// BrutePoint();
246#ifdef UDF_DBG
247 DirNdx = UDFGetDirIndexByFileInfo(Fcb->FileInfo);
248 if(DirNdx) {
249 CurName.Buffer = UDFDirIndex(DirNdx, Fcb->FileInfo->Index)->FName.Buffer;
250 if(CurName.Buffer) {
251 AdPrint(("Cleaning up file: %ws %8.8x\n", CurName.Buffer, FileObject));
252 } else {
253 AdPrint(("Cleaning up file: ??? \n"));
254 }
255 }
256#endif //UDF_DBG
257 AdPrint(("UDF: OpenHandleCount: %x\n",Fcb->OpenHandleCount));
258 // Acquire parent object
259 if(Fcb->FileInfo->ParentFile) {
260 UDF_CHECK_PAGING_IO_RESOURCE(Fcb->FileInfo->ParentFile->Fcb->NTRequiredFCB);
261 UDFAcquireResourceExclusive(&(Fcb->FileInfo->ParentFile->Fcb->NTRequiredFCB->MainResource),TRUE);
262 } else {
263 UDFAcquireResourceShared(&(Vcb->VCBResource),TRUE);
264 }
265 AcquiredParentFCB = TRUE;
266 // Acquire current object
268 UDFAcquireResourceExclusive(&(NtReqFcb->MainResource),TRUE);
269 AcquiredFCB = TRUE;
270 // dereference object
272 UDFInterlockedDecrement((PLONG)&(Vcb->VCBHandleCount));
273 if(FileObject->Flags & FO_CACHE_SUPPORTED) {
274 // we've cached close
275 UDFInterlockedDecrement((PLONG)&(Fcb->CachedOpenHandleCount));
276 }
277 ASSERT(Fcb->OpenHandleCount <= (Fcb->ReferenceCount-1));
278 // check if Ccb being cleaned up has DeleteOnClose flag set
279#ifndef UDF_READ_ONLY_BUILD
280 if(Ccb->CCBFlags & UDF_CCB_DELETE_ON_CLOSE) {
281 AdPrint((" DeleteOnClose\n"));
282 // Ok, now we'll become 'delete on close'...
283 ASSERT(!(Fcb->FCBFlags & UDF_FCB_ROOT_DIRECTORY));
284 Fcb->FCBFlags |= UDF_FCB_DELETE_ON_CLOSE;
285 FileObject->DeletePending = TRUE;
286 // Report this to the dir notify package for a directory.
287 if(Fcb->FCBFlags & UDF_FCB_DIRECTORY) {
288 FsRtlNotifyFullChangeDirectory( Vcb->NotifyIRPMutex, &(Vcb->NextNotifyIRP),
290 0, NULL, NULL, NULL );
291 }
292 }
293#endif //UDF_READ_ONLY_BUILD
294
295 if(!(Fcb->FCBFlags & UDF_FCB_DIRECTORY)) {
296 // Unlock all outstanding file locks.
297 FsRtlFastUnlockAll(&(NtReqFcb->FileLock),
300 NULL);
301 }
302 // get Link count
303 lc = UDFGetFileLinkCount(Fcb->FileInfo);
304
305#ifndef UDF_READ_ONLY_BUILD
306 if( (Fcb->FCBFlags & UDF_FCB_DELETE_ON_CLOSE) &&
307 !(Fcb->OpenHandleCount)) {
308 // This can be useful for Streams, those were brutally deleted
309 // (together with parent object)
310 ASSERT(!(Fcb->FCBFlags & UDF_FCB_ROOT_DIRECTORY));
311 FileObject->DeletePending = TRUE;
312
313 // we should mark all streams of the file being deleted
314 // for deletion too, if there are no more Links to
315 // main data stream
316 if((lc <= 1) &&
317 !UDFIsSDirDeleted(Fcb->FileInfo->Dloc->SDirInfo)) {
318 RC = UDFMarkStreamsForDeletion(Vcb, Fcb, TRUE); // Delete
319 }
320 // we can release these resources 'cause UDF_FCB_DELETE_ON_CLOSE
321 // flag is already set & the file can't be opened
323 UDFReleaseResource(&(NtReqFcb->MainResource));
324 AcquiredFCB = FALSE;
325 if(Fcb->FileInfo->ParentFile) {
327 UDFReleaseResource(&(Fcb->ParentFcb->NTRequiredFCB->MainResource));
328 } else {
329 UDFReleaseResource(&(Vcb->VCBResource));
330 }
331 AcquiredParentFCB = FALSE;
332 UDFReleaseResource(&(Vcb->VCBResource));
333 AcquiredVcb = FALSE;
334
335 // Make system to issue last Close request
336 // for our Target ...
338
339#ifdef UDF_DELAYED_CLOSE
340 // remove file from our DelayedClose queue
342 ASSERT(!Fcb->IrpContextLite);
343#endif //UDF_DELAYED_CLOSE
344
345 UDFAcquireResourceShared(&(Vcb->VCBResource), TRUE);
346 AcquiredVcb = TRUE;
347 if(Fcb->FileInfo->ParentFile) {
349 UDFAcquireResourceExclusive(&(Fcb->ParentFcb->NTRequiredFCB->MainResource),TRUE);
350 } else {
351 UDFAcquireResourceShared(&(Vcb->VCBResource),TRUE);
352 }
353 AcquiredParentFCB = TRUE;
355 UDFAcquireResourceExclusive(&(NtReqFcb->MainResource),TRUE);
356 AcquiredFCB = TRUE;
357
358 // we should set file sizes to zero if there are no more
359 // links to this file
360 if(lc <= 1) {
361 // Synchronize here with paging IO
362 UDFAcquireResourceExclusive(&(NtReqFcb->PagingIoResource),TRUE);
363 // set file size to zero (for system cache manager)
364// NtReqFcb->CommonFCBHeader.ValidDataLength.QuadPart =
365 NtReqFcb->CommonFCBHeader.FileSize.QuadPart =
366 NtReqFcb->CommonFCBHeader.ValidDataLength.QuadPart = 0;
367 CcSetFileSizes(FileObject, (PCC_FILE_SIZES)&(NtReqFcb->CommonFCBHeader.AllocationSize));
368
369 UDFReleaseResource(&(NtReqFcb->PagingIoResource));
370 }
371 }
372#endif //UDF_READ_ONLY_BUILD
373
374#ifdef UDF_DELAYED_CLOSE
375 if ((Fcb->ReferenceCount == 1) &&
376 /*(Fcb->NodeIdentifier.NodeType != UDF_NODE_TYPE_VCB) &&*/ // see above
377 (!(Fcb->FCBFlags & UDF_FCB_DELETE_ON_CLOSE)) ) {
378 Fcb->FCBFlags |= UDF_FCB_DELAY_CLOSE;
379 }
380#endif //UDF_DELAYED_CLOSE
381
382 NextFileInfo = Fcb->FileInfo;
383
384#ifndef UDF_READ_ONLY_BUILD
385 // do we need to delete it now ?
386 if( (Fcb->FCBFlags & UDF_FCB_DELETE_ON_CLOSE) &&
387 !(Fcb->OpenHandleCount)) {
388
389 // can we do it ?
390 if(Fcb->FCBFlags & UDF_FCB_DIRECTORY) {
391 ASSERT(!(Fcb->FCBFlags & UDF_FCB_ROOT_DIRECTORY));
392 if(!UDFIsDirEmpty__(NextFileInfo)) {
393 // forget about it
394 Fcb->FCBFlags &= ~UDF_FCB_DELETE_ON_CLOSE;
395 goto DiscardDelete;
396 }
397 } else
398 if (lc <= 1) {
399 // Synchronize here with paging IO
400 BOOLEAN AcquiredPagingIo;
401 AcquiredPagingIo = UDFAcquireResourceExclusiveWithCheck(&(NtReqFcb->PagingIoResource));
402 // set file size to zero (for UdfInfo package)
403 // we should not do this for directories and linked files
404 UDFResizeFile__(Vcb, NextFileInfo, 0);
405 if(AcquiredPagingIo) {
406 UDFReleaseResource(&(NtReqFcb->PagingIoResource));
407 }
408 }
409 // mark parent object for deletion if requested
410 if((Fcb->FCBFlags & UDF_FCB_DELETE_PARENT) &&
411 Fcb->ParentFcb) {
414 }
415 // flush file. It is required by UDFUnlinkFile__()
416 RC = UDFFlushFile__(Vcb, NextFileInfo);
417 if(!NT_SUCCESS(RC)) {
418 AdPrint(("Error flushing file !!!\n"));
419 }
420 // try to unlink
421 if((RC = UDFUnlinkFile__(Vcb, NextFileInfo, TRUE)) == STATUS_CANNOT_DELETE) {
422 // If we can't delete file with Streams due to references,
423 // mark SDir & Streams
424 // for Deletion. We shall also set DELETE_PARENT flag to
425 // force Deletion of the current file later... when curently
426 // opened Streams would be cleaned up.
427
428 // WARNING! We should keep SDir & Streams if there is a
429 // link to this file
430 if(NextFileInfo->Dloc &&
431 NextFileInfo->Dloc->SDirInfo &&
432 NextFileInfo->Dloc->SDirInfo->Fcb) {
433
434 BrutePoint();
435 if(!UDFIsSDirDeleted(NextFileInfo->Dloc->SDirInfo)) {
436// RC = UDFMarkStreamsForDeletion(Vcb, Fcb, TRUE); // Delete
437//#ifdef UDF_ALLOW_PRETEND_DELETED
438 UDFPretendFileDeleted__(Vcb, Fcb->FileInfo);
439//#endif //UDF_ALLOW_PRETEND_DELETED
440 }
441 goto NotifyDelete;
442
443 } else {
444 // Getting here means that we can't delete file because of
445 // References/PemissionsDenied/Smth.Else,
446 // but not Linked+OpenedStream
447 BrutePoint();
448// RC = STATUS_SUCCESS;
449 goto DiscardDelete_1;
450 }
451 } else {
452DiscardDelete_1:
453 // We have got an ugly ERROR, or
454 // file is deleted, so forget about it
455 ASSERT(!(Fcb->FCBFlags & UDF_FCB_ROOT_DIRECTORY));
456 ForcedCleanUp = TRUE;
457 if(NT_SUCCESS(RC))
458 Fcb->FCBFlags &= ~UDF_FCB_DELETE_ON_CLOSE;
459 Fcb->FCBFlags |= UDF_FCB_DELETED;
460 RC = STATUS_SUCCESS;
461 }
462NotifyDelete:
463 // We should prevent SetEOF operations on completly
464 // deleted data streams
465 if(lc < 1) {
466 NtReqFcb->NtReqFCBFlags |= UDF_NTREQ_FCB_DELETED;
467 }
468 // Report that we have removed an entry.
469 if(UDFIsAStream(NextFileInfo)) {
470 UDFNotifyFullReportChange( Vcb, NextFileInfo,
473 } else {
474 UDFNotifyFullReportChange( Vcb, NextFileInfo,
477 }
478 } else
479 if(Fcb->FCBFlags & UDF_FCB_DELETE_ON_CLOSE) {
480DiscardDelete:
481 UDFNotifyFullReportChange( Vcb, NextFileInfo,
484 0,
486 }
487#endif //UDF_READ_ONLY_BUILD
488
489 if(Fcb->FCBFlags & UDF_FCB_DIRECTORY) {
490 // Report to the dir notify package for a directory.
491 FsRtlNotifyCleanup( Vcb->NotifyIRPMutex, &(Vcb->NextNotifyIRP), (PVOID)Ccb );
492 }
493
494 // we can't purge Cache when more than one link exists
495 if(lc > 1) {
496 ForcedCleanUp = FALSE;
497 }
498
499 if ( (FileObject->Flags & FO_CACHE_SUPPORTED) &&
500 (NtReqFcb->SectionObject.DataSectionObject) ) {
501 BOOLEAN LastNonCached = (!Fcb->CachedOpenHandleCount &&
503 // If this was the last cached open, and there are open
504 // non-cached handles, attempt a flush and purge operation
505 // to avoid cache coherency overhead from these non-cached
506 // handles later. We ignore any I/O errors from the flush.
507 // We shall not flush deleted files
508 RC = STATUS_SUCCESS;
509 if( LastNonCached
510 ||
511 (!Fcb->OpenHandleCount &&
512 !ForcedCleanUp) ) {
513
514#ifndef UDF_READ_ONLY_BUILD
515 LONGLONG OldFileSize, NewFileSize;
516
517 if( (OldFileSize = NtReqFcb->CommonFCBHeader.ValidDataLength.QuadPart) <
518 (NewFileSize = NtReqFcb->CommonFCBHeader.FileSize.QuadPart)) {
519/* UDFZeroDataEx(NtReqFcb,
520 OldFileSize,
521 NewFileSize - OldFileSize,
522 TRUE, Vcb, FileObject);*/
523
524 NtReqFcb->CommonFCBHeader.ValidDataLength.QuadPart = NewFileSize;
525 }
526#endif //UDF_READ_ONLY_BUILD
527 MmPrint((" CcFlushCache()\n"));
528 CcFlushCache( &(NtReqFcb->SectionObject), NULL, 0, &IoStatus );
529 if(!NT_SUCCESS(IoStatus.Status)) {
530 MmPrint((" CcFlushCache() error: %x\n", IoStatus.Status));
531 RC = IoStatus.Status;
532 }
533 }
534 // If file is deleted or it is last cached open, but there are
535 // some non-cached handles we should purge cache section
536 if(ForcedCleanUp || LastNonCached) {
537 if(NtReqFcb->SectionObject.DataSectionObject) {
538 MmPrint((" CcPurgeCacheSection()\n"));
539 CcPurgeCacheSection( &(NtReqFcb->SectionObject), NULL, 0, FALSE );
540 }
541/* MmPrint((" CcPurgeCacheSection()\n"));
542 CcPurgeCacheSection( &(NtReqFcb->SectionObject), NULL, 0, FALSE );*/
543 }
544 // we needn't Flush here. It will be done in UDFCloseFileInfoChain()
545 }
546
547#ifndef UDF_READ_ONLY_BUILD
548 // Update FileTimes & Attrs
549 if(!(Vcb->VCBFlags & UDF_VCB_FLAGS_VOLUME_READ_ONLY) &&
550 !(Fcb->FCBFlags & (UDF_FCB_DELETE_ON_CLOSE |
552 UDF_FCB_DIRECTORY |
553 UDF_FCB_READ_ONLY*/)) &&
554 !UDFIsAStreamDir(NextFileInfo)) {
556 LONGLONG ASize;
558 // Check if we should set ARCHIVE bit & LastWriteTime
559 if(FileObject->Flags & FO_FILE_MODIFIED) {
560 ULONG Attr;
561 PDIR_INDEX_ITEM DirNdx;
562 DirNdx = UDFDirIndex(UDFGetDirIndexByFileInfo(NextFileInfo), NextFileInfo->Index);
563 ASSERT(DirNdx);
564 // Archive bit
565 if(!(Ccb->CCBFlags & UDF_CCB_ATTRIBUTES_SET) &&
566 (Vcb->CompatFlags & UDF_VCB_IC_UPDATE_ARCH_BIT)) {
567 Attr = UDFAttributesToNT(DirNdx, NextFileInfo->Dloc->FileEntry);
568 if(!(Attr & FILE_ATTRIBUTE_ARCHIVE))
569 UDFAttributesToUDF(DirNdx, NextFileInfo->Dloc->FileEntry, Attr | FILE_ATTRIBUTE_ARCHIVE);
570 }
571 // WriteTime
572 if(!(Ccb->CCBFlags & UDF_CCB_WRITE_TIME_SET) &&
573 (Vcb->CompatFlags & UDF_VCB_IC_UPDATE_MODIFY_TIME)) {
574 UDFSetFileXTime(NextFileInfo, NULL, &NtTime, NULL, &NtTime);
575 NtReqFcb->LastWriteTime.QuadPart =
576 NtReqFcb->LastAccessTime.QuadPart = NtTime;
577 ChangeTime = TRUE;
578 }
579 }
580 if(!(Fcb->FCBFlags & UDF_FCB_DIRECTORY)) {
581 // Update sizes in DirIndex
582 if(!Fcb->OpenHandleCount) {
583 ASize = UDFGetFileAllocationSize(Vcb, NextFileInfo);
584// NtReqFcb->CommonFCBHeader.AllocationSize.QuadPart;
585 UDFSetFileSizeInDirNdx(Vcb, NextFileInfo, &ASize);
586 } else
587 if(FileObject->Flags & FO_FILE_SIZE_CHANGED) {
588 ASize = //UDFGetFileAllocationSize(Vcb, NextFileInfo);
589 NtReqFcb->CommonFCBHeader.AllocationSize.QuadPart;
590 UDFSetFileSizeInDirNdx(Vcb, NextFileInfo, &ASize);
591 }
592 }
593 // AccessTime
594 if((FileObject->Flags & FO_FILE_FAST_IO_READ) &&
595 !(Ccb->CCBFlags & UDF_CCB_ACCESS_TIME_SET) &&
596 (Vcb->CompatFlags & UDF_VCB_IC_UPDATE_ACCESS_TIME)) {
597 UDFSetFileXTime(NextFileInfo, NULL, &NtTime, NULL, NULL);
598 NtReqFcb->LastAccessTime.QuadPart = NtTime;
599// ChangeTime = TRUE;
600 }
601 // ChangeTime (AttrTime)
602 if(!(Ccb->CCBFlags & UDF_CCB_MODIFY_TIME_SET) &&
603 (Vcb->CompatFlags & UDF_VCB_IC_UPDATE_ATTR_TIME) &&
604 (ChangeTime || (Ccb->CCBFlags & (UDF_CCB_ATTRIBUTES_SET |
608 UDFSetFileXTime(NextFileInfo, NULL, NULL, &NtTime, NULL);
609 NtReqFcb->ChangeTime.QuadPart = NtTime;
610 }
611 }
612#endif //UDF_READ_ONLY_BUILD
613
614 if(!(Fcb->FCBFlags & UDF_FCB_DIRECTORY) &&
615 ForcedCleanUp) {
616 // flush system cache
617 MmPrint((" CcUninitializeCacheMap()\n"));
619 } else {
620 MmPrint((" CcUninitializeCacheMap()\n"));
622 }
623
624 // release resources now.
625 // they'll be acquired in UDFCloseFileInfoChain()
627 UDFReleaseResource(&(NtReqFcb->MainResource));
628 AcquiredFCB = FALSE;
629
630 if(Fcb->FileInfo->ParentFile) {
631 UDF_CHECK_PAGING_IO_RESOURCE(Fcb->FileInfo->ParentFile->Fcb->NTRequiredFCB);
632 UDFReleaseResource(&(Fcb->FileInfo->ParentFile->Fcb->NTRequiredFCB->MainResource));
633 } else {
634 UDFReleaseResource(&(Vcb->VCBResource));
635 }
636 AcquiredParentFCB = FALSE;
637 // close the chain
638 ASSERT(AcquiredVcb);
639 RC2 = UDFCloseFileInfoChain(Vcb, NextFileInfo, Ccb->TreeLength, TRUE);
640 if(NT_SUCCESS(RC))
641 RC = RC2;
642
643 Ccb->CCBFlags |= UDF_CCB_CLEANED;
644
645 // We must clean up the share access at this time, since we may not
646 // get a Close call for awhile if the file was mapped through this
647 // File Object.
648 IoRemoveShareAccess( FileObject, &(NtReqFcb->FCBShareAccess) );
649
650 NtReqFcb->CommonFCBHeader.IsFastIoPossible = UDFIsFastIoPossible(Fcb);
651
653
654try_exit: NOTHING;
655
656 } _SEH2_FINALLY {
657
658 if(AcquiredFCB) {
660 UDFReleaseResource(&(NtReqFcb->MainResource));
661 }
662
663 if(AcquiredParentFCB) {
664 if(Fcb->FileInfo->ParentFile) {
665 UDF_CHECK_PAGING_IO_RESOURCE(Fcb->FileInfo->ParentFile->Fcb->NTRequiredFCB);
666 UDFReleaseResource(&(Fcb->FileInfo->ParentFile->Fcb->NTRequiredFCB->MainResource));
667 } else {
668 UDFReleaseResource(&(Vcb->VCBResource));
669 }
670 }
671
672 if(AcquiredVcb) {
673 UDFReleaseResource(&(Vcb->VCBResource));
674 AcquiredVcb = FALSE;
675 }
676
678 // complete the IRP
679 Irp->IoStatus.Status = RC;
680 Irp->IoStatus.Information = 0;
682 // Free up the Irp Context
683 UDFReleaseIrpContext(PtrIrpContext);
684 }
685
686 } _SEH2_END; // end of "__finally" processing
687 return(RC);
688} // end UDFCommonCleanup()
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)
struct _VCB * PVCB
Definition: fatstruc.h:557
NTSTATUS UDFCloseFileInfoChain(IN PVCB Vcb, IN PUDF_FILE_INFO fi, IN ULONG TreeLength, IN BOOLEAN VcbAcquired)
Definition: cleanup.cpp:696
PDIR_INDEX_HDR UDFGetDirIndexByFileInfo(IN PUDF_FILE_INFO FileInfo)
Definition: dirtree.cpp:1092
BOOLEAN UDFAcquireResourceExclusiveWithCheck(IN PERESOURCE Resource)
Definition: misc.cpp:2529
VOID UDFReleaseIrpContext(PtrUDFIrpContext PtrIrpContext)
Definition: misc.cpp:1086
#define UDFNotifyVolumeEvent(FileObject, EventCode)
Definition: env_spec.h:114
__inline VOID UDFNotifyFullReportChange(PVCB V, PUDF_FILE_INFO FI, ULONG E, ULONG A)
Definition: env_spec.h:99
#define DO_VERIFY_VOLUME
Definition: env_spec_w32.h:393
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
FAST_IO_POSSIBLE NTAPI UDFIsFastIoPossible(IN PtrUDFFCB Fcb)
Definition: fastio.cpp:118
_In_ PLARGE_INTEGER NtTime
Definition: fatprocs.h:1914
NTSTATUS UDFMarkStreamsForDeletion(IN PVCB Vcb, IN PtrUDFFCB Fcb, IN BOOLEAN ForDel)
Definition: fileinfo.cpp:1137
NTSTATUS NTAPI FsRtlFastUnlockAll(IN PFILE_LOCK FileLock, IN PFILE_OBJECT FileObject, IN PEPROCESS Process, IN PVOID Context OPTIONAL)
Definition: filelock.c:1025
VOID NTAPI CcSetFileSizes(IN PFILE_OBJECT FileObject, IN PCC_FILE_SIZES FileSizes)
Definition: fssup.c:356
BOOLEAN NTAPI CcUninitializeCacheMap(IN PFILE_OBJECT FileObject, IN OPTIONAL PLARGE_INTEGER TruncateSize, IN OPTIONAL PCACHE_UNINITIALIZE_EVENT UninitializeEvent)
Definition: fssup.c:286
#define FILE_ATTRIBUTE_ARCHIVE
Definition: nt_native.h:706
#define FSRTL_VOLUME_UNLOCK
Definition: ntifs_ex.h:443
VOID NTAPI FsRtlNotifyCleanup(IN PNOTIFY_SYNC NotifySync, IN PLIST_ENTRY NotifyList, IN PVOID FsContext)
Definition: notify.c:659
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)
Definition: notify.c:1487
VOID NTAPI IoRemoveShareAccess(IN PFILE_OBJECT FileObject, IN PSHARE_ACCESS ShareAccess)
Definition: file.c:3478
PEPROCESS NTAPI IoGetRequestorProcess(IN PIRP Irp)
Definition: irp.c:1782
OSSTATUS UDFResetDeviceDriver(IN PVCB Vcb, IN PDEVICE_OBJECT TargetDeviceObject, IN BOOLEAN Unlock)
Definition: phys_lib.cpp:4199
#define UDFRemoveFromSystemDelayedQueue(Fcb)
Definition: protos.h:109
#define UDFRemoveFromDelayedQueue(Fcb)
Definition: protos.h:106
#define _SEH2_AbnormalTermination()
Definition: pseh2_64.h:160
#define STATUS_CANNOT_DELETE
Definition: shellext.h:71
#define UDF_CCB_CREATE_TIME_SET
Definition: struct.h:155
#define UDF_CCB_ATTRIBUTES_SET
Definition: struct.h:157
#define UDF_CCB_ACCESS_TIME_SET
Definition: struct.h:153
#define UDF_FCB_ROOT_DIRECTORY
Definition: struct.h:304
#define UDF_CCB_CLEANED
Definition: struct.h:146
#define UDF_CCB_MODIFY_TIME_SET
Definition: struct.h:154
#define UDF_NODE_TYPE_VCB
Definition: struct.h:61
#define UDF_FCB_DELETE_ON_CLOSE
Definition: struct.h:309
#define UDF_FCB_DELAY_CLOSE
Definition: struct.h:313
#define UDF_CCB_WRITE_TIME_SET
Definition: struct.h:156
#define UDF_CCB_DELETE_ON_CLOSE
Definition: struct.h:162
PVOID DeviceExtension
Definition: env_spec_w32.h:418
UNICODE_STRING FName
Definition: udf_rel.h:173
struct _UDF_FILE_INFO * SDirInfo
Definition: udf_rel.h:319
PUDF_DATALOC_INFO Dloc
Definition: udf_rel.h:367
uint_di Index
Definition: udf_rel.h:392
Definition: cdstruc.h:498
int64_t LONGLONG
Definition: typedefs.h:68
#define UDF_VCB_IC_UPDATE_MODIFY_TIME
Definition: udf_common.h:494
#define UDF_VCB_FLAGS_VOLUME_MOUNTED
Definition: udf_common.h:459
#define UDF_VCB_IC_UPDATE_ATTR_TIME
Definition: udf_common.h:495
#define UDF_VCB_FLAGS_VOLUME_READ_ONLY
Definition: udf_common.h:463
#define UDF_VCB_IC_UPDATE_ARCH_BIT
Definition: udf_common.h:496
#define UDF_VCB_IC_UPDATE_ACCESS_TIME
Definition: udf_common.h:493
#define UDF_VCB_FLAGS_OUR_DEVICE_DRIVER
Definition: udf_common.h:466
uint16 UDFGetFileLinkCount(IN PUDF_FILE_INFO FileInfo)
Definition: udf_info.cpp:1355
void UDFSetFileSizeInDirNdx(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo, IN int64 *ASize)
Definition: udf_info.cpp:1190
OSSTATUS UDFResizeFile__(IN PVCB Vcb, IN OUT PUDF_FILE_INFO FileInfo, IN int64 NewLength)
Definition: udf_info.cpp:3468
OSSTATUS UDFPretendFileDeleted__(IN PVCB Vcb, IN PUDF_FILE_INFO FileInfo)
Definition: udf_info.cpp:5566
#define UDFIsSDirDeleted(FI)
Definition: udf_info.h:1004
#define UDFGetFileAllocationSize(Vcb, FileInfo)
Definition: udf_info.h:797
#define UDFIsDirEmpty__(fi)
Definition: udf_info.h:1070
__inline PDIR_INDEX_ITEM UDFDirIndex(IN PDIR_INDEX_HDR hDirNdx, IN uint_di i)
Definition: udf_info.h:1105
#define UDFIsADirectory(FileInfo)
Definition: udf_info.h:792
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define FILE_ACTION_MODIFIED_STREAM
#define FILE_ACTION_MODIFIED
#define FO_FILE_FAST_IO_READ
Definition: iotypes.h:1795
#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 FO_FILE_MODIFIED
Definition: iotypes.h:1788
#define FILE_NOTIFY_CHANGE_FILE_NAME
#define FO_CLEANUP_COMPLETE
Definition: iotypes.h:1790
* PFILE_OBJECT
Definition: iotypes.h:1998
#define FO_FILE_SIZE_CHANGED
Definition: iotypes.h:1789
#define FO_CACHE_SUPPORTED
Definition: iotypes.h:1781
#define FILE_NOTIFY_CHANGE_LAST_WRITE
#define FILE_NOTIFY_CHANGE_DIR_NAME
_In_opt_ PLARGE_INTEGER NewFileSize
Definition: mmfuncs.h:608

Referenced by UDFCleanup(), and UDFCommonDispatch().

◆ UDFCommonClose()

NTSTATUS UDFCommonClose ( PtrUDFIrpContext  PtrIrpContext,
PIRP  Irp 
)

Definition at line 137 of file close.cpp.

141{
147 PVCB Vcb = NULL;
148// PERESOURCE PtrResourceAcquired = NULL;
149 BOOLEAN AcquiredVcb = FALSE;
150 BOOLEAN AcquiredGD = FALSE;
152 ULONG i = 0;
153// ULONG clean_stat = 0;
154
155// BOOLEAN CompleteIrp = TRUE;
156 BOOLEAN PostRequest = FALSE;
157
158#ifdef UDF_DBG
159 UNICODE_STRING CurName;
160 PDIR_INDEX_HDR DirNdx;
161#endif
162
163 AdPrint(("UDFCommonClose: \n"));
164
165 _SEH2_TRY {
166 if (Irp) {
167
168 // If this is the first (IOManager) request
169 // First, get a pointer to the current I/O stack location
171 ASSERT(IrpSp);
172
175
176 // Get the FCB and CCB pointers
177 Ccb = (PtrUDFCCB)(FileObject->FsContext2);
178 ASSERT(Ccb);
179 if(Ccb->CCBFlags & UDF_CCB_READ_ONLY) {
181 }
182 Fcb = Ccb->Fcb;
183 } else {
184 // If this is a queued call (for our dispatch)
185 // Get saved Fcb address
186 Fcb = PtrIrpContext->Fcb;
187 i = PtrIrpContext->TreeLength;
188 }
189
190 ASSERT(Fcb);
191 Vcb = (PVCB)(PtrIrpContext->TargetDeviceObject->DeviceExtension);
192 ASSERT(Vcb);
193 ASSERT(Vcb->NodeIdentifier.NodeType == UDF_NODE_TYPE_VCB);
194// Vcb->VCBFlags |= UDF_VCB_SKIP_EJECT_CHECK;
195
196 // Steps we shall take at this point are:
197 // (a) Acquire the VCB shared
198 // (b) Acquire the FCB's CCB list exclusively
199 // (c) Delete the CCB structure (free memory)
200 // (d) If this is the last close, release the FCB structure
201 // (unless we keep these around for "delayed close" functionality.
202 // Note that it is often the case that the close dispatch entry point is invoked
203 // in the most inconvenient of situations (when it is not possible, for example,
204 // to safely acquire certain required resources without deadlocking or waiting).
205 // Therefore, be extremely careful in implementing this close dispatch entry point.
206 // Also note that we do not have the option of returning a failure code from the
207 // close dispatch entry point; the system expects that the close will always succeed.
208
209 UDFAcquireResourceShared(&(Vcb->VCBResource), TRUE);
210 AcquiredVcb = TRUE;
211
212 // Is this is the first (IOManager) request ?
213 if (Irp) {
214 PtrIrpContext->TreeLength =
215 i = Ccb->TreeLength;
216 // remember the number of incomplete Close requests
217 InterlockedIncrement((PLONG)&(Fcb->CcbCount));
218 // we can release CCB in any case
220 FileObject->FsContext2 = NULL;
221#ifdef DBG
222/* } else {
223 ASSERT(Fcb->NTRequiredFCB);
224 if(Fcb->NTRequiredFCB) {
225 ASSERT(Fcb->NTRequiredFCB->FileObject);
226 if(Fcb->NTRequiredFCB->FileObject) {
227 ASSERT(!Fcb->NTRequiredFCB->FileObject->FsContext2);
228 }
229 }*/
230#endif //DBG
231 }
232
233#ifdef UDF_DELAYED_CLOSE
234 // check if this is the last Close (no more Handles)
235 // and try to Delay it....
236 if((Fcb->FCBFlags & UDF_FCB_DELAY_CLOSE) &&
237 (Vcb->VCBFlags & UDF_VCB_FLAGS_VOLUME_MOUNTED) &&
238 !(Vcb->VCBFlags & UDF_VCB_FLAGS_NO_DELAYED_CLOSE) &&
239 !(Fcb->OpenHandleCount)) {
240 UDFReleaseResource(&(Vcb->VCBResource));
241 AcquiredVcb = FALSE;
242 if((RC = UDFQueueDelayedClose(PtrIrpContext,Fcb)) == STATUS_SUCCESS)
244 // do standard Close if we can't Delay this opeartion
245 AdPrint((" Cant queue Close Irp, status=%x\n", RC));
246 }
247#endif //UDF_DELAYED_CLOSE
248
249 if(Irp) {
250 // We should post actual procesing if this is a recursive call
251 if((PtrIrpContext->IrpContextFlags & UDF_IRP_CONTEXT_NOT_TOP_LEVEL) ||
252 (Fcb->NTRequiredFCB->AcqFlushCount)) {
253 AdPrint((" post NOT_TOP_LEVEL Irp\n"));
254 PostRequest = TRUE;
256 }
257 }
258
259 // Close request is near completion, Vcb is acquired.
260 // Now we can safely decrease CcbCount, because no Rename
261 // operation can run until Vcb release.
262 InterlockedDecrement((PLONG)&(Fcb->CcbCount));
263
264 UDFInterlockedDecrement((PLONG)&(Vcb->VCBOpenCount));
265 if(PtrIrpContext->IrpContextFlags & UDF_IRP_CONTEXT_READ_ONLY)
266 UDFInterlockedDecrement((PLONG)&(Vcb->VCBOpenCountRO));
267
268 if(!i || (Fcb->NodeIdentifier.NodeType == UDF_NODE_TYPE_VCB)) {
269
270 AdPrint(("UDF: Closing volume\n"));
271 AdPrint(("UDF: ReferenceCount: %x\n",Fcb->ReferenceCount));
272
273 if (Vcb->VCBOpenCount > UDF_RESIDUAL_REFERENCE) {
274 ASSERT(Fcb->NodeIdentifier.NodeType == UDF_NODE_TYPE_VCB);
275 UDFInterlockedDecrement((PLONG)&(Fcb->ReferenceCount));
276 ASSERT(Fcb->NTRequiredFCB);
277 UDFInterlockedDecrement((PLONG)&(Fcb->NTRequiredFCB->CommonRefCount));
278
280 }
281
282 UDFInterlockedIncrement((PLONG)&(Vcb->VCBOpenCount));
283
284 if(AcquiredVcb) {
285 UDFReleaseResource(&(Vcb->VCBResource));
286 AcquiredVcb = FALSE;
287 } else {
288 BrutePoint();
289 }
290 // Acquire GlobalDataResource
291 UDFAcquireResourceExclusive(&(UDFGlobalData.GlobalDataResource), TRUE);
292 AcquiredGD = TRUE;
293// // Acquire Vcb
294 UDFAcquireResourceExclusive(&(Vcb->VCBResource), TRUE);
295 AcquiredVcb = TRUE;
296
297 UDFInterlockedDecrement((PLONG)&(Vcb->VCBOpenCount));
298
299
300 ASSERT(Fcb->NodeIdentifier.NodeType == UDF_NODE_TYPE_VCB);
301 UDFInterlockedDecrement((PLONG)&(Fcb->ReferenceCount));
302 ASSERT(Fcb->NTRequiredFCB);
303 UDFInterlockedDecrement((PLONG)&(Fcb->NTRequiredFCB->CommonRefCount));
304
305 //AdPrint(("UDF: Closing volume, reset driver (e.g. stop BGF)\n"));
306 //UDFResetDeviceDriver(Vcb, Vcb->TargetDeviceObject, FALSE);
307
308 AdPrint(("UDF: Closing volume, reset write status\n"));
309 RC = UDFPhSendIOCTL(IOCTL_CDRW_RESET_WRITE_STATUS, Vcb->TargetDeviceObject,
310 NULL, 0, NULL, 0, TRUE, NULL);
311
312 if((Vcb->VCBFlags & UDF_VCB_FLAGS_BEING_DISMOUNTED) ||
313 ((!(Vcb->VCBFlags & UDF_VCB_FLAGS_VOLUME_MOUNTED)) && (Vcb->VCBOpenCount <= UDF_RESIDUAL_REFERENCE))) {
314 // Try to KILL dismounted volume....
315 // w2k requires this, NT4 - recomends
316 AcquiredVcb = UDFCheckForDismount(PtrIrpContext, Vcb, TRUE);
317 }
318
320 }
321
322 fi = Fcb->FileInfo;
323#ifdef UDF_DBG
324 if(!fi) {
325 BrutePoint();
326 }
327
328 DirNdx = UDFGetDirIndexByFileInfo(fi);
329 if(DirNdx) {
330 CurName.Buffer = UDFDirIndex(DirNdx,fi->Index)->FName.Buffer;
331 if(CurName.Buffer) {
332 AdPrint(("Closing file: %ws %8.8x\n", CurName.Buffer, FileObject));
333 } else {
334 AdPrint(("Closing file: ??? \n"));
335 }
336 }
337 AdPrint(("UDF: ReferenceCount: %x\n",Fcb->ReferenceCount));
338#endif // UDF_DBG
339 // try to clean up as long chain as it is possible
341
342try_exit: NOTHING;
343
344 } _SEH2_FINALLY {
345
346 if(AcquiredVcb) {
347 UDFReleaseResource(&(Vcb->VCBResource));
348 }
349 if(AcquiredGD) {
350 UDFReleaseResource(&(UDFGlobalData.GlobalDataResource));
351 }
352
353 // Post IRP if required
354 if (PostRequest) {
355
356 // Perform the post operation & complete the IRP
357 // if this is first call of UDFCommonClose
358 // and will return STATUS_SUCCESS back to us
359 PtrIrpContext->Irp = NULL;
360 PtrIrpContext->Fcb = Fcb;
361 UDFPostRequest(PtrIrpContext, NULL);
362 }
363
365 // If this is not async close complete the IRP
366 if (Irp) {
367/* if( FileObject ) {
368 if(clean_stat & UDF_CLOSE_NTREQFCB_DELETED) {
369// ASSERT(!FileObject->FsContext2);
370 FileObject->FsContext = NULL;
371#ifdef DBG
372 } else {
373 UDFNTRequiredFCB* NtReqFcb = ((UDFNTRequiredFCB*)(FileObject->FsContext));
374 if(NtReqFcb->FileObject == FileObject) {
375 NtReqFcb->FileObject = NULL;
376 }
377#endif //DBG
378 }
379 }*/
380 Irp->IoStatus.Status = STATUS_SUCCESS;
381 Irp->IoStatus.Information = 0;
383 }
384 // Free up the Irp Context
385 if(!PostRequest)
386 UDFReleaseIrpContext(PtrIrpContext);
387 }
388
389 } _SEH2_END; // end of "__finally" processing
390
391 return STATUS_SUCCESS ;
392} // end UDFCommonClose()
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define IOCTL_CDRW_RESET_WRITE_STATUS
Definition: cdrw_usr.h:102
NTSTATUS UDFQueueDelayedClose(PtrUDFIrpContext IrpContext, PtrUDFFCB Fcb)
Definition: close.cpp:1106
NTSTATUS UDFPostRequest(IN PtrUDFIrpContext PtrIrpContext, IN PIRP Irp)
Definition: misc.cpp:1128
VOID __fastcall UDFCleanUpCCB(PtrUDFCCB Ccb)
Definition: misc.cpp:805
NTSTATUS NTAPI UDFPhSendIOCTL(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, OUT PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN OverrideVerify, OUT PIO_STATUS_BLOCK Iosb OPTIONAL)
Definition: env_spec.cpp:511
#define UDFInterlockedIncrement(addr)
Definition: env_spec_w32.h:675
BOOLEAN UDFCheckForDismount(IN PtrUDFIrpContext IrpContext, IN PVCB Vcb, IN BOOLEAN VcbAcquired)
Definition: verfysup.cpp:629
#define UDF_CCB_READ_ONLY
Definition: struct.h:170
#define UDF_IRP_CONTEXT_READ_ONLY
Definition: struct.h:394
_UDFFileControlBlock * Fcb
Definition: struct.h:378
ULONG TreeLength
Definition: struct.h:379

Referenced by UDFClose(), UDFCommonDispatch(), and UDFDoDelayedClose().

◆ UDFCommonCreate()

NTSTATUS UDFCommonCreate ( IN PtrUDFIrpContext  PtrIrpContext,
IN PIRP  Irp 
)

◆ UDFCommonDeviceControl()

NTSTATUS NTAPI UDFCommonDeviceControl ( PtrUDFIrpContext  PtrIrpContext,
PIRP  Irp 
)

Definition at line 149 of file devcntrl.cpp.

153{
156// PIO_STACK_LOCATION PtrNextIoStackLocation = NULL;
160 PVCB Vcb = NULL;
163// PVOID BufferPointer = NULL;
164 BOOLEAN AcquiredVcb = FALSE;
165 BOOLEAN FSDevObj;
166 ULONG TrackNumber;
167 BOOLEAN UnsafeIoctl = TRUE;
168 UCHAR ScsiCommand;
169 PPREVENT_MEDIA_REMOVAL_USER_IN Buf = NULL; // FSD buffer
170 PCDB Cdb;
171 PCHAR CdbData;
172 PCHAR ModeSelectData;
173
174 UDFPrint(("UDFCommonDeviceControl\n"));
175
176 _SEH2_TRY {
177 // First, get a pointer to the current I/O stack location
179 ASSERT(IrpSp);
180
181 // Get the IoControlCode value
183
186
187 FSDevObj = UDFIsFSDevObj(PtrIrpContext->TargetDeviceObject);
188
189 if(FSDevObj) {
190 switch (IoControlCode) {
194#ifndef UDF_READ_ONLY_BUILD
196#endif //UDF_READ_ONLY_BUILD
198 break;
199 default:
200 UDFPrint(("UDFCommonDeviceControl: STATUS_INVALID_PARAMETER %x for FsDevObj\n", IoControlCode));
203 }
204 } else {
205 Ccb = (PtrUDFCCB)(FileObject->FsContext2);
206 if(!Ccb) {
207 UDFPrint((" !Ccb\n"));
208 goto ioctl_do_default;
209 }
210 ASSERT(Ccb);
211 Fcb = Ccb->Fcb;
212 ASSERT(Fcb);
213
214 // Check if the IOCTL is suitable for this type of File
215 if (Fcb->NodeIdentifier.NodeType == UDF_NODE_TYPE_VCB) {
216 // Everything is acceptable for Volume
217 Vcb = (PVCB)(Fcb);
218 } else {
219 Vcb = Fcb->Vcb;
221 // For files/disrs only the following are acceptable
222 switch (IoControlCode) {
226 break;
227 default:
228 UDFPrint(("UDFCommonDeviceControl: STATUS_INVALID_PARAMETER %x for File/Dir Obj\n", IoControlCode));
230 }
231 }
232 // check 'safe' IOCTLs
233 switch (IoControlCode) {
235
240
245
250
255
269
274
278
280
298
300
303
310// case :
311
313
314 UnsafeIoctl = FALSE;
315 break;
316 }
317
319 UDFAcquireResourceShared(&(Vcb->VCBResource), TRUE);
320 } else {
321 UDFAcquireResourceExclusive(&(Vcb->VCBResource), TRUE);
322 }
323 AcquiredVcb = TRUE;
324 }
325
326 UDFPrint(("UDF Irp %x, ctx %x, DevIoCtl %x\n", Irp, PtrIrpContext, IoControlCode));
327
328 // We may wish to allow only volume open operations.
329 switch (IoControlCode) {
330
333
334 if(!Irp->AssociatedIrp.SystemBuffer)
335 goto ioctl_do_default;
336
338 Cdb = (PCDB)&(((PSCSI_PASS_THROUGH_DIRECT)(Irp->AssociatedIrp.SystemBuffer))->Cdb);
339 CdbData = (PCHAR)(((PSCSI_PASS_THROUGH_DIRECT)(Irp->AssociatedIrp.SystemBuffer))->DataBuffer);
340 } else {
341 Cdb = (PCDB)&(((PSCSI_PASS_THROUGH)(Irp->AssociatedIrp.SystemBuffer))->Cdb);
342 if(((PSCSI_PASS_THROUGH)(Irp->AssociatedIrp.SystemBuffer))->DataBufferOffset) {
343 CdbData = ((PCHAR)Cdb) +
344 ((PSCSI_PASS_THROUGH)(Irp->AssociatedIrp.SystemBuffer))->DataBufferOffset;
345 } else {
346 CdbData = NULL;
347 }
348 }
349 ScsiCommand = Cdb->CDB6.OperationCode;
350
351 if(ScsiCommand == SCSIOP_WRITE_CD) {
352 UDFPrint(("Write10, LBA %2.2x%2.2x%2.2x%2.2x\n",
353 Cdb->WRITE_CD.LBA[0],
354 Cdb->WRITE_CD.LBA[1],
355 Cdb->WRITE_CD.LBA[2],
356 Cdb->WRITE_CD.LBA[3]
357 ));
358 } else
359 if(ScsiCommand == SCSIOP_WRITE12) {
360 UDFPrint(("Write12, LBA %2.2x%2.2x%2.2x%2.2x\n",
361 Cdb->CDB12READWRITE.LBA[0],
362 Cdb->CDB12READWRITE.LBA[1],
363 Cdb->CDB12READWRITE.LBA[2],
364 Cdb->CDB12READWRITE.LBA[3]
365 ));
366 } else {
367 }
368
369 switch(ScsiCommand) {
370 case SCSIOP_MODE_SELECT: {
371// PMODE_PARAMETER_HEADER ParamHdr = (PMODE_PARAMETER_HEADER)CdbData;
372 ModeSelectData = CdbData+4;
373 switch(ModeSelectData[0]) {
374 case MODE_PAGE_MRW2:
376 case MODE_PAGE_MRW:
377 UDFPrint(("Unsafe MODE_SELECT_6 via pass-through (%2.2x)\n", ModeSelectData[0]));
378 goto unsafe_direct_scsi_cmd;
379 }
380 break; }
381
383// PMODE_PARAMETER_HEADER10 ParamHdr = (PMODE_PARAMETER_HEADER10)CdbData;
384 ModeSelectData = CdbData+8;
385 switch(ModeSelectData[0]) {
386 case MODE_PAGE_MRW2:
388 case MODE_PAGE_MRW:
389 UDFPrint(("Unsafe MODE_SELECT_10 via pass-through (%2.2x)\n", ModeSelectData[0]));
390 goto unsafe_direct_scsi_cmd;
391 }
392 break; }
393
399 case SCSIOP_WRITE6:
400 case SCSIOP_WRITE_CD:
401 case SCSIOP_BLANK:
402 case SCSIOP_WRITE12:
404 UDFPrint(("UDF Direct media modification via pass-through (%2.2x)\n", ScsiCommand));
405unsafe_direct_scsi_cmd:
406 if(!(Vcb->VCBFlags & UDF_VCB_FLAGS_VOLUME_MOUNTED))
407 goto ioctl_do_default;
408
409 UDFPrint(("Forget this volume\n"));
410 // Acquire Vcb resource (Shared -> Exclusive)
411 UDFInterlockedIncrement((PLONG)&(Vcb->VCBOpenCount));
412 UDFReleaseResource(&(Vcb->VCBResource));
413
414 if(!(Vcb->VCBFlags & UDF_VCB_FLAGS_RAW_DISK)) {
415 UDFCloseAllSystemDelayedInDir(Vcb, Vcb->RootDirFCB->FileInfo);
416 }
417#ifdef UDF_DELAYED_CLOSE
418 // Acquire exclusive access to the Vcb.
420#endif //UDF_DELAYED_CLOSE
421
422 // allocate tmp buffer for FSD calls
424 if(!Buf)
426
427 UDFAcquireResourceExclusive(&(Vcb->VCBResource), TRUE);
428 AcquiredVcb = TRUE;
429 UDFInterlockedDecrement((PLONG)&(Vcb->VCBOpenCount));
430
432 MyFreePool__(Buf);
433 Buf = NULL;
434 Vcb->MediaLockCount = 0;
435
436 Vcb->VCBFlags &= ~UDF_VCB_FLAGS_VOLUME_MOUNTED;
437 Vcb->WriteSecurity = FALSE;
438
439 // Release the Vcb resource.
440 UDFReleaseResource(&(Vcb->VCBResource));
441 AcquiredVcb = FALSE;
442 // disable Eject Request Waiter if any
444
445 // Make sure, that volume will never be quick-remounted
446 // It is very important for ChkUdf utility and
447 // some CD-recording libraries
448 Vcb->SerialNumber--;
449
450 UDFPrint(("Forgotten\n"));
451
452 goto notify_media_change;
453
455 case SCSIOP_DOORLOCK:
458 UDFPrint(("UDF Medium/Tray control IOCTL via pass-through\n"));
459 }
460 goto ioctl_do_default;
461
462 case IOCTL_CDRW_BLANK:
465
466notify_media_change:
467/* Vcb->VCBFlags |= UDF_VCB_FLAGS_UNSAFE_IOCTL;
468 // Make sure, that volume will never be quick-remounted
469 // It is very important for ChkUdf utility and
470 // some CD-recording libraries
471 Vcb->SerialNumber--;
472*/ goto ioctl_do_default;
473
475
476 UDFPrint(("UDF Register Autoformat\n"));
479 } else {
481 RC = STATUS_SUCCESS;
482 }
484 Irp->IoStatus.Information = 0;
485 break;
486 }
487
489
490 UDFPrint(("UDF Disable driver\n"));
491 IoUnregisterFileSystem(UDFGlobalData.UDFDeviceObject);
492 // Now, delete any device objects, etc. we may have created
493 if (UDFGlobalData.UDFDeviceObject) {
494 IoDeleteDevice(UDFGlobalData.UDFDeviceObject);
495 UDFGlobalData.UDFDeviceObject = NULL;
496 }
497
498 // free up any memory we might have reserved for zones/lookaside
499 // lists
502 }
503
504 // delete the resource we may have initialized
506 // un-initialize this resource
507 UDFDeleteResource(&(UDFGlobalData.GlobalDataResource));
509 }
510 RC = STATUS_SUCCESS;
512 Irp->IoStatus.Information = 0;
513 break;
514 }
516 UDFPrint(("UDF Invaidate volume\n"));
517 if(AcquiredVcb) {
518 UDFReleaseResource(&(Vcb->VCBResource));
519 AcquiredVcb = FALSE;
520 }
521 RC = UDFInvalidateVolumes( PtrIrpContext, Irp );
523 Irp->IoStatus.Information = 0;
524 break;
525 }
526
528 {
529 if (IrpSp->Parameters.DeviceIoControl.InputBufferLength != sizeof(HANDLE))
530 {
532 }
533 else
534 {
535 HANDLE MountEventHandle = *(PHANDLE)Irp->AssociatedIrp.SystemBuffer;
536 if (MountEventHandle)
537 {
538 if (!UDFGlobalData.MountEvent)
539 {
541 MountEventHandle,
542 0,
543 NULL,
544 UserMode,
545 (PVOID *) &UDFGlobalData.MountEvent,
546 NULL);
547
548 if (!NT_SUCCESS(RC))
549 {
550 UDFGlobalData.MountEvent = NULL;
551 }
552 }
553 else
554 {
556 }
557 }
558 else
559 {
560 if (!UDFGlobalData.MountEvent)
561 {
563 }
564 else
565 {
567 UDFGlobalData.MountEvent = NULL;
568 }
569 }
570 }
571
573 Irp->IoStatus.Information = 0;
574 break;
575 }
576
578 {
579 if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(BOOLEAN))
580 {
582 }
583 else
584 {
585 *(PBOOLEAN)Irp->AssociatedIrp.SystemBuffer = Vcb->IsVolumeJustMounted;
586 Vcb->IsVolumeJustMounted = FALSE;
587 }
588
590 Irp->IoStatus.Information = 0;
591 break;
592 }
593
594
595 //case FSCTL_GET_RETRIEVAL_POINTERS
597 UDFPrint(("UDF: Get Retrieval Pointers\n"));
598 RC = UDFGetRetrievalPointers( PtrIrpContext, Irp, 0 );
600 break;
601 }
603 UDFPrint(("UDF: Get Spec Retrieval Pointers\n"));
604 PUDF_GET_SPEC_RETRIEVAL_POINTERS_IN SpecRetrPointer;
605 SpecRetrPointer = (PUDF_GET_SPEC_RETRIEVAL_POINTERS_IN)(Irp->AssociatedIrp.SystemBuffer);
606 RC = UDFGetRetrievalPointers( PtrIrpContext, Irp, SpecRetrPointer->Special );
608 break;
609 }
611 UDFPrint(("UDF: Get File Alloc mode (from ICB)\n"));
612 RC = UDFGetFileAllocModeFromICB( PtrIrpContext, Irp );
614 break;
615 }
616#ifndef UDF_READ_ONLY_BUILD
618 UDFPrint(("UDF: Set File Alloc mode\n"));
619 RC = UDFSetFileAllocModeFromICB( PtrIrpContext, Irp );
621 break;
622 }
623#endif //UDF_READ_ONLY_BUILD
625 if(AcquiredVcb) {
626 UDFReleaseResource(&(Vcb->VCBResource));
627 AcquiredVcb = FALSE;
628 }
629 RC = UDFLockVolume( PtrIrpContext, Irp, GetCurrentPID() );
631 break;
633 if(AcquiredVcb) {
634 UDFReleaseResource(&(Vcb->VCBResource));
635 AcquiredVcb = FALSE;
636 }
637 RC = UDFUnlockVolume( PtrIrpContext, Irp, GetCurrentPID() );
639 break;
640#ifndef UDF_READ_ONLY_BUILD
642 RC = STATUS_SUCCESS;
643
644 Irp->IoStatus.Information = 0;
645 Irp->IoStatus.Status = STATUS_SUCCESS;
647 break;
648#endif //UDF_READ_ONLY_BUILD
650
651 PUDF_GET_VERSION_OUT udf_ver;
652
653 UDFPrint(("UDFUserFsCtrlRequest: IOCTL_UDF_GET_VERSION\n"));
654
655 Irp->IoStatus.Information = 0;
657
658 if(!IrpSp->Parameters.DeviceIoControl.OutputBufferLength) {
659 UDFPrint(("!OutputBufferLength\n"));
661 }
662 // Check the size of the output buffer.
663 if(IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(UDF_GET_VERSION_OUT)) {
664 UDFPrint(("OutputBufferLength < %x\n", sizeof(UDF_GET_VERSION_OUT)));
666 }
667
668 udf_ver = (PUDF_GET_VERSION_OUT)(Irp->AssociatedIrp.SystemBuffer);
669 if(!udf_ver) {
670 UDFPrint(("!udf_ver\n"));
672 }
673
674 RtlZeroMemory(udf_ver, IrpSp->Parameters.DeviceIoControl.OutputBufferLength);
675
676 udf_ver->header.Length = sizeof(UDF_GET_VERSION_OUT);
677 udf_ver->header.DriverVersionMj = 0x00010005;
678 udf_ver->header.DriverVersionMn = 0x12;
679 udf_ver->header.DriverVersionBuild = UDF_CURRENT_BUILD;
680
681 udf_ver->FSVersionMj = Vcb->CurrentUDFRev >> 8;
682 udf_ver->FSVersionMn = Vcb->CurrentUDFRev & 0xff;
683 udf_ver->FSFlags = Vcb->UserFSFlags;
684 if( ((Vcb->origIntegrityType == INTEGRITY_TYPE_OPEN) &&
685 (Vcb->CompatFlags & UDF_VCB_IC_DIRTY_RO))
686 ||
687 (Vcb->VCBFlags & UDF_VCB_FLAGS_VOLUME_READ_ONLY) ) {
688 UDFPrint((" UDF_USER_FS_FLAGS_RO\n"));
689 udf_ver->FSFlags |= UDF_USER_FS_FLAGS_RO;
690 }
691 if(Vcb->VCBFlags & UDF_VCB_FLAGS_OUR_DEVICE_DRIVER) {
692 UDFPrint((" UDF_USER_FS_FLAGS_OUR_DRIVER\n"));
694 }
695 if(Vcb->VCBFlags & UDF_VCB_FLAGS_RAW_DISK) {
696 UDFPrint((" UDF_USER_FS_FLAGS_RAW\n"));
697 udf_ver->FSFlags |= UDF_USER_FS_FLAGS_RAW;
698 }
699 if(Vcb->VCBFlags & UDF_VCB_FLAGS_MEDIA_READ_ONLY) {
700 UDFPrint((" UDF_USER_FS_FLAGS_MEDIA_RO\n"));
702 }
703 if(Vcb->FP_disc) {
704 UDFPrint((" UDF_USER_FS_FLAGS_FP\n"));
705 udf_ver->FSFlags |= UDF_USER_FS_FLAGS_FP;
706 }
707 udf_ver->FSCompatFlags = Vcb->CompatFlags;
708
709 udf_ver->FSCfgVersion = Vcb->CfgVersion;
710
711 Irp->IoStatus.Information = sizeof(UDF_GET_VERSION_OUT);
712 RC = STATUS_SUCCESS;
714
715 break; }
717
718 PUDF_SET_OPTIONS_IN udf_opt;
719 BOOLEAN PrevVerifyOnWrite;
720
721 UDFPrint(("UDF: IOCTL_UDF_SET_OPTIONS\n"));
722
723 Irp->IoStatus.Information = 0;
725
726 if(IrpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof(UDF_SET_OPTIONS_IN)) {
727 UDFPrint(("InputBufferLength < %x\n", sizeof(UDF_SET_OPTIONS_IN)));
729 }
730
731 udf_opt = (PUDF_SET_OPTIONS_IN)(Irp->AssociatedIrp.SystemBuffer);
732 if(!udf_opt) {
733 UDFPrint(("!udf_opt\n"));
735 }
736
738 UDFPrint(("invalid opt target\n"));
740 }
741
742 if(AcquiredVcb) {
743 UDFReleaseResource(&(Vcb->VCBResource));
744 AcquiredVcb = FALSE;
745 }
746 UDFAcquireResourceExclusive(&(Vcb->VCBResource), TRUE);
747 AcquiredVcb = TRUE;
748
749 PrevVerifyOnWrite = Vcb->VerifyOnWrite;
750
751 Vcb->Cfg = ((PUCHAR)(udf_opt)) + udf_opt->header.HdrLength;
752 Vcb->CfgLength = IrpSp->Parameters.DeviceIoControl.InputBufferLength - offsetof(UDF_SET_OPTIONS_IN, Data);
753 UDFReadRegKeys(Vcb, TRUE /*update*/, TRUE /*cfg*/);
754 Vcb->Cfg = NULL;
755 Vcb->CfgLength = 0;
756 Vcb->CfgVersion++;
757 //UDFReadRegKeys(Vcb, TRUE /*update*/, TRUE);
758 if(PrevVerifyOnWrite != Vcb->VerifyOnWrite) {
759 if(Vcb->VerifyOnWrite) {
760 UDFVInit(Vcb);
761 } else {
762 WCacheFlushBlocks__(&(Vcb->FastCache), Vcb, 0, Vcb->LastLBA);
763 UDFVFlush(Vcb);
765 }
766 }
767
768 RC = STATUS_SUCCESS;
769 break; }
770#if 0
771 case IOCTL_UDF_GET_OPTIONS_VERSION: {
772
773 PUDF_GET_OPTIONS_VERSION_OUT udf_opt_ver;
774
775 UDFPrint(("UDF: IOCTL_UDF_GET_OPTIONS_VERSION\n"));
776
777 Irp->IoStatus.Information = 0;
779
780 if(IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(UDF_GET_OPTIONS_VERSION_OUT)) {
781 UDFPrint(("OutputBufferLength < %x\n", sizeof(UDF_GET_OPTIONS_VERSION_OUT)));
783 }
784
785 udf_opt_ver = (PUDF_GET_OPTIONS_VERSION_OUT)(Irp->AssociatedIrp.SystemBuffer);
786 if(!udf_opt_ver) {
787 UDFPrint(("!udf_opt-ver\n"));
789 }
790/*
791 if(AcquiredVcb) {
792 UDFReleaseResource(&(Vcb->VCBResource));
793 AcquiredVcb = FALSE;
794 }
795 UDFAcquireResourceShared(&(Vcb->VCBResource), TRUE);
796 AcquiredVcb = TRUE;
797*/
798 udf_opt_ver->CfgVersion = Vcb->CfgVersion;
799 Irp->IoStatus.Information = sizeof(UDF_GET_OPTIONS_VERSION_OUT);
800
801 RC = STATUS_SUCCESS;
802 break; }
803#endif //0
805
806 UDFPrint(("UDF: IOCTL_CDRW_RESET_DRIVER\n"));
807 Vcb->MediaLockCount = 0;
808 Vcb->VCBFlags &= ~UDF_VCB_FLAGS_MEDIA_LOCKED;
809 goto ioctl_do_default;
810
812
813 UDFPrint(("UDFUserFsCtrlRequest: FSCTL_ALLOW_EXTENDED_DASD_IO\n"));
814 // DASD i/o is always permitted
815 // So, no-op this call
816 RC = STATUS_SUCCESS;
817
818 Irp->IoStatus.Information = 0;
819 Irp->IoStatus.Status = STATUS_SUCCESS;
821 break;
822
824
825 UDFPrint(("UDFUserFsCtrlRequest: FSCTL_IS_VOLUME_DIRTY\n"));
826 // DASD i/o is always permitted
827 // So, no-op this call
828 RC = UDFIsVolumeDirty(PtrIrpContext, Irp);
830 break;
831
835
836 UDFPrint(("UDF Reset/Eject request\n"));
837// PPREVENT_MEDIA_REMOVAL_USER_IN Buf;
838
839 if(Vcb->EjectWaiter) {
840 UDFPrint((" Vcb->EjectWaiter present\n"));
841 Irp->IoStatus.Information = 0;
842 Vcb->EjectWaiter->SoftEjectReq = TRUE;
843 Vcb->SoftEjectReq = TRUE;
846 }
847 UDFPrint((" !Vcb->EjectWaiter\n"));
848 goto ioctl_do_default;
849/*
850 Buf = (PPREVENT_MEDIA_REMOVAL_USER_IN)MyAllocatePool__(NonPagedPool, sizeof(PREVENT_MEDIA_REMOVAL_USER_IN));
851 if(!Buf) try_return(RC = STATUS_INSUFFICIENT_RESOURCES);
852 // Acquire Vcb resource (Shared -> Exclusive)
853 UDFReleaseResource(&(Vcb->VCBResource));
854 UDFAcquireResourceExclusive(&(Vcb->VCBResource), TRUE);
855
856 Vcb->Vpb->RealDevice->Flags |= DO_VERIFY_VOLUME;
857 Vcb->VCBFlags &= ~UDF_VCB_FLAGS_VOLUME_MOUNTED;
858
859 UDFDoDismountSequence(Vcb, Buf, IoControlCode == IOCTL_CDROM_EJECT_MEDIA);
860 // disable Eject Request Waiter if any
861 MyFreePool__(Buf);
862 // Release the Vcb resource.
863 UDFReleaseResource(&(Vcb->VCBResource));
864 AcquiredVcb = FALSE;
865 UDFStopEjectWaiter(Vcb);
866 CompleteIrp = TRUE;
867 RC = STATUS_SUCCESS;
868 break;*/
869 }
871
872 UDFPrint(("UDF Cdrom Disk Type\n"));
874 // Verify the Vcb in this case to detect if the volume has changed.
875 Irp->IoStatus.Information = 0;
876 RC = UDFVerifyVcb(PtrIrpContext,Vcb);
877 if(!NT_SUCCESS(RC))
878 try_return(RC);
879
880 // Check the size of the output buffer.
881 if (IrpSp->Parameters.DeviceIoControl.OutputBufferLength < sizeof(CDROM_DISK_DATA_USER_OUT))
883
884 // Copy the data from the Vcb.
885 ((PCDROM_DISK_DATA_USER_OUT)(Irp->AssociatedIrp.SystemBuffer))->DiskData = CDROM_DISK_DATA_TRACK;
886 for(TrackNumber=Vcb->FirstTrackNum; TrackNumber<Vcb->LastTrackNum; TrackNumber++) {
887 if((Vcb->TrackMap[TrackNumber].TrackParam & Trk_QSubChan_Type_Mask) ==
889 ((PCDROM_DISK_DATA_USER_OUT)(Irp->AssociatedIrp.SystemBuffer))->DiskData |= CDROM_DISK_AUDIO_TRACK;
890 break;
891 }
892 }
893
894 Irp->IoStatus.Information = sizeof(CDROM_DISK_DATA_USER_OUT);
895 RC = STATUS_SUCCESS;
896 break;
897 }
898
903 UDFPrint(("UDF Lock/Unlock\n"));
904 PPREVENT_MEDIA_REMOVAL_USER_IN buffer; // user supplied buffer
905 buffer = (PPREVENT_MEDIA_REMOVAL_USER_IN)(Irp->AssociatedIrp.SystemBuffer);
906 if(!buffer) {
907 if(!(Vcb->VCBFlags & UDF_VCB_FLAGS_VOLUME_MOUNTED)) {
908 UDFPrint(("!mounted\n"));
909 goto ioctl_do_default;
910 }
911 UDFPrint(("abort\n"));
913 Irp->IoStatus.Information = 0;
914 UnsafeIoctl = FALSE;
916 break;
917 }
918 if(!buffer->PreventMediaRemoval &&
919 !Vcb->MediaLockCount) {
920
921 UDFPrint(("!locked + unlock req\n"));
922 if(!(Vcb->VCBFlags & UDF_VCB_FLAGS_VOLUME_MOUNTED)) {
923 UDFPrint(("!mounted\n"));
924 goto ioctl_do_default;
925 }
926#if 0
927 // allocate tmp buffer for FSD calls
929 if(!Buf)
931
932 // Acquire Vcb resource (Shared -> Exclusive)
933 UDFInterlockedIncrement((PLONG)&(Vcb->VCBOpenCount));
934 UDFReleaseResource(&(Vcb->VCBResource));
935
936#ifdef UDF_DELAYED_CLOSE
937 // Acquire exclusive access to the Vcb.
939#endif //UDF_DELAYED_CLOSE
940
941 UDFAcquireResourceExclusive(&(Vcb->VCBResource), TRUE);
942 UDFInterlockedDecrement((PLONG)&(Vcb->VCBOpenCount));
943
945 MyFreePool__(Buf);
946 Buf = NULL;
947 Vcb->MediaLockCount = 0;
948 // Release the Vcb resource.
949 UDFReleaseResource(&(Vcb->VCBResource));
950 AcquiredVcb = FALSE;
951 // disable Eject Request Waiter if any
953#else
954 // just ignore
955#endif
956ignore_lock:
957 UDFPrint(("ignore lock/unlock\n"));
959 Irp->IoStatus.Information = 0;
960 RC = STATUS_SUCCESS;
961 break;
962 }
963 if(buffer->PreventMediaRemoval) {
964 UDFPrint(("lock req\n"));
965 Vcb->MediaLockCount++;
966 Vcb->VCBFlags |= UDF_VCB_FLAGS_MEDIA_LOCKED;
967 UnsafeIoctl = FALSE;
968 } else {
969 UDFPrint(("unlock req\n"));
970 if(Vcb->MediaLockCount) {
971 UDFPrint(("lock count %d\n", Vcb->MediaLockCount));
972 UnsafeIoctl = FALSE;
973 Vcb->MediaLockCount--;
974 }
975 }
976 if(!(Vcb->VCBFlags & UDF_VCB_FLAGS_VOLUME_MOUNTED)) {
977 UDFPrint(("!mounted\n"));
978 goto ioctl_do_default;
979 }
980 goto ignore_lock;
981 }
982 default:
983
984 UDFPrint(("default processing Irp %x, ctx %x, DevIoCtl %x\n", Irp, PtrIrpContext, IoControlCode));
985ioctl_do_default:
986
987 // make sure volume is Sync'ed BEFORE sending unsafe IOCTL
988 if(Vcb && UnsafeIoctl) {
990 UDFPrint((" sync'ed\n"));
991 }
992 // Invoke the lower level driver in the chain.
993 //PtrNextIoStackLocation = IoGetNextIrpStackLocation(Irp);
994 //*PtrNextIoStackLocation = *IrpSp;
996/*
997 // Set a completion routine.
998 IoSetCompletionRoutine(Irp, UDFDevIoctlCompletion, PtrIrpContext, TRUE, TRUE, TRUE);
999 // Send the request.
1000*/
1001 RC = IoCallDriver(Vcb->TargetDeviceObject, Irp);
1002 if(!CompleteIrp) {
1003 // since now we do not use IoSetCompletionRoutine()
1004 UDFReleaseIrpContext(PtrIrpContext);
1005 }
1006 break;
1007 }
1008
1009 if(Vcb && UnsafeIoctl) {
1010 UDFPrint((" set UnsafeIoctl\n"));
1011 Vcb->VCBFlags |= UDF_VCB_FLAGS_UNSAFE_IOCTL;
1012 }
1013
1014try_exit: NOTHING;
1015
1016 } _SEH2_FINALLY {
1017
1018 if(AcquiredVcb) {
1019 UDFReleaseResource(&(Vcb->VCBResource));
1020 AcquiredVcb = FALSE;
1021 }
1022
1023 if(Buf) {
1024 MyFreePool__(Buf);
1025 }
1026
1028 CompleteIrp) {
1029 UDFPrint((" complete Irp %x, ctx %x, status %x, iolen %x\n",
1030 Irp, PtrIrpContext, RC, Irp->IoStatus.Information));
1031 Irp->IoStatus.Status = RC;
1032 // complete the IRP
1034 // Release the IRP context
1035 UDFReleaseIrpContext(PtrIrpContext);
1036 }
1037 } _SEH2_END;
1038
1039 return(RC);
1040} // end UDFCommonDeviceControl()
#define SCSIOP_WRITE_CD
Definition: cdrw_hw.h:907
#define Trk_QSubChan_Type_Mask
Definition: cdrw_hw.h:2370
#define SCSIOP_DOORUNLOCK
Definition: cdrw_hw.h:972
#define Trk_QSubChan_Type_Audio
Definition: cdrw_hw.h:2372
#define SCSIOP_SEND_CUE_SHEET
Definition: cdrw_hw.h:949
#define SCSIOP_WRITE6
Definition: cdrw_hw.h:876
#define MODE_PAGE_MRW2
Definition: cdrw_hw.h:843
#define SCSIOP_MEDIUM_REMOVAL
Definition: cdrw_hw.h:902
#define SCSIOP_SEND_DVD_STRUCTURE
Definition: cdrw_hw.h:969
#define SCSIOP_FORMAT_UNIT
Definition: cdrw_hw.h:871
#define SCSIOP_RESERVE_TRACK
Definition: cdrw_hw.h:941
#define MODE_PAGE_WRITE_PARAMS
Definition: cdrw_hw.h:844
#define MODE_PAGE_MRW
Definition: cdrw_hw.h:855
#define SCSIOP_CLOSE_TRACK_SESSION
Definition: cdrw_hw.h:947
#define SCSIOP_BLANK
Definition: cdrw_hw.h:950
#define SCSIOP_DOORLOCK
Definition: cdrw_hw.h:971
#define SCSIOP_WRITE12
Definition: cdrw_hw.h:957
union _CDB * PCDB
#define SCSIOP_START_STOP_UNIT
Definition: cdrw_hw.h:897
#define SCSIOP_SET_STREAMING
Definition: cdrw_hw.h:963
#define SCSIOP_MODE_SELECT10
Definition: cdrw_hw.h:943
#define SCSIOP_MODE_SELECT
Definition: cdrw_hw.h:891