ReactOS 0.4.15-dev-7906-g1b85a5f
phys_lib.cpp File Reference
#include "phys_lib.h"
Include dependency graph for phys_lib.cpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define Vcb   ((PVCB)_Vcb)
 
#define fms   FALSE
 
#define TempMSF   toc->SessionData[index].Params.StartPositionOfLeadOut.MSF
 
#define TempMSF   toc->SessionData[index].Params.StartPositionOfTrack.MSF
 
#define TempMSF   toc->SessionData[index].Params.StartPositionOfTrack.MSF
 
#define TempMSF   toc->SessionData[index].Params.StartPositionOfNextProgramArea.MaxLeadOut_MSF
 
#define fms   FALSE
 
#define TempMSF   toc->TrackData[TocEntry].LBA
 
#define fms   FALSE
 
#define fms   FALSE
 
#define cap   ((PGET_CAPABILITIES_3_USER_OUT)ioBuf)
 

Functions

OSSTATUS UDFSetSpeeds (IN PVCB Vcb)
 
NTSTATUS UDFSetCaching (IN PVCB Vcb)
 
OSSTATUS UDFRecoverFromError (IN PVCB Vcb, IN BOOLEAN WriteOp, IN OSSTATUS status, IN uint32 Lba, IN uint32 BCount, IN OUT uint32 *retry)
 
NTSTATUS UDFSyncCache (IN PVCB Vcb)
 
OSSTATUS UDFReallocTrackMap (IN PVCB Vcb, IN uint32 TrackNum)
 
OSSTATUS UDFTWrite (IN void *_Vcb, IN void *Buffer, IN SIZE_T Length, IN uint32 LBA, OUT PSIZE_T WrittenBytes, IN uint32 Flags)
 
OSSTATUS UDFTRead (IN void *_Vcb, IN void *Buffer, IN SIZE_T Length, IN uint32 LBA, OUT PSIZE_T ReadBytes, IN uint32 Flags)
 
NTSTATUS UDFSetMRWMode (IN PVCB Vcb)
 
OSSTATUS UDFDoOPC (IN PVCB Vcb)
 
OSSTATUS UDFPrepareForWriteOperation (IN PVCB Vcb, IN uint32 Lba, IN uint32 BCount)
 
OSSTATUS UDFReadDiscTrackInfo (PDEVICE_OBJECT DeviceObject, PVCB Vcb)
 
OSSTATUS UDFReadAndProcessFullToc (PDEVICE_OBJECT DeviceObject, PVCB Vcb)
 
OSSTATUS UDFUseStandard (PDEVICE_OBJECT DeviceObject, PVCB Vcb)
 
OSSTATUS UDFGetBlockSize (IN PDEVICE_OBJECT DeviceObject, IN PVCB Vcb)
 
OSSTATUS UDFGetDiskInfo (IN PDEVICE_OBJECT DeviceObject, IN PVCB Vcb)
 
OSSTATUS UDFPrepareForReadOperation (IN PVCB Vcb, IN uint32 Lba, IN uint32 BCount)
 
void UDFUpdateNWA (PVCB Vcb, uint32 LBA, uint32 BCount, OSSTATUS RC)
 
OSSTATUS UDFWriteSectors (IN PVCB Vcb, IN BOOLEAN Translate, IN uint32 Lba, IN uint32 BCount, IN BOOLEAN Direct, IN int8 *Buffer, OUT PSIZE_T WrittenBytes)
 
OSSTATUS UDFWriteInSector (IN PVCB Vcb, IN BOOLEAN Translate, IN uint32 Lba, IN uint32 i, IN uint32 l, IN BOOLEAN Direct, OUT int8 *Buffer, OUT PSIZE_T WrittenBytes)
 
OSSTATUS UDFWriteData (IN PVCB Vcb, IN BOOLEAN Translate, IN int64 Offset, IN SIZE_T Length, IN BOOLEAN Direct, IN int8 *Buffer, OUT PSIZE_T WrittenBytes)
 
OSSTATUS UDFResetDeviceDriver (IN PVCB Vcb, IN PDEVICE_OBJECT TargetDeviceObject, IN BOOLEAN Unlock)
 

Variables

static const char Signature [16] = {CDRW_SIGNATURE_v1}
 

Macro Definition Documentation

◆ cap

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 cap   ((PGET_CAPABILITIES_3_USER_OUT)ioBuf)

◆ fms [1/4]

#define fms   FALSE

◆ fms [2/4]

#define fms   FALSE

◆ fms [3/4]

#define fms   FALSE

◆ fms [4/4]

#define fms   FALSE

◆ TempMSF [1/5]

#define TempMSF   toc->SessionData[index].Params.StartPositionOfLeadOut.MSF

◆ TempMSF [2/5]

#define TempMSF   toc->SessionData[index].Params.StartPositionOfTrack.MSF

◆ TempMSF [3/5]

#define TempMSF   toc->SessionData[index].Params.StartPositionOfTrack.MSF

◆ TempMSF [4/5]

#define TempMSF   toc->SessionData[index].Params.StartPositionOfNextProgramArea.MaxLeadOut_MSF

◆ TempMSF [5/5]

#define TempMSF   toc->TrackData[TocEntry].LBA

◆ Vcb

IN PVCB Vcb   ((PVCB)_Vcb)

Definition at line 1415 of file cdprocs.h.

Referenced by __attribute__(), __brelse(), _Dispatch_type_(), _Function_class_(), _Requires_lock_held_(), _Requires_lock_not_held_(), _Success_(), add_balance_item(), add_calc_job_comp(), add_calc_job_decomp(), add_checksum_entry(), add_children_to_move_list(), add_csum_sparse_extents(), add_data_reloc(), add_data_reloc_extent_item(), add_device(), add_ext_holes(), add_metadata_reloc(), add_metadata_reloc_extent_item(), add_metadata_reloc_parent(), add_parents(), add_root_item_to_cache(), add_root_ref(), add_thread_job(), add_to_bootstrap(), add_trim_entry_avoid_sb(), add_volume_device(), AddBitmap(), AddFixupArray(), AddIndexAllocation(), AddIndexRoot(), AddRun(), allocate_cache(), allocate_cache_chunk(), allocate_tree_extents(), allow_extended_dasd_io(), balance_data_chunk(), balance_metadata_chunk(), bmap(), BrowseIndexEntries(), BrowseSubNodeIndexEntries(), calc_thread_main(), calc_tree_checksum(), CdCreateInternalStream(), CdDeleteFcb(), CdDeleteVcb(), CdFindActiveVolDescriptor(), CdFinishBuffers(), CdGetNextFcb(), CdInitializeVcb(), CdLookupFcbTable(), CdMarkDevForVerifyIfVcbMounted(), CdQueryFsAttributeInfo(), CdQueryFsDeviceInfo(), CdQueryFsSectorSizeInfo(), CdQueryFsSizeInfo(), CdRemoveClose(), CdUnlockVolumeInternal(), CdUpdateVcbFromVolDescriptor(), CdVerifyFcbOperation(), CdVerifyVcb(), check_csum(), check_for_orphans(), check_for_orphans_root(), check_inode_used(), check_sector_csum(), check_tree_checksum(), clean_space_cache(), clean_space_cache_chunk(), clear_free_space_cache(), construct_extent_item(), convert_old_extent(), create_chunk(), create_directory_fcb(), create_fcb(), create_fileref(), create_snapshot(), create_stream(), create_subvol(), CreateBTreeFromIndex(), CreateBTreeNodeFromIndexNode(), data_reloc_add_tree_edr(), decrease_extent_refcount(), decrease_extent_refcount_data(), decrease_extent_refcount_tree(), delete_root_ref(), delete_xattr(), dismount_volume(), do_calc_job(), do_create_snapshot(), do_flush(), do_splits(), do_tree_writes(), do_unlock_volume(), do_write(), do_write2(), do_write_job(), drop_chunk(), drop_root(), drop_roots(), duplicate_extents(), duplicate_fcb(), Ex2ProcessUserPerfStat(), Ext2AddBlockExtent(), Ext2AddEntry(), Ext2AddVcbExtent(), Ext2AllocateFcb(), Ext2AllocateInode(), Ext2AllocateMcb(), Ext2AllowExtendedDasdIo(), Ext2bhReaperThread(), Ext2BlockMap(), Ext2BuildEntry(), Ext2BuildExtents(), Ext2CheckBitmapConsistency(), Ext2CheckDismount(), Ext2CheckFileAccess(), Ext2CheckInodeAccess(), Ext2CheckJournal(), Ext2CheckSetBlock(), Ext2Cleanup(), Ext2CleanupAllMcbs(), Ext2ClearInode(), Ext2Close(), Ext2Create(), Ext2CreateFile(), Ext2CreateInode(), Ext2CreateVolume(), Ext2DeleteFile(), Ext2DeleteReparsePoint(), Ext2DestroyInode(), Ext2DestroyVcb(), Ext2DeviceControlNormal(), Ext2DiskShutDown(), Ext2DismountVolume(), Ext2DoExtentExpand(), Ext2DropBH(), Ext2DropGroupBH(), Ext2ExceptionFilter(), Ext2ExceptionHandler(), Ext2ExpandBlock(), Ext2ExpandExtent(), Ext2ExpandFile(), Ext2ExpandIndirect(), Ext2ExpandLast(), Ext2FastIoQueryStandardInfo(), Ext2FcbReaperThread(), Ext2FillEntry(), Ext2FirstUnusedMcb(), Ext2FloppyFlush(), Ext2Flush(), Ext2FlushFiles(), Ext2FlushRange(), Ext2FlushVcb(), Ext2FlushVolume(), Ext2FollowLink(), Ext2FreeBlock(), Ext2FreeCcb(), Ext2FreeFcb(), Ext2FreeInode(), Ext2GetBlock(), Ext2GetInodeLba(), Ext2GetReparsePoint(), Ext2GetRetrievalPointerBase(), Ext2GetRetrievalPointers(), Ext2InitializeLabel(), Ext2InitializeVcb(), Ext2InitializeZone(), Ext2InsertFcb(), Ext2InsertMcb(), Ext2InsertVcb(), Ext2InvalidateVolumes(), Ext2IsFileRemovable(), Ext2IsHandleCountZero(), Ext2IsVolumeMounted(), Ext2IsWearingCloak(), Ext2LinkHeadMcb(), Ext2LinkTailMcb(), Ext2LoadBlock(), Ext2LoadBuffer(), Ext2LoadGroup(), Ext2LoadGroupBH(), Ext2LoadInode(), Ext2LoadInodeXattr(), Ext2LoadInternalJournal(), Ext2LoadSuper(), Ext2LockVcb(), Ext2LockVolume(), Ext2LookupBlockExtent(), Ext2LookupFile(), Ext2LookupVcbExtent(), Ext2MapExtent(), Ext2MapIndirect(), Ext2McbReaperThread(), Ext2MediaEjectControl(), Ext2MountVolume(), Ext2NewBlock(), Ext2NewInode(), Ext2NotifyChangeDirectory(), Ext2NotifyReportChange(), Ext2OEMToUnicode(), Ext2OEMToUnicodeSize(), Ext2OplockRequest(), Ext2OverwriteEa(), Ext2PerformRegistryVolumeParams(), Ext2ProcessEntry(), Ext2ProcessUserProperty(), Ext2ProcessVolumeProperty(), Ext2PurgeVolume(), Ext2PutGroup(), Ext2QueryDirectory(), Ext2QueryEa(), Ext2QueryExtentMappings(), Ext2QueryFileInformation(), Ext2QueryRetrievalPointers(), Ext2QueryUnusedBH(), Ext2QueryUnusedFcb(), Ext2QueryVolumeInformation(), Ext2QueryVolumeParams(), Ext2Read(), Ext2ReadDisk(), Ext2ReadFile(), Ext2ReadInode(), Ext2ReadSymlink(), Ext2ReadSync(), Ext2ReadVolume(), Ext2ReadWriteBlocks(), Ext2RecoverJournal(), Ext2RefreshSuper(), Ext2ReleaseFcb(), Ext2RemoveBlockExtent(), Ext2RemoveMcb(), Ext2RemoveVcb(), Ext2RemoveVcbExtent(), Ext2SaveBlock(), Ext2SaveBuffer(), Ext2SaveGroup(), Ext2SaveInode(), Ext2SaveInodeXattr(), Ext2SaveSuper(), Ext2ScanDir(), Ext2SearchMcb(), Ext2SetDispositionInfo(), Ext2SetEa(), Ext2SetFileInformation(), Ext2SetLinkInfo(), Ext2SetParentEntry(), Ext2SetRenameInfo(), Ext2SetReparsePoint(), Ext2SetVolumeInformation(), Ext2ShutDown(), Ext2StartFloppyFlushDpc(), Ext2SupersedeOrOverWriteFile(), Ext2TearDownStream(), Ext2TotalBlocks(), Ext2TruncateBlock(), Ext2TruncateExtent(), Ext2TruncateFile(), Ext2TruncateIndirect(), Ext2TruncateIndirectFast(), Ext2TruncateSymlink(), Ext2UnicodeToOEM(), Ext2UnicodeToOEMSize(), Ext2UnlinkFcb(), Ext2UnlinkMcb(), Ext2UnlockVcb(), Ext2UnlockVolume(), Ext2UpdateGroupDirStat(), Ext2UpdateVcbStat(), Ext2VerifyVcb(), Ext2VerifyVolume(), Ext2Write(), Ext2WriteFile(), Ext2WriteInode(), Ext2WriteSymlink(), Ext2WriteVolume(), Ext2ZeroBuffer(), ext3_inode_blocks(), ext3_inode_blocks_set(), ext4_check_descriptors(), ext4_inode_to_goal_block(), FatAddMcbEntry(), FatAllocateCloseContext(), FatAllowExtendedDasdIo(), FatAutoUnlock(), FatCheckDirtyBit(), FatCleanVolumeDpc(), FatCloseEaFile(), FatCommonQueryEa(), FatCommonSetEa(), FatComputeMoveFileSplicePoints(), FatCreateDcb(), FatCreateFcb(), FatCreateIrpContext(), FatDecodeFileObject(), FatDeferredCleanVolume(), FatDeferredFlush(), FatDeleteVcb(), FatExamineFatEntries(), FatFlushFat(), FatFlushFatEntries(), FatFspDispatch(), FatFspMarkVolumeDirtyWithRecover(), FatGetStatistics(), FatInterpretClusterType(), FatIsHandleCountZero(), FatIsVolumeDirty(), FatIsVolumeMounted(), FatLookupFatEntry(), FatMarkDevForVerifyIfVcbMounted(), FatMultipleAsync(), FatPagingFileErrorHandler(), FatPerformVerifyDiskRead(), FatPnpAdjustVpbRefCount(), FatPreallocateCloseContext(), FatQueryBpb(), FatQueryFsAttributeInfo(), FatQueryFsDeviceInfo(), FatQueryFsFullSizeInfo(), FatQueryFsSectorSizeInfo(), FatQueryFsSizeInfo(), FatQueryFsVolumeInfo(), FatQuickVerifyVcb(), FatReadEaSet(), FatReadVolumeFile(), FatSelectBestWindow(), FatSetFatRun(), FatSetFsLabelInfo(), FatSetRenameInfo(), FatSetupAllocationSupport(), FatSetZeroOnDeallocate(), FatSingleAsync(), FatSingleNonAlignedSync(), FatSwapVpb(), FatTearDownAllocationSupport(), FatTearDownVcb(), FatToggleMediaEjectDisable(), FatUnlockVolume(), FatUnlockVolumeInternal(), FatVerifyLookupFatEntry(), FatVerifyVcb(), FatZeroData(), fcb_load_csums(), file_create(), file_create2(), find_extent_data_refcount(), find_extent_shared_data_refcount(), find_extent_shared_tree_refcount(), find_metadata_address_in_chunk(), find_subvol(), FindAttribute(), FindFirstAttribute(), finish_removing_device(), FixupUpdateSequenceArray(), flush_changed_dev_stats(), flush_changed_extent(), flush_disk_caches(), flush_fcb_caches(), flush_partial_stripe(), flush_subvol(), free_vol(), FreeClusters(), fsctl_get_xattrs(), fsctl_oplock(), fsctl_request(), fsctl_set_xattr(), get_block_bh_mdl(), get_block_bh_pin(), get_csum_info(), get_devices(), get_ea_len(), get_extent_flags(), get_extent_refcount(), get_integrity_information(), get_reparse_tag(), get_retrieval_pointers(), get_sector_csum(), get_subvol_path(), get_tree_checksum(), get_tree_new_address(), get_usage(), GetBestFileNameFromRecord(), GetFileNameFromRecord(), GetStandardInformationFromRecord(), if(), increase_extent_refcount(), increase_extent_refcount_data(), IncreaseMftSize(), insert_extent_chunk(), insert_tree_extent(), insert_tree_extent_skinny(), insert_tree_item_batch(), invalidate_volumes(), is_device_part_of_mounted_btrfs_raid(), is_extent_unique(), is_tree_unique(), is_volume_dirty(), is_volume_mounted(), is_writable(), load_cache_chunk(), load_csum(), load_dir_children(), load_free_space_bitmap(), load_free_space_cache(), load_stored_free_space_cache(), load_stored_free_space_tree(), lock_volume(), log_error(), log_file_checksum_error(), log_file_checksum_error_shared(), log_tree_checksum_error(), log_tree_checksum_error_shared(), log_unrecoverable_error(), look_for_balance_item(), main(), mark_subvol_dirty(), mknod(), mountdev_query_stable_guid(), MupCleanupVcb(), MupCloseVcb(), MupDereferenceVcb(), MupInitializeVcb(), my_open(), my_retrieve_vol_type(), notify_change_directory(), NtfsAddFCBToTable(), NtfsAttachFCBToFileObject(), NtfsCreateFCB(), NtfsDirFindFile(), NtfsDumpFileAttributes(), NtfsDumpFileRecord(), NtfsFCBInitializeCache(), NtfsFindFileAt(), NtfsFindMftRecord(), NtfsGetFCBForFile(), NtfsGrabFCB(), NtfsGrabFCBFromTable(), NtfsLookupFile(), NtfsLookupFileAt(), NtfsMakeFCBFromDirEntry(), NtfsMakeRootFCB(), NtfsMountVolume(), NtfsOpenRootFCB(), NtfsReadFCBAttribute(), NtfsReleaseFCB(), open_fcb(), open_fcb_stream(), open_file(), open_file2(), open_file3(), open_fileref(), open_fileref_by_inode(), open_fileref_child(), OpenMupFileSystem(), oplock_complete(), partial_stripe_read(), pause_balance(), pause_scrub(), pnp_device_usage_notification(), pnp_query_remove_device(), pnp_remove_device(), pnp_surprise_removal(), print_open_trees(), PrintAllVCNs(), query_balance(), query_directory(), query_filesystems(), query_info(), query_scrub(), query_uuid(), RawCheckForDismount(), RawCleanup(), RawClose(), RawCreate(), RawDispatch(), RawFileSystemControl(), RawInitializeVcb(), RawQueryFsAttributeInfo(), RawQueryFsDeviceInfo(), RawQueryFsSizeInfo(), RawQueryFsVolumeInfo(), RawQueryInformation(), RawQueryVolumeInformation(), RawReadWriteDeviceControl(), RawSetInformation(), RawUserFsCtrl(), read_data(), read_data_dup(), read_data_raid0(), read_data_raid10(), read_data_raid5(), read_data_raid6(), read_send_buffer(), ReadAttribute(), ReadFileRecord(), ReadLCN(), recvd_subvol(), reduce_tree_extent(), regen_bootstrap(), regenerate_space_list(), registry_load_volume_options(), remove_balance_item(), remove_device(), remove_free_space_inode(), remove_from_bootstrap(), remove_root_extents(), remove_volume_child(), rename_file_to_stream(), rename_stream(), rename_stream_to_file(), reserve_subvol(), reset_stats(), resize_device(), resume_balance(), resume_scrub(), scrub_chunk(), scrub_chunk_raid56(), scrub_chunk_raid56_stripe_run(), scrub_data_extent(), scrub_extent(), scrub_extent_dup(), scrub_extent_raid0(), scrub_extent_raid10(), scrub_raid5_stripe(), scrub_raid6_stripe(), send_subvol(), set_basic_information(), set_disposition_information(), set_end_of_file_information(), set_file_security(), set_link_information(), set_rename_information(), set_sparse(), set_valid_data_length_information(), set_xattr(), set_zero_data(), SetNonResidentAttributeDataLength(), SetResidentAttributeDataLength(), shared_tree_is_unique(), should_balance_chunk(), snapshot_tree_copy(), split_path(), split_tree(), split_tree_at(), start_balance(), start_scrub(), stop_balance(), stop_scrub(), stream_set_end_of_file_information(), submit_bh_mdl(), submit_bh_pin(), sync_blockdev(), test_not_full(), trees_consistent(), trim_unalloc_space(), try_consolidation(), try_tree_amalgamate(), UDFAcquireDloc(), UDFAddXSpaceBitmap(), UDFAllocateFESpace(), UDFAllocFreeExtent_(), UDFAreSectorsRelocated(), UDFAssignAcl(), UDFAssingNewFUID(), UDFBlankMount(), UDFBuildAllocDescs(), UDFBuildFileEntry(), UDFBuildFreeSpaceBitmap(), UDFBuildHashEntry(), UDFBuildLongAllocDescs(), UDFBuildShortAllocDescs(), UDFBuildTreeItemsList(), UDFChangeFileCounter(), UDFCheckArea(), UDFCheckForDismount(), UDFCleanUpFcbChain(), UDFCleanUpFile__(), UDFCleanupVCB(), UDFCloseAllDelayed(), UDFCloseAllXXXDelayedInDir(), UDFCloseFile__(), UDFCloseFileInfoChain(), UDFCloseResidual(), UDFClrModified(), UDFCommonCleanup(), UDFCommonClose(), UDFCommonCreate(), UDFCommonDeviceControl(), UDFCommonDirControl(), UDFCommonDispatch(), UDFCommonFileInfo(), UDFCommonFlush(), UDFCommonPnp(), UDFCommonQueryVolInfo(), UDFCommonRead(), UDFCommonSetVolInfo(), UDFCommonShutdown(), UDFCommonWrite(), UDFCompleteMount(), UDFConvertFEToExtended(), UDFConvertFEToNonInICB(), UDFCreateFile__(), UDFCreateRootFile__(), UDFCreateStreamDir__(), UDFDiscardFESpace(), UDFDismountVcb(), UDFDismountVolume(), UDFDoDismountSequence(), UDFDoOPC(), UDFDOSName(), UDFEjectReqWaiter(), UDFExtAllocDescToMapping(), UDFExtentOffsetToLba(), UDFFileDirInfoToNT(), UDFFindAnchor(), UDFFindDloc(), UDFFindDlocInMem(), UDFFindFile(), UDFFindFile__(), UDFFindFileId(), UDFFindFreeDloc(), UDFFindFreeFileId(), UDFFindLastFileSet(), UDFFindMinSuitableExtent(), UDFFindNextMatch(), UDFFindVRS(), UDFFirstOpenFile(), UDFFlushADirectory(), UDFFlushAllCachedAllocations(), UDFFlushFE(), UDFFlushFESpace(), UDFFlushFI(), UDFFlushFile__(), UDFFlushIsBreaking(), UDFFlushLogicalVolume(), UDFFlushTryBreak(), UDFFreeDloc(), UDFFreeFESpace(), UDFFreeFileAllocation(), UDFGetBlockSize(), UDFGetCachedAllocation(), UDFGetCfgParameter(), UDFGetDiskInfo(), UDFGetDiskInfoAndVerify(), UDFGetFileStreamInformation(), UDFGetFreeSpace(), UDFGetInternalInformation(), UDFGetMediaClass(), UDFGetOpenParamsByFileId(), UDFGetPartFreeSpace(), UDFGetPartNumByPhysLba(), UDFGetRegParameter(), UDFGetRetrievalPointers(), UDFGetStatistics(), UDFGetTotalSpace(), UDFGetVolumeBitmap(), UDFHardLink(), UDFHardLinkFile__(), UDFIndexDirectory(), UDFInitAllocationCache(), UDFInitializeFCB(), UDFInitializeVCB(), UDFInvalidateVolumes(), UDFIsCachedBadSequence(), UDFIsExtentCached(), UDFIsNameInExpression(), UDFIsVolumeDirty(), UDFLoadBogusLogicalVol(), UDFLoadExtInfo(), UDFLoadFileset(), UDFLoadLogicalVol(), UDFLoadLogicalVolInt(), UDFLoadPartDesc(), UDFLoadPartition(), UDFLoadPVolDesc(), UDFLoadSparingTable(), UDFLoadVAT(), UDFLocateLbaInExtent(), UDFLockVolume(), UDFLongAllocDescToMapping(), UDFLookUpAcl(), UDFMarkAllocatedAsNotXXX(), UDFMarkAllocatedAsRecorded(), UDFMarkBadSpaceAsUsed(), UDFMarkNotAllocatedAsAllocated(), UDFMarkSpaceAsXXX_(), UDFMarkSpaceAsXXXNoProtect_(), UDFMarkStreamsForDeletion(), UDFMountVolume(), UDFNotifyChangeDirectory(), UDFOpenFile(), UDFOpenFile__(), UDFOpenRootFile__(), UDFOpenStreamDir__(), UDFPackDirectory__(), UDFPackMapping(), UDFPadLastSector(), UDFPartEnd(), UDFPartLbaToPhys(), UDFPartLen(), UDFPartStart(), UDFPerformVerify(), UDFPhReadSynchronous(), UDFPhWriteSynchronous(), UDFPhysLbaToPart(), UDFPnpQueryRemove(), UDFPnpRemove(), UDFPnpSurpriseRemove(), UDFPostRequest(), UDFPreClrModified(), UDFPrepareForReadOperation(), UDFPrepareForRenameMoveLink(), UDFPrepareForWriteOperation(), UDFPrepareXSpaceBitmap(), UDFProcessSequence(), UDFPurgeCacheEx_(), UDFQueryDirectory(), UDFQueryFsAttributeInfo(), UDFQueryFsDeviceInfo(), UDFQueryFsFullSizeInfo(), UDFQueryFsSizeInfo(), UDFQueryFsVolumeInfo(), UDFReadAndProcessFullToc(), UDFReadDiscTrackInfo(), UDFReadEntityID_Domain(), UDFReadExtent(), UDFReadExtentLocation(), UDFReadFile__(), UDFReadFileEntry(), UDFReadFileLocation__(), UDFReadMappingFromXEntry(), UDFReadRegKeys(), UDFReadSecurity(), UDFReadTagged(), UDFReadVDS(), UDFReallocTrackMap(), UDFRecordDirectory__(), UDFRecordVAT(), UDFRecoverFromError(), UDFReleaseDloc(), UDFReleaseDlocList(), UDFReleaseFileIdCache(), UDFReleaseVCB(), UDFRelocateDloc(), UDFRelocateSector(), UDFRelocateSectors(), UDFRemapPacket(), UDFRememberBadSequence(), UDFRemoveDloc(), UDFRemoveFileId(), UDFRename(), UDFRenameMoveFile__(), UDFResetDeviceDriver(), UDFResizeExtent(), UDFResizeFile__(), UDFReTagDirectory(), UDFScanForDismountedVcb(), UDFSetAllocationInformation(), UDFSetAllocDescLen(), UDFSetCaching(), UDFSetDispositionInformation(), UDFSetEOF(), UDFSetFileAllocModeFromICB(), UDFSetFileUID(), UDFSetLabelInfo(), UDFSetModified(), UDFSetMRWMode(), UDFSetSpeeds(), UDFSetUpTag(), UDFShortAllocDescToMapping(), UDFSparseFile__(), UDFStartEjectWaiter(), UDFStopEjectWaiter(), UDFStoreCachedAllocation(), UDFStoreDloc(), UDFStoreFileId(), UDFSyncCache(), UDFTRead(), UDFTSendIOCTL(), UDFTWrite(), UDFUmount__(), UDFUnlinkAllFilesInDir(), UDFUnlinkDloc(), UDFUnlinkFile__(), UDFUnlockVolume(), UDFUnmapRange(), UDFUnPackMapping(), UDFUpdateCompatOption(), UDFUpdateLogicalVol(), UDFUpdateLogicalVolInt(), UDFUpdateNonAllocated(), UDFUpdateNWA(), UDFUpdatePartDesc(), UDFUpdateSparingTable(), UDFUpdateVAT(), UDFUpdateVDS(), UDFUpdateVolIdent(), UDFUpdateXSpaceBitmaps(), UDFUseStandard(), UDFVerifyFreeSpaceBitmap(), UDFVerifyPartDesc(), UDFVerifySequence(), UDFVerifyVcb(), UDFVerifyVolume(), UDFVerifyXSpaceBitmap(), UDFVFlush(), UDFVForget(), UDFVInit(), UDFVIsStored(), UDFVRead(), UDFVRelease(), UDFVStoreBlock(), UDFVUpdateBlock(), UDFVVerify(), UDFVWorkItem(), UDFVWrite(), UDFWriteData(), UDFWriteExtent(), UDFWriteFile__(), UDFWriteInSector(), UDFWriteSectors(), UDFWriteSecurity(), UDFZeroExtent(), UDFZeroFile__(), unlock_volume(), update_backup_superblock(), update_changed_extent_ref(), update_chunk_cache(), update_chunk_cache_tree(), update_chunk_caches(), update_chunk_caches_tree(), update_chunk_usage(), update_chunks(), update_dev_item(), update_extent_flags(), update_extent_level(), update_root_backref(), update_root_root(), update_tree_extents(), update_tree_extents_recursive(), update_volumes(), UpdateFileNameRecord(), UpdateFileRecord(), UpdateIndexEntryFileNameSize(), UpdateMftMirror(), verify_vcb(), VfatCloseWorker(), VfatDiskShutDown(), vfatInitFCBFromDirEntry(), VfatPnp(), write(), write_metadata_items(), write_superblock(), write_superblocks(), write_trees(), WriteAttribute(), and zero_data().

Function Documentation

◆ UDFDoOPC()

OSSTATUS UDFDoOPC ( IN PVCB  Vcb)

Definition at line 850 of file phys_lib.cpp.

853{
854 OSSTATUS RC;
855 if(Vcb->OPCNum && !Vcb->OPCDone) {
856 UDFPrint(("UDFDoOPC\n"));
857 if(!Vcb->OPCh) {
858 Vcb->OPCh =
861 }
862 if(!Vcb->OPCh)
864 Vcb->OPCh->DoOpc = TRUE;
865 Vcb->OPCh->OpcBlocksNumber = 0;
866 RC = UDFPhSendIOCTL(IOCTL_CDRW_SEND_OPC_INFO, Vcb->TargetDeviceObject,
867 (void*)(Vcb->OPCh),sizeof(SEND_OPC_INFO_HEADER_USER_IN),
868 NULL,0,
869 FALSE, NULL);
870 if(!OS_SUCCESS(RC)) {
871 UDFPrint(("UDFDoOPC failed\n"));
872 Vcb->OPCNum = 0;
873// Vcb->VCBFlags |= UDF_VCB_FLAGS_OPC_FAILED;
874 }
875 Vcb->OPCDone = TRUE;
876 }
877 return RC;
878} // end UDFDoOPC()
struct _SEND_OPC_INFO_HEADER_USER_IN * PSEND_OPC_INFO_HEADER_USER_IN
#define IOCTL_CDRW_SEND_OPC_INFO
Definition: cdrw_usr.h:109
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
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 OS_SUCCESS(a)
Definition: env_spec_w32.h:56
#define OSSTATUS
Definition: env_spec_w32.h:57
#define NonPagedPool
Definition: env_spec_w32.h:307
#define MyAllocatePool__(type, size)
Definition: mem_tools.h:149
#define Vcb
Definition: cdprocs.h:1415
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define UDFPrint(Args)
Definition: udffs.h:223

Referenced by UDFPrepareForWriteOperation().

◆ UDFGetBlockSize()

OSSTATUS UDFGetBlockSize ( IN PDEVICE_OBJECT  DeviceObject,
IN PVCB  Vcb 
)

Definition at line 2687 of file phys_lib.cpp.

2691{
2695#ifdef UDF_FORMAT_MEDIA
2696 PUDFFmtState fms = Vcb->fms;
2697#else
2698 #define fms FALSE
2699#endif //UDF_FORMAT_MEDIA
2700
2701 if(!DiskGeometry || !PartitionInfo)
2703
2704#ifdef _BROWSE_UDF_
2705
2706#ifdef UDF_HDD_SUPPORT
2707 if(!fms) {
2709 UDFPrint(("UDFGetBlockSize: HDD\n"));
2711 0,NULL,
2712 DiskGeometry,sizeof(DISK_GEOMETRY),
2713 TRUE,NULL );
2714 Vcb->BlockSize = (OS_SUCCESS(RC)) ? DiskGeometry->BytesPerSector : 512;
2715 if(!NT_SUCCESS(RC))
2716 try_return(RC);
2718 0,NULL,
2720 TRUE,NULL );
2721 if(!NT_SUCCESS(RC)) {
2722 UDFPrint(("UDFGetBlockSize: IOCTL_DISK_GET_PARTITION_INFO failed\n"));
2723 if(RC == STATUS_INVALID_DEVICE_REQUEST) /* ReactOS Code Change (was =) */
2725 try_return(RC);
2726 }
2727 if(PartitionInfo->PartitionType != PARTITION_IFS) {
2728 UDFPrint(("UDFGetBlockSize: PartitionInfo->PartitionType != PARTITION_IFS\n"));
2730 }
2731 } else {
2732#endif //UDF_HDD_SUPPORT
2734 DiskGeometry,sizeof(DISK_GEOMETRY),
2735 DiskGeometry,sizeof(DISK_GEOMETRY),
2736 TRUE,NULL );
2737
2738 if(RC == STATUS_DEVICE_NOT_READY) {
2739 // probably, the device is really busy, may be by CD/DVD recording
2740 UserPrint((" busy (0)\n"));
2741 try_return(RC);
2742 }
2743
2744 Vcb->BlockSize = (OS_SUCCESS(RC)) ? DiskGeometry->BytesPerSector : 2048;
2745#ifdef UDF_HDD_SUPPORT
2746 }
2747 }
2748#endif //UDF_HDD_SUPPORT
2749
2750#endif //_BROWSE_UDF_
2751
2752#ifdef UDF_FORMAT_MEDIA
2753 if(fms) {
2755 DiskGeometry,sizeof(DISK_GEOMETRY),
2756 DiskGeometry,sizeof(DISK_GEOMETRY),
2757 FALSE, NULL );
2758
2759 if(!NT_SUCCESS(RC)) {
2761 DiskGeometry,sizeof(DISK_GEOMETRY),
2762 DiskGeometry,sizeof(DISK_GEOMETRY),
2763 FALSE, NULL );
2764 if(NT_SUCCESS(RC)) {
2765 fms->opt_media = MT_HD;
2767 NULL,0,
2769 FALSE, NULL );
2770 if(!NT_SUCCESS(RC)) {
2771 LONG HiOffs=0;
2772 RC = SetFilePointer(DeviceObject->h,0,&HiOffs,FILE_END);
2773 }
2774 }
2775 }
2776
2777 if(RC == STATUS_DEVICE_NOT_READY) {
2778 // probably, the device is really busy, may be by CD/DVD recording
2779 UserPrint((" busy\n"));
2780 try_return(RC );
2781 }
2782
2783 Vcb->BlockSize = (NT_SUCCESS(RC)) ? DiskGeometry->BytesPerSector : 2048;
2784 }
2785#endif //UDF_FORMAT_MEDIA
2786
2787 // Block size must be an even multiple of 512
2788 switch (Vcb->BlockSize) {
2789 case 2048: Vcb->BlockSizeBits = 11; break;
2790#ifdef UDF_HDD_SUPPORT
2791 case 512: Vcb->BlockSizeBits = 9; break;
2792 case 1024: Vcb->BlockSizeBits = 10; break;
2793 case 4096: Vcb->BlockSizeBits = 12; break;
2794 case 8192: Vcb->BlockSizeBits = 13; break;
2795#endif //UDF_HDD_SUPPORT
2796 default:
2797 {
2798 UserPrint(("UDF: Bad block size (%ld)\n", Vcb->BlockSize));
2800 }
2801 }
2802
2803#ifdef UDF_HDD_SUPPORT
2804 if(
2805#ifdef _BROWSE_UDF_
2807 ||
2808#endif //_BROWSE_UDF_
2809#ifdef UDF_FORMAT_MEDIA
2810 (fms && fms->opt_media == MT_HD)
2811 ||
2812#endif //UDF_FORMAT_MEDIA
2813 FALSE ) {
2814
2815#ifdef UDF_FORMAT_MEDIA
2816 if(fms && !NT_SUCCESS(RC))
2818#endif //UDF_FORMAT_MEDIA
2819
2820 Vcb->FirstLBA=0;//(ULONG)(PartitionInfo->StartingOffset.QuadPart >> Vcb->BlockSizeBits);
2821 Vcb->LastPossibleLBA =
2822 Vcb->LastLBA = (uint32)(PartitionInfo->PartitionLength.QuadPart >> Vcb->BlockSizeBits)/* + Vcb->FirstLBA*/ - 1;
2823 } else {
2824#endif //UDF_HDD_SUPPORT
2825 Vcb->FirstLBA=0;
2826 if(OS_SUCCESS(RC)) {
2827 Vcb->LastLBA = (uint32)(DiskGeometry->Cylinders.QuadPart *
2828 DiskGeometry->TracksPerCylinder *
2829 DiskGeometry->SectorsPerTrack - 1);
2830 if(Vcb->LastLBA == 0x7fffffff) {
2832 }
2833 } else {
2835 }
2836 Vcb->LastPossibleLBA = Vcb->LastLBA;
2837#ifdef UDF_HDD_SUPPORT
2838 }
2839#endif //UDF_HDD_SUPPORT
2840
2841#ifdef _BROWSE_UDF_
2842// if(UDFGetDevType(DeviceObject) == FILE_DEVICE_DISK) {
2843 Vcb->WriteBlockSize = PACKETSIZE_UDF*Vcb->BlockSize;
2844// } else {
2845// Vcb->WriteBlockSize = PACKETSIZE_UDF*Vcb->BlockSize;
2846// }
2847#else //_BROWSE_UDF_
2848 if(fms->opt_media == MT_HD) {
2849 Vcb->WriteBlockSize = Vcb->BlockSize;
2850 } else {
2851 Vcb->WriteBlockSize = PACKETSIZE_UDF*Vcb->BlockSize;
2852 }
2853#endif //_BROWSE_UDF_
2854
2855 RC = STATUS_SUCCESS;
2856
2857try_exit: NOTHING;
2858
2859 UDFPrint(("UDFGetBlockSize:\nBlock size is %x, Block size bits %x, Last LBA is %x\n",
2860 Vcb->BlockSize, Vcb->BlockSizeBits, Vcb->LastLBA));
2861
2863 MyFreePool__(DiskGeometry);
2864 return RC;
2865
2866} // end UDFGetBlockSize()
unsigned int uint32
Definition: types.h:32
#define PARTITION_IFS
Definition: disk.h:93
#define try_return(S)
Definition: cdprocs.h:2179
#define DEFAULT_LAST_LBA_FP_CD
Definition: cdrw_usr.h:1820
#define PACKETSIZE_UDF
Definition: cdrw_usr.h:1753
#define IOCTL_DISK_GET_DRIVE_GEOMETRY
Definition: cdrw_usr.h:169
#define DEFAULT_LAST_LBA_DVD
Definition: cdrw_usr.h:1821
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetFilePointer
Definition: compat.h:743
#define UDFGetDevType(DevObj)
Definition: env_spec.h:148
#define UserPrint(x)
Definition: env_spec_w32.h:202
#define NOTHING
Definition: input_list.c:10
#define MyFreePool__(addr)
Definition: mem_tools.h:152
#define IOCTL_CDROM_GET_DRIVE_GEOMETRY
Definition: ntddcdrm.h:73
#define IOCTL_DISK_GET_PARTITION_INFO
Definition: ntdddisk.h:106
struct _PARTITION_INFORMATION * PPARTITION_INFORMATION
struct _DISK_GEOMETRY * PDISK_GEOMETRY
long LONG
Definition: pedump.c:60
#define fms
#define FILE_DEVICE_DISK
Definition: winioctl.h:113
#define STATUS_DEVICE_NOT_READY
Definition: shellext.h:70
#define STATUS_SUCCESS
Definition: shellext.h:65
#define _BROWSE_UDF_
Definition: struct.h:330
LARGE_INTEGER Cylinders
Definition: ntdddisk.h:405
ULONG TracksPerCylinder
Definition: ntdddisk.h:407
ULONG SectorsPerTrack
Definition: ntdddisk.h:408
ULONG BytesPerSector
Definition: ntdddisk.h:409
#define UDFIsDvdMedia(Vcb)
Definition: udf_common.h:524
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_UNRECOGNIZED_VOLUME
Definition: udferr_usr.h:173
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define UDF_HDD_SUPPORT
Definition: udffs.h:45
LONGLONG QuadPart
Definition: typedefs.h:114
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FILE_END
Definition: winbase.h:114
_In_ ULONG _In_ struct _SET_PARTITION_INFORMATION_EX * PartitionInfo
Definition: iofuncs.h:2105

Referenced by UDFGetDiskInfo().

◆ UDFGetDiskInfo()

OSSTATUS UDFGetDiskInfo ( IN PDEVICE_OBJECT  DeviceObject,
IN PVCB  Vcb 
)

Definition at line 3050 of file phys_lib.cpp.

3054{
3056 int8* ioBuf = (int8*)MyAllocatePool__(NonPagedPool,4096);
3057 uint8 MediaType;
3058 PLUN_WRITE_PERF_DESC_USER WPerfDesc;
3059 uint32 i;
3060// BOOLEAN MRW_problem = FALSE;
3061 uint32 SavedFeatures = 0;
3062#ifdef UDF_FORMAT_MEDIA
3063 PUDFFmtState fms = Vcb->fms;
3064#else
3065 #define fms FALSE
3066#endif //UDF_FORMAT_MEDIA
3067
3068 UDFPrint(("UDFGetDiskInfo\n"));
3069
3070 if(!ioBuf) {
3072 }
3073
3074 _SEH2_TRY {
3076 if(!OS_SUCCESS(RC)) try_return(RC);
3077
3078
3079 // Get lower driver signature
3081 ioBuf,sizeof(GET_SIGNATURE_USER_OUT),
3082 ioBuf,sizeof(GET_SIGNATURE_USER_OUT),
3083 TRUE,NULL);
3084
3085 if(!OS_SUCCESS(RC)) {
3086
3088#ifdef _BROWSE_UDF_
3089 if(!NT_SUCCESS(RC) || fms)
3090 try_return(RC);
3091
3092 // assume Device Recordable for now
3093 goto GetSignatureFailed;
3094#endif //_BROWSE_UDF_
3095 }
3096
3097 UDFPrint(("UDF: Signature of low driver is : %s \n",
3098 ((PGET_SIGNATURE_USER_OUT)(ioBuf))->VendorId));
3099
3100 if(!strncmp( (const char *)(&( ((PGET_SIGNATURE_USER_OUT)(ioBuf))->VendorId[0]) ),
3102 UDFPrint(("UDF: *****************************************\n"));
3103 UDFPrint(("UDF: ********* Our Device Driver Found ******\n"));
3104 UDFPrint(("UDF: *****************************************\n"));
3105
3106 (Vcb->VCBFlags) |= UDF_VCB_FLAGS_OUR_DEVICE_DRIVER;
3107#ifndef _BROWSE_UDF_
3108 // reset driver
3109#ifdef UDF_FORMAT_MEDIA
3110 if(!fms->opt_probe) {
3111#endif //UDF_FORMAT_MEDIA
3112 UDFResetDeviceDriver(Vcb, Vcb->TargetDeviceObject, FALSE);
3113 // lock it
3114 ((PPREVENT_MEDIA_REMOVAL_USER_IN)(ioBuf))->PreventMediaRemoval = TRUE;
3117 ioBuf,sizeof(PREVENT_MEDIA_REMOVAL_USER_IN),
3118 NULL,0,
3119 FALSE, NULL);
3120#ifdef UDF_FORMAT_MEDIA
3121 }
3122#endif //UDF_FORMAT_MEDIA
3123#endif //_BROWSE_UDF_
3124//#else //_BROWSE_UDF_
3125 // get device features
3128 NULL,0,
3129 ioBuf,sizeof(GET_DEVICE_INFO_USER_OUT),
3130 FALSE,NULL);
3131
3132 Vcb->SavedFeatures =
3133 SavedFeatures = ((PGET_DEVICE_INFO_USER_OUT)ioBuf)->Features;
3134 if(!(SavedFeatures & CDRW_FEATURE_SYNC_ON_WRITE)) {
3135 UDFPrint(("UDFGetDiskInfo: UDF_VCB_IC_NO_SYNCCACHE_AFTER_WRITE\n"));
3137 }
3138 if(!(SavedFeatures & CDRW_FEATURE_FORCE_SYNC_BEFORE_READ)) {
3139 UDFPrint(("UDFGetDiskInfo: UDF_VCB_IC_SYNCCACHE_BEFORE_READ\n"));
3140 Vcb->CompatFlags |= UDF_VCB_IC_SYNCCACHE_BEFORE_READ;
3141 }
3142 if(SavedFeatures & CDRW_FEATURE_BAD_RW_SEEK) {
3143 UDFPrint(("UDFGetDiskInfo: CDRW_FEATURE_BAD_RW_SEEK\n"));
3144 Vcb->CompatFlags |= UDF_VCB_IC_BAD_RW_SEEK;
3145 }
3146 // we must check if this is FP-formatted disk in old devices
3147 // independently of MediaType they report
3148 if(SavedFeatures & CDRW_FEATURE_FP_ADDRESSING_PROBLEM) {
3149 UDFPrint(("UDFGetDiskInfo: CDRW_FEATURE_FP_ADDRESSING_PROBLEM ?\n"));
3150 Vcb->CompatFlags |= UDF_VCB_IC_FP_ADDR_PROBLEM;
3151 }
3152 if(SavedFeatures & CDRW_FEATURE_MRW_ADDRESSING_PROBLEM) {
3153 UDFPrint(("UDFGetDiskInfo: CDRW_FEATURE_MRW_ADDRESSING_PROBLEM ?\n"));
3154 }
3155 if(SavedFeatures & CDRW_FEATURE_FORCE_SYNC_ON_WRITE) {
3156 UDFPrint(("UDFGetDiskInfo: CDRW_FEATURE_FORCE_SYNC_ON_WRITE\n"));
3158 }
3159 if(SavedFeatures & CDRW_FEATURE_BAD_DVD_LAST_LBA) {
3160 UDFPrint(("UDFGetDiskInfo: CDRW_FEATURE_BAD_DVD_LAST_LBA\n"));
3161 Vcb->CompatFlags |= UDF_VCB_IC_BAD_DVD_LAST_LBA;
3162 }
3163 if(SavedFeatures & CDRW_FEATURE_STREAMING) {
3164 UDFPrint(("UDFGetDiskInfo: CDRW_FEATURE_STREAMING\n"));
3165 }
3166 if(SavedFeatures & CDRW_FEATURE_OPC) {
3167 UDFPrint(("UDFGetDiskInfo: CDRW_FEATURE_OPC -> assume OPCNum=1\n"));
3168 Vcb->OPCNum = 1;
3169 }
3170#ifdef UDF_FORMAT_MEDIA
3171 if(SavedFeatures & CDRW_FEATURE_FULL_BLANK_ON_FORMAT) {
3172 UDFPrint(("UDFGetDiskInfo: CDRW_FEATURE_FULL_BLANK_ON_FORMAT\n"));
3173 if((fms->opt_probe || fms->opt_smart_f)/* &&
3174 (fms->format_media && fms->blank_media*/) {
3175 UDFPrint(("UDFGetDiskInfo: force Full Erase\n"));
3176 fms->opt_qblank = FALSE;
3177 }
3178 }
3179#endif //UDF_FORMAT_MEDIA
3180#ifdef _BROWSE_UDF_
3181 // get device buffer size
3184 NULL,0,
3185 ioBuf,sizeof(BUFFER_CAPACITY_BLOCK_USER_OUT),
3186 FALSE,NULL);
3187 if(NT_SUCCESS(RC)) {
3188 Vcb->CdrwBufferSize = ((PBUFFER_CAPACITY_BLOCK_USER_OUT)ioBuf)->BufferLength;
3189 } else {
3190 Vcb->CdrwBufferSize = 0;
3191 }
3192 UDFPrint(("UDFGetDiskInfo: CdrwBufferSize = %dKb\n", Vcb->CdrwBufferSize / 1024));
3193 Vcb->CdrwBufferSizeCounter = 0;
3194#endif //_BROWSE_UDF_
3195 // get media type
3197 NULL,0,ioBuf,sizeof(GET_MEDIA_TYPE_USER_OUT),
3198 FALSE, NULL);
3199 if(!OS_SUCCESS(RC)) goto Try_FullToc;
3200 Vcb->MediaType =
3201 MediaType = ((PGET_MEDIA_TYPE_USER_OUT)ioBuf)->MediaType;
3202 UDFPrint(("UDFGetDiskInfo: MediaType %x\n", MediaType));
3203
3204#ifndef UDF_FORMAT_MEDIA
3205 // we shall ignore audio-disks
3206 switch(MediaType) {
3213// case :
3214 UDFPrint(("UDFGetDiskInfo: we shall ignore audio-disks...\n"));
3216 }
3217#endif //UDF_FORMAT_MEDIA
3218
3219 UDFPrint(("UDFGetDiskInfo: Check DVD-disks...\n"));
3221 NULL,0,ioBuf,sizeof(GET_MEDIA_TYPE_EX_USER_OUT),
3222 FALSE, NULL);
3223 if(!OS_SUCCESS(RC)) goto Try_FullToc;
3224 Vcb->MediaClassEx =
3225 MediaType = (((PGET_MEDIA_TYPE_EX_USER_OUT)ioBuf)->MediaClass);
3226 UDFPrint(("UDFGetDiskInfo: MediaClassEx %x\n", MediaType));
3227
3228#ifdef _BROWSE_UDF_
3229 if(!fms) {
3230
3231 switch(MediaType) {
3232
3233 case CdMediaClass_CDR:
3234 case CdMediaClass_DVDR:
3235 case CdMediaClass_DVDpR:
3237 case CdMediaClass_BDR:
3238 UDFPrint(("UDFGetDiskInfo: MediaClass R\n"));
3239 Vcb->MediaType = MediaType_UnknownSize_CDR;
3240 break;
3241 case CdMediaClass_CDRW:
3242
3243 if(SavedFeatures & CDRW_FEATURE_MRW_ADDRESSING_PROBLEM) {
3244 UDFPrint(("UDFGetDiskInfo: CDRW_FEATURE_MRW_ADDRESSING_PROBLEM on CD-RW\n"));
3245 Vcb->CompatFlags |= UDF_VCB_IC_MRW_ADDR_PROBLEM;
3246 }
3247
3248 case CdMediaClass_DVDRW:
3253 case CdMediaClass_BDRE:
3254 UDFPrint(("UDFGetDiskInfo: MediaClass RW\n"));
3255 Vcb->MediaType = MediaType_UnknownSize_CDRW;
3256 break;
3257 case CdMediaClass_CDROM:
3260 case CdMediaClass_BDROM:
3261 UDFPrint(("UDFGetDiskInfo: MediaClass ROM\n"));
3262 Vcb->MediaType = MediaType_Unknown;
3263 // Vcb->MediaType = MediaType_UnknownSize_CDROM;
3264 break;
3265 default:
3266 UDFPrint(("UDFGetDiskInfo: MediaClass Unknown\n"));
3267 Vcb->MediaType = MediaType_Unknown;
3268 break;
3269 }
3270 MediaType = Vcb->MediaType;
3271
3272 }
3273#endif //_BROWSE_UDF_
3274
3275#ifdef UDF_FORMAT_MEDIA
3276
3277 if(fms) {
3278
3279 switch(MediaType) {
3280 case CdMediaClass_CDR:
3281 UDFPrint(("CdMediaClass_CDR\n"));
3282 MediaType = MediaType_UnknownSize_CDR;
3283 if(fms->opt_media == MT_AUTO)
3284 fms->opt_media = MT_CDR;
3285 break;
3286 case CdMediaClass_DVDR:
3287 UDFPrint(("CdMediaClass_DVDR -> MediaType_UnknownSize_CDR\n"));
3288 MediaType = MediaType_UnknownSize_CDR;
3289 if(fms->opt_media == MT_AUTO)
3290 fms->opt_media = MT_DVDR;
3291 break;
3292 case CdMediaClass_DVDpR:
3293 UDFPrint(("CdMediaClass_DVDpR -> MediaType_UnknownSize_CDR\n"));
3294 MediaType = MediaType_UnknownSize_CDR;
3295 if(fms->opt_media == MT_AUTO)
3296 fms->opt_media = MT_DVDpR;
3297 break;
3299 UDFPrint(("CdMediaClass_HD_DVDR -> MediaType_UnknownSize_CDR\n"));
3300 MediaType = MediaType_UnknownSize_CDR;
3301 if(fms->opt_media == MT_AUTO)
3302 fms->opt_media = MT_DVDR;
3303 break;
3304 case CdMediaClass_BDR:
3305 UDFPrint(("CdMediaClass_BDR -> MediaType_UnknownSize_CDR\n"));
3306 MediaType = MediaType_UnknownSize_CDR;
3307 if(fms->opt_media == MT_AUTO)
3308 fms->opt_media = MT_DVDR;
3309 break;
3310 case CdMediaClass_CDRW:
3311 UDFPrint(("CdMediaClass_CDRW\n"));
3312 MediaType = MediaType_UnknownSize_CDRW;
3313 if(fms->opt_media == MT_AUTO)
3314 fms->opt_media = MT_CDRW;
3315 if(SavedFeatures & CDRW_FEATURE_MRW_ADDRESSING_PROBLEM) {
3316 UDFPrint(("UDFGetDiskInfo: CDRW_FEATURE_MRW_ADDRESSING_PROBLEM on CD-RW\n"));
3317 Vcb->CompatFlags |= UDF_VCB_IC_MRW_ADDR_PROBLEM;
3318 }
3319 break;
3320 case CdMediaClass_DVDRW:
3321 UDFPrint((" CdMediaClass_DVDRW -> MediaType_UnknownSize_CDRW\n"));
3322 if(fms->opt_media == MT_AUTO)
3323 fms->opt_media = MT_DVDRW;
3324 MediaType = MediaType_UnknownSize_CDRW;
3325 break;
3327 UDFPrint((" CdMediaClass_DVDpRW -> MediaType_UnknownSize_CDRW\n"));
3328 if(fms->opt_media == MT_AUTO)
3329 fms->opt_media = MT_DVDpRW;
3330 MediaType = MediaType_UnknownSize_CDRW;
3331 break;
3333 UDFPrint((" CdMediaClass_DVDRAM -> MediaType_UnknownSize_CDRW\n"));
3334 if(fms->opt_media == MT_AUTO)
3335 fms->opt_media = MT_DVDRAM;
3336 MediaType = MediaType_UnknownSize_CDRW;
3337 break;
3339 UDFPrint((" CdMediaClass_HD_DVDRW -> MediaType_UnknownSize_CDRW\n"));
3340 if(fms->opt_media == MT_AUTO)
3341 fms->opt_media = MT_DVDRW;
3342 MediaType = MediaType_UnknownSize_CDRW;
3343 break;
3345 UDFPrint((" CdMediaClass_HD_DVDRAM -> MediaType_UnknownSize_CDRW\n"));
3346 if(fms->opt_media == MT_AUTO)
3347 fms->opt_media = MT_DVDRAM;
3348 MediaType = MediaType_UnknownSize_CDRW;
3349 break;
3350 case CdMediaClass_BDRE:
3351 UDFPrint((" CdMediaClass_BDRE -> MediaType_UnknownSize_CDRW\n"));
3352 if(fms->opt_media == MT_AUTO)
3353 fms->opt_media = MT_DVDRW;
3354 MediaType = MediaType_UnknownSize_CDRW;
3355 break;
3357 UDFPrint((" CdMediaClass_NoDiscPresent -> MediaType_NoDiscPresent\n"));
3358 MediaType = MediaType_NoDiscPresent;
3359 fms->opt_media = MT_none;
3360 break;
3362 UDFPrint((" CdMediaClass_DoorOpen -> MediaType_DoorOpen\n"));
3363 MediaType = MediaType_DoorOpen;
3364 fms->opt_media = MT_none;
3365 break;
3366 default:
3367 UDFPrint((" MediaType_Unknown\n"));
3368 MediaType = MediaType_Unknown;
3369 break;
3370 }
3371 if(!apply_force_r(fms)) {
3373 }
3374 }
3375
3376#endif //UDF_FORMAT_MEDIA
3377
3378 Vcb->DVD_Mode = (((PGET_MEDIA_TYPE_EX_USER_OUT)ioBuf)->MediaClassEx == CdMediaClassEx_DVD);
3379 Vcb->PhMediaCapFlags = ((PGET_MEDIA_TYPE_EX_USER_OUT)ioBuf)->CapFlags;
3380 Vcb->WriteParamsReq = (Vcb->PhMediaCapFlags & CdCapFlags_WriteParamsReq) ? TRUE : FALSE;
3381 if(Vcb->DVD_Mode &&
3382 !(Vcb->PhMediaCapFlags & CdCapFlags_RandomWritable)) {
3383 UDFPrint(("UDFGetDiskInfo: DVD && !CdCapFlags_RandomWritable\n"));
3384 UDFPrint((" Read-only volume\n"));
3385// BrutePoint();
3386#ifndef UDF_CDRW_EMULATION_ON_ROM
3388#endif
3389 }
3390#ifdef UDF_FORMAT_MEDIA
3391 if(fms) {
3392 if((MediaType == MediaType_NoDiscPresent) ||
3393 (MediaType == MediaType_DoorOpen)) {
3394 UserPrint(("No media in device\n"));
3396 }
3397 }
3398#endif //UDF_FORMAT_MEDIA
3399 if(!Vcb->WriteParamsReq) {
3400 UDFPrint(("UDFGetDiskInfo: do not use WriteParams\n"));
3401 }
3402 if(Vcb->PhMediaCapFlags & CdCapFlags_Cav) {
3403 UDFPrint(("UDFGetDiskInfo: Use CAV (1)\n"));
3404 Vcb->VCBFlags |= UDF_VCB_FLAGS_USE_CAV;
3405 }
3406
3407#ifdef _BROWSE_UDF_
3408 if(!fms) {
3409 // check if this device is capable to write on such media
3410 if(UDFIsDvdMedia(Vcb)) {
3411 //RC =
3412 UDFPrint(("UDFGetDiskInfo: update defaulted LastLBA\n"));
3414 //if(!OS_SUCCESS(RC)) goto Try_FullToc;
3415 } else {
3416 if((SavedFeatures & CDRW_FEATURE_MRW_ADDRESSING_PROBLEM) &&
3417 (SavedFeatures & UDF_VCB_IC_FP_ADDR_PROBLEM)) {
3418 UDFPrint(("UDFGetDiskInfo: CDRW_FEATURE_MRW_ADDRESSING_PROBLEM on old CD-ROM\n"));
3419 Vcb->CompatFlags |= UDF_VCB_IC_MRW_ADDR_PROBLEM;
3420 }
3421 }
3422 }
3423#endif //_BROWSE_UDF_
3424
3425/*#ifdef UDF_FORMAT_MEDIA
3426 if(fms) {
3427 if(MediaType == CdMediaClass_DVDRW) {
3428 UserPrint(("Not empty media. Erase required.\n"));
3429 my_exit(fms, MKUDF_BLANK_FORMAT_REQUIRED);
3430 }
3431 }
3432#endif //UDF_FORMAT_MEDIA*/
3433
3434#define cap ((PGET_CAPABILITIES_3_USER_OUT)ioBuf)
3435 // get device capabilities
3437 NULL,0,ioBuf,sizeof(GET_CAPABILITIES_3_USER_OUT),
3438 FALSE, NULL);
3439 if(!OS_SUCCESS(RC)) goto Try_FullToc;
3440
3441 // check if this device is capable to write on such media
3443 NULL,0,NULL,0,FALSE, NULL);
3444 if(RC != STATUS_SUCCESS) {
3445 UDFPrint(("IS_WRITABLE - false, doing additional check...\n"));
3446 if( ((MediaType >= MediaType_UnknownSize_CDRW) && !(cap->WriteCap & DevCap_write_cd_rw)) ||
3447 ((MediaType >= MediaType_UnknownSize_CDR) && !(cap->WriteCap & DevCap_write_cd_r)) ||
3448 (MediaType < MediaType_UnknownSize_CDR) ) {
3449 UserPrint(("Hardware Read-only volume\n"));
3450#ifndef UDF_CDRW_EMULATION_ON_ROM
3452#endif //UDF_CDRW_EMULATION_ON_ROM
3453#ifdef UDF_FORMAT_MEDIA
3454 if(fms && !fms->opt_read_iso)
3455 my_exit(fms, MKUDF_HW_READ_ONLY);
3456#endif //UDF_FORMAT_MEDIA
3457 }
3458 } else {
3459 UDFPrint(("Writable disk\n"));
3460 }
3461 Vcb->MaxWriteSpeed = cap->MaximumWriteSpeedSupported;
3462 Vcb->MaxReadSpeed = cap->MaximumSpeedSupported;
3463 if(cap->PageLength >= (sizeof(GET_CAPABILITIES_3_USER_OUT)-2)) {
3464 Vcb->CurSpeed = max(cap->CurrentSpeed, cap->CurrentWriteSpeed3);
3465 if(cap->LunWPerfDescriptorCount && cap->LunWPerfDescriptorCount != 0xffff) {
3466 ULONG n;
3467 UDFPrint(("Write performance descriptor(s) found: %x\n", cap->LunWPerfDescriptorCount));
3468 n = (4096 - sizeof(GET_CAPABILITIES_3_USER_OUT)) / sizeof(LUN_WRITE_PERF_DESC_USER);
3469 n = min(n, cap->LunWPerfDescriptorCount);
3470 // get device capabilities
3474 TRUE,NULL);
3475 if(OS_SUCCESS(RC)) {
3476 WPerfDesc = (PLUN_WRITE_PERF_DESC_USER)(ioBuf + sizeof(GET_CAPABILITIES_3_USER_OUT));
3477 n = FALSE;
3478 for(i = 0; i<n; i++) {
3479 if((WPerfDesc[i].RotationControl & LunWPerf_RotCtrl_Mask) == LunWPerf_RotCtrl_CAV) {
3480 Vcb->VCBFlags |= UDF_VCB_FLAGS_USE_CAV;
3481 if(!n) {
3482 Vcb->CurSpeed = WPerfDesc[i].WriteSpeedSupported;
3483 n = TRUE;
3484 UDFPrint(("Use CAV\n"));
3485 } else {
3486 Vcb->CurSpeed = max(WPerfDesc[i].WriteSpeedSupported, Vcb->CurSpeed);
3487 }
3488 UDFPrint(("supports speed %dX\n", Vcb->CurSpeed/176));
3489 //break;
3490 }
3491 }
3492 if(n) {
3493 UDFPrint(("Set r/w speeds to %dX\n", Vcb->CurSpeed/176));
3494 Vcb->MaxWriteSpeed =
3495 Vcb->MaxReadSpeed = Vcb->CurSpeed;
3496 }
3497 }
3498 }
3499 } else {
3500 Vcb->CurSpeed = max(cap->CurrentSpeed, cap->CurrentWriteSpeed);
3501 }
3502 UDFPrint((" Speeds r/w %dX/%dX\n", Vcb->CurSpeed/176, cap->CurrentWriteSpeed/176));
3503
3504 if(Vcb->VCBFlags & UDF_VCB_FLAGS_USE_CAV) {
3505 // limit both read & write speed to last write speed for CAV mode
3506 // some drives damage data when speed is adjusted during recording process
3507 // even in packet mode
3509 }
3511
3512#undef cap
3513#ifdef UDF_FORMAT_MEDIA
3514 if(fms) {
3515 if( (fms->auto_media || (fms->opt_media == MT_AUTO)) &&
3516 (fms->opt_media < MT_DVDR) ) {
3517 if(MediaType < MediaType_UnknownSize_CDRW) {
3518 fms->opt_media = MT_CDR;
3519 } else {
3520 fms->opt_media = MT_CDRW;
3521 }
3522 }
3523 if(!apply_force_r(fms)) {
3525 }
3526 }
3527#endif //UDF_FORMAT_MEDIA
3529
3530 if(!OS_SUCCESS(RC)) {
3531 // may be we have a CD-ROM device
3532Try_FullToc:
3533 UDFPrint(("Hardware Read-only volume (2)\n"));
3534// BrutePoint();
3535#ifndef UDF_CDRW_EMULATION_ON_ROM
3537#endif
3538
3540
3541 if(!OS_SUCCESS(RC)) {
3543 if(!OS_SUCCESS(RC)) try_return(RC);
3544 }
3545
3546 }
3547 } else {
3548#ifdef _BROWSE_UDF_
3549GetSignatureFailed:
3550#endif
3552 if(!OS_SUCCESS(RC)) try_return(RC);
3553 }
3554
3555try_exit: NOTHING;
3556
3557 } _SEH2_FINALLY {
3558
3559 if(ioBuf) MyFreePool__(ioBuf);
3560
3561 if(UDFIsDvdMedia(Vcb) &&
3562 (Vcb->CompatFlags & UDF_VCB_IC_BAD_DVD_LAST_LBA) &&
3563 (Vcb->VCBFlags & UDF_VCB_FLAGS_VOLUME_READ_ONLY) &&
3564 Vcb->LastLBA &&
3565 (Vcb->LastLBA < DEFAULT_LAST_LBA_DVD)) {
3566 UDFPrint(("UDF: Bad DVD last LBA %x, fixup!\n", Vcb->LastLBA));
3567 Vcb->LastLBA = DEFAULT_LAST_LBA_DVD;
3568 Vcb->NWA = 0;
3569 }
3570
3571
3572 if(UDFIsDvdMedia(Vcb) && !Vcb->FirstLBA && !Vcb->LastPossibleLBA) {
3573 UDFPrint(("UDF: Empty DVD. Use bogus values for now\n"));
3574 Vcb->LastPossibleLBA = DEFAULT_LAST_LBA_DVD;
3575 Vcb->LastLBA = 0;
3576 }
3577
3578 if((Vcb->LastPossibleLBA & 0x80000000) || (Vcb->LastPossibleLBA < Vcb->LastLBA)) {
3579 UDFPrint(("UDF: bad LastPossibleLBA %x -> %x\n", Vcb->LastPossibleLBA, Vcb->LastLBA));
3580 Vcb->LastPossibleLBA = Vcb->LastLBA;
3581 }
3582 if(!Vcb->WriteBlockSize)
3583 Vcb->WriteBlockSize = PACKETSIZE_UDF*Vcb->BlockSize;
3584
3585#ifdef _BROWSE_UDF_
3586 if(Vcb->TrackMap) {
3587 if(Vcb->TrackMap[Vcb->LastTrackNum].LastLba > Vcb->NWA) {
3588 if(Vcb->NWA) {
3589 if(Vcb->TrackMap[Vcb->LastTrackNum].DataParam & TrkInfo_FP) {
3590 Vcb->LastLBA = Vcb->NWA-1;
3591 } else {
3592 Vcb->LastLBA = Vcb->NWA-7-1;
3593 }
3594 }
3595 } else {
3596 if((Vcb->LastTrackNum > 1) &&
3597 (Vcb->TrackMap[Vcb->LastTrackNum-1].FirstLba >= Vcb->TrackMap[Vcb->LastTrackNum-1].LastLba)) {
3598 Vcb->LastLBA = Vcb->TrackMap[Vcb->LastTrackNum-1].LastLba;
3599 }
3600 }
3601 }
3602
3603 for(i=0; i<32; i++) {
3604 if(!(Vcb->LastPossibleLBA >> i))
3605 break;
3606 }
3607 if(i > 20) {
3608 Vcb->WCacheBlocksPerFrameSh = max(Vcb->WCacheBlocksPerFrameSh, (2*i)/5+2);
3609 Vcb->WCacheBlocksPerFrameSh = min(Vcb->WCacheBlocksPerFrameSh, 16);
3610 }
3611
3612 if(Vcb->CompatFlags & UDF_VCB_IC_FP_ADDR_PROBLEM) {
3613 // Check first 0x200 blocks
3614 UDFCheckTrackFPAddressing(Vcb, Vcb->FirstTrackNum);
3615 // if we really have such a problem, fix LastLBA
3616 if(Vcb->CompatFlags & UDF_VCB_IC_FP_ADDR_PROBLEM) {
3617 UDFPrint(("UDF: Fix LastLBA: %x -> %x\n", Vcb->LastLBA, (Vcb->LastLBA*32) / 39));
3618 Vcb->LastLBA = (Vcb->LastLBA*32) / 39;
3619 }
3620 }
3621#endif //_BROWSE_UDF_
3622
3623 if(Vcb->VCBFlags & UDF_VCB_FLAGS_VOLUME_READ_ONLY) {
3624 if(!Vcb->BlankCD && Vcb->MediaType != MediaType_UnknownSize_CDRW) {
3625 UDFPrint(("UDFGetDiskInfo: R/O+!Blank+!RW -> !RAW\n"));
3626 Vcb->VCBFlags &= ~UDF_VCB_FLAGS_RAW_DISK;
3627 } else {
3628 UDFPrint(("UDFGetDiskInfo: Blank or RW\n"));
3629 }
3630 }
3631
3632 UDFPrint(("UDF: ------------------------------------------\n"));
3633 UDFPrint(("UDF: Media characteristics\n"));
3634 UDFPrint(("UDF: Last session: %d\n",Vcb->LastSession));
3635 UDFPrint(("UDF: First track in first session: %d\n",Vcb->FirstTrackNum));
3636 UDFPrint(("UDF: First track in last session: %d\n",Vcb->FirstTrackNumLastSes));
3637 UDFPrint(("UDF: Last track in last session: %d\n",Vcb->LastTrackNum));
3638 UDFPrint(("UDF: First LBA in first session: %x\n",Vcb->FirstLBA));
3639 UDFPrint(("UDF: First LBA in last session: %x\n",Vcb->FirstLBALastSes));
3640 UDFPrint(("UDF: Last LBA in last session: %x\n",Vcb->LastLBA));
3641 UDFPrint(("UDF: First writable LBA (NWA) in last session: %x\n",Vcb->NWA));
3642 UDFPrint(("UDF: Last available LBA beyond end of last session: %x\n",Vcb->LastPossibleLBA));
3643 UDFPrint(("UDF: blocks per frame: %x\n",1 << Vcb->WCacheBlocksPerFrameSh));
3644 UDFPrint(("UDF: Flags: %s%s\n",
3645 Vcb->VCBFlags & UDF_VCB_FLAGS_RAW_DISK ? "RAW " : "",
3646 Vcb->VCBFlags & UDF_VCB_FLAGS_VOLUME_READ_ONLY ? "R/O " : "WR "
3647 ));
3648 UDFPrint(("UDF: ------------------------------------------\n"));
3649
3650#ifdef UDF_FORMAT_MEDIA
3651 if(fms && fms->opt_disk_info) {
3652 UserPrint(("------------------------------------------\n"));
3653 UserPrint(("Media characteristics:\n"));
3654 UserPrint((" First writable LBA (NWA) in last session: %x\n",Vcb->NWA));
3655 UserPrint((" Last available LBA beyond end of last session: %x\n",Vcb->LastPossibleLBA));
3656 UserPrint(("------------------------------------------\n"));
3657 }
3658#endif //UDF_FORMAT_MEDIA
3659
3660 } _SEH2_END;
3661
3662 UDFPrint(("UDFGetDiskInfo: %x\n", RC));
3663 return(RC);
3664
3665} // end UDFGetDiskInfo()
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
unsigned char uint8
Definition: types.h:28
#define DevCap_write_cd_rw
Definition: cdrw_hw.h:3014
#define TrkInfo_FP
Definition: cdrw_hw.h:2417
#define MediaType_Unknown
Definition: cdrw_hw.h:2465
#define MediaType_DoorOpen
Definition: cdrw_hw.h:2500
#define MediaType_UnknownSize_CDR
Definition: cdrw_hw.h:2475
#define MediaType_UnknownSize_CDRW
Definition: cdrw_hw.h:2485
#define MediaType_120mm_CDRW_AudioOnly
Definition: cdrw_hw.h:2487
#define MediaType_120mm_CDROM_AudioOnly
Definition: cdrw_hw.h:2467
#define DevCap_write_cd_r
Definition: cdrw_hw.h:3013
#define MediaType_80mm_CDRW_AudioOnly
Definition: cdrw_hw.h:2491
#define LunWPerf_RotCtrl_CAV
Definition: cdrw_hw.h:3142
#define MediaType_NoDiscPresent
Definition: cdrw_hw.h:2499
#define MediaType_80mm_CDROM_AudioOnly
Definition: cdrw_hw.h:2471
#define MediaType_120mm_CDR_AudioOnly
Definition: cdrw_hw.h:2477
#define LunWPerf_RotCtrl_Mask
Definition: cdrw_hw.h:3140
#define MediaType_80mm_CDR_AudioOnly
Definition: cdrw_hw.h:2481
#define CdMediaClass_CDR
Definition: cdrw_usr.h:744
#define IOCTL_CDRW_BUFFER_CAPACITY
Definition: cdrw_usr.h:94
#define CdMediaClass_DVDR
Definition: cdrw_usr.h:748
#define IOCTL_CDRW_GET_MEDIA_TYPE
Definition: cdrw_usr.h:84
#define CdMediaClass_DoorOpen
Definition: cdrw_usr.h:763
#define CDRW_FEATURE_BAD_RW_SEEK
Definition: cdrw_usr.h:1485
#define CdMediaClass_DVDRW
Definition: cdrw_usr.h:749
struct _GET_MEDIA_TYPE_USER_OUT * PGET_MEDIA_TYPE_USER_OUT
struct _PREVENT_MEDIA_REMOVAL_USER_IN * PPREVENT_MEDIA_REMOVAL_USER_IN
#define CdMediaClass_CDROM
Definition: cdrw_usr.h:743
struct _GET_CAPABILITIES_3_USER_OUT GET_CAPABILITIES_3_USER_OUT
#define CdMediaClass_HD_DVDRW
Definition: cdrw_usr.h:761
#define CDRW_FEATURE_BAD_DVD_LAST_LBA
Definition: cdrw_usr.h:1492
#define CDRW_FEATURE_MRW_ADDRESSING_PROBLEM
Definition: cdrw_usr.h:1490
#define CdMediaClass_CDRW
Definition: cdrw_usr.h:745
#define CDRW_FEATURE_FORCE_SYNC_ON_WRITE
Definition: cdrw_usr.h:1491
#define CDRW_FEATURE_FULL_BLANK_ON_FORMAT
Definition: cdrw_usr.h:1493
#define CDRW_FEATURE_FORCE_SYNC_BEFORE_READ
Definition: cdrw_usr.h:1495
#define CdMediaClass_BDRE
Definition: cdrw_usr.h:756
struct _LUN_WRITE_PERF_DESC_USER * PLUN_WRITE_PERF_DESC_USER
#define CdMediaClass_BDROM
Definition: cdrw_usr.h:755
#define CdCapFlags_RandomWritable
Definition: cdrw_usr.h:796
struct _GET_DEVICE_INFO_USER_OUT * PGET_DEVICE_INFO_USER_OUT
#define CdMediaClass_HD_DVDROM
Definition: cdrw_usr.h:758
struct _LUN_WRITE_PERF_DESC_USER LUN_WRITE_PERF_DESC_USER
#define CDRW_FEATURE_STREAMING
Definition: cdrw_usr.h:1494
#define CDRW_FEATURE_FP_ADDRESSING_PROBLEM
Definition: cdrw_usr.h:1489
#define CdMediaClass_HD_DVDRAM
Definition: cdrw_usr.h:759
#define IOCTL_CDRW_GET_SIGNATURE
Definition: cdrw_usr.h:95
#define IOCTL_DISK_IS_WRITABLE
Definition: cdrw_usr.h:172
#define IOCTL_CDRW_GET_DEVICE_INFO
Definition: cdrw_usr.h:119
#define CdMediaClass_DVDRAM
Definition: cdrw_usr.h:747
#define CdMediaClass_HD_DVDR
Definition: cdrw_usr.h:760
#define CdMediaClass_NoDiscPresent
Definition: cdrw_usr.h:762
#define CdMediaClass_DVDROM
Definition: cdrw_usr.h:746
struct _GET_MEDIA_TYPE_EX_USER_OUT * PGET_MEDIA_TYPE_EX_USER_OUT
#define CdMediaClass_DVDpR
Definition: cdrw_usr.h:750
#define CdCapFlags_WriteParamsReq
Definition: cdrw_usr.h:795
#define CDRW_FEATURE_OPC
Definition: cdrw_usr.h:1480
struct _BUFFER_CAPACITY_BLOCK_USER_OUT * PBUFFER_CAPACITY_BLOCK_USER_OUT
#define CDRW_FEATURE_SYNC_ON_WRITE
Definition: cdrw_usr.h:1484
#define CdCapFlags_Cav
Definition: cdrw_usr.h:797
#define IOCTL_CDRW_GET_MEDIA_TYPE_EX
Definition: cdrw_usr.h:123
#define CdMediaClass_DVDpRW
Definition: cdrw_usr.h:751
#define CdMediaClassEx_DVD
Definition: cdrw_usr.h:780
#define CdMediaClass_BDR
Definition: cdrw_usr.h:757
#define IOCTL_CDRW_GET_CAPABILITIES
Definition: cdrw_usr.h:82
char int8
Definition: platform.h:10
void my_exit(int rc)
#define _SEH2_FINALLY
Definition: filesup.c:21
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
GLdouble n
Definition: glext.h:7729
GLenum cap
Definition: glext.h:9639
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 min(a, b)
Definition: monoChain.cc:55
#define IOCTL_STORAGE_MEDIA_REMOVAL
Definition: ntddstor.h:104
NTSTATUS UDFSetCaching(IN PVCB Vcb)
Definition: phys_lib.cpp:4263
static const char Signature[16]
Definition: phys_lib.cpp:18
OSSTATUS UDFSetSpeeds(IN PVCB Vcb)
Definition: phys_lib.cpp:4234
OSSTATUS UDFReadAndProcessFullToc(PDEVICE_OBJECT DeviceObject, PVCB Vcb)
Definition: phys_lib.cpp:2243
OSSTATUS UDFUseStandard(PDEVICE_OBJECT DeviceObject, PVCB Vcb)
Definition: phys_lib.cpp:2386
OSSTATUS UDFReadDiscTrackInfo(PDEVICE_OBJECT DeviceObject, PVCB Vcb)
Definition: phys_lib.cpp:1635
OSSTATUS UDFResetDeviceDriver(IN PVCB Vcb, IN PDEVICE_OBJECT TargetDeviceObject, IN BOOLEAN Unlock)
Definition: phys_lib.cpp:4199
OSSTATUS UDFGetBlockSize(IN PDEVICE_OBJECT DeviceObject, IN PVCB Vcb)
Definition: phys_lib.cpp:2687
#define max(a, b)
Definition: svc.c:63
uint32_t ULONG
Definition: typedefs.h:59
#define UDF_VCB_IC_SYNCCACHE_BEFORE_READ
Definition: udf_common.h:512
#define UDF_VCB_FLAGS_USE_CAV
Definition: udf_common.h:487
#define UDF_VCB_FLAGS_VOLUME_READ_ONLY
Definition: udf_common.h:463
#define UDF_VCB_FLAGS_RAW_DISK
Definition: udf_common.h:476
#define UDF_VCB_IC_NO_SYNCCACHE_AFTER_WRITE
Definition: udf_common.h:507
#define UDF_VCB_FLAGS_FORCE_SYNC_CACHE
Definition: udf_common.h:485
#define UDF_VCB_IC_MRW_ADDR_PROBLEM
Definition: udf_common.h:510
#define UDF_VCB_FLAGS_OUR_DEVICE_DRIVER
Definition: udf_common.h:466
#define UDF_VCB_IC_BAD_DVD_LAST_LBA
Definition: udf_common.h:511
#define UDF_VCB_IC_FP_ADDR_PROBLEM
Definition: udf_common.h:509
#define UDF_VCB_IC_BAD_RW_SEEK
Definition: udf_common.h:508
#define MKUDF_CANT_APPLY_R
Definition: udferr_usr.h:79
#define MKUDF_NO_MEDIA_IN_DEVICE
Definition: udferr_usr.h:56

Referenced by UDFMountVolume(), and UDFVerifyVolume().

◆ UDFPrepareForReadOperation()

OSSTATUS UDFPrepareForReadOperation ( IN PVCB  Vcb,
IN uint32  Lba,
IN uint32  BCount 
)

Definition at line 3670 of file phys_lib.cpp.

3675{
3676 if( (Vcb->FsDeviceType != FILE_DEVICE_CD_ROM_FILE_SYSTEM) ) {
3677 Vcb->VCBFlags &= ~UDF_VCB_LAST_WRITE;
3678 return STATUS_SUCCESS;
3679 }
3680 uint32 i = Vcb->LastReadTrack;
3681 BOOLEAN speed_changed = FALSE;
3682#ifdef _BROWSE_UDF_
3683 PUCHAR tmp;
3684 OSSTATUS RC;
3686#endif //_BROWSE_UDF_
3687
3688#ifdef _UDF_STRUCTURES_H_
3689 if(Vcb->BSBM_Bitmap) {
3690 ULONG i;
3691 for(i=0; i<BCount; i++) {
3692 if(UDFGetBit((uint32*)(Vcb->BSBM_Bitmap), Lba+i)) {
3693 UDFPrint(("R: Known BB @ %#x\n", Lba));
3694 //return STATUS_FT_WRITE_RECOVERY; // this shall not be treated as error and
3695 // we shall get IO request to BAD block
3697 }
3698 }
3699 }
3700#endif //_UDF_STRUCTURES_H_
3701
3702 if(!UDFIsDvdMedia(Vcb) &&
3703 (Vcb->VCBFlags & UDF_VCB_LAST_WRITE) &&
3704 !(Vcb->VCBFlags & UDF_VCB_FLAGS_NO_SYNC_CACHE) &&
3705 !(Vcb->CompatFlags & UDF_VCB_IC_NO_SYNCCACHE_AFTER_WRITE)){
3706
3707// OSSTATUS RC;
3708
3709 RC = UDFSyncCache(Vcb);
3710 }
3711 if( (Vcb->VCBFlags & UDF_VCB_LAST_WRITE) &&
3712 !(Vcb->VCBFlags & UDF_VCB_FLAGS_NO_SYNC_CACHE) &&
3713#ifndef UDF_FORMAT_MEDIA
3714 (Vcb->CompatFlags & UDF_VCB_IC_SYNCCACHE_BEFORE_READ) &&
3715#endif //UDF_FORMAT_MEDIA
3716 TRUE)
3717 {
3718// OSSTATUS RC;
3720 }
3721
3722#ifdef _BROWSE_UDF_
3723 if(!UDFIsDvdMedia(Vcb)) {
3724 // limit read speed after write operation
3725 // to avoid performance degrade durring speed-up/down
3726 // on read/write mode switching
3727 if(Vcb->VCBFlags & UDF_VCB_FLAGS_USE_CAV) {
3728 // limit both read & write speed to last write speed for CAV mode
3729 // some drives damage data when speed is adjusted during recording process
3730 // even in packet mode
3731 if(Vcb->CurSpeed != Vcb->MaxWriteSpeed ||
3732 Vcb->CurSpeed != Vcb->MaxReadSpeed) {
3733 Vcb->CurSpeed = Vcb->MaxWriteSpeed;
3734 speed_changed = TRUE;
3735 }
3736 } else
3737 if(Vcb->VCBFlags & UDF_VCB_LAST_WRITE) {
3738 // limit read speed to last write speed
3739 if(Vcb->CurSpeed > Vcb->MaxWriteSpeed) {
3740 Vcb->CurSpeed = Vcb->MaxWriteSpeed;
3741 speed_changed = TRUE;
3742 }
3743 } else
3744 if(Vcb->CurSpeed < Vcb->MaxReadSpeed ) {
3745 // increment read speed (+1X)
3746 Vcb->CurSpeed += 176/1;
3747 speed_changed = TRUE;
3748 }
3749
3750 if(Vcb->CurSpeed > Vcb->MaxReadSpeed) {
3751 Vcb->CurSpeed = Vcb->MaxReadSpeed;
3752 }
3753 // send speed limits to drive
3754 if(speed_changed) {
3755 RtlZeroMemory(&(Vcb->SpeedBuf), sizeof(SET_CD_SPEED_EX_USER_IN));
3756 Vcb->SpeedBuf.ReadSpeed = Vcb->CurSpeed;
3757 Vcb->SpeedBuf.WriteSpeed = Vcb->MaxWriteSpeed;
3758 if(Vcb->VCBFlags & UDF_VCB_FLAGS_USE_CAV) {
3759 Vcb->SpeedBuf.RotCtrl = CdSpeed_RotCtrl_CAV;
3760 }
3761 UDFPrint((" UDFPrepareForReadOperation: set speed to %s %dX/%dX\n",
3762 (Vcb->VCBFlags & UDF_VCB_FLAGS_USE_CAV) ? "CAV" : "CLV",
3763 Vcb->SpeedBuf.ReadSpeed,
3764 Vcb->SpeedBuf.WriteSpeed));
3766 Vcb->TargetDeviceObject,
3767 &(Vcb->SpeedBuf),sizeof(SET_CD_SPEED_EX_USER_IN),
3768 NULL,0,TRUE,NULL);
3769 }
3770 }
3771
3772 if(UDFIsDvdMedia(Vcb))
3773 return STATUS_SUCCESS;
3774
3775 if(Vcb->LastReadTrack &&
3776 ((Vcb->TrackMap[i].FirstLba <= Lba) || (Vcb->TrackMap[i].FirstLba & 0x80000000)) &&
3777 (Vcb->TrackMap[i].LastLba >= Lba)) {
3778check_for_data_track:
3779 // check track mode (Mode1/XA)
3780 switch((Vcb->TrackMap[i].DataParam & TrkInfo_Dat_Mask)) {
3781 case TrkInfo_Dat_Mode1: // Mode1
3782 case TrkInfo_Dat_XA: // XA Mode2
3783 case TrkInfo_Dat_Unknown: // for some stupid irons
3785 break;
3786 default:
3787 Vcb->IncrementalSeekState = INCREMENTAL_SEEK_NONE;
3789 }
3790 } else {
3791 for(i=Vcb->FirstTrackNum; i<=Vcb->LastTrackNum; i++) {
3792 if(((Vcb->TrackMap[i].FirstLba > Lba) && !(Vcb->TrackMap[i].FirstLba & 0x80000000)) ||
3793 (Vcb->TrackMap[i].LastLba < Lba))
3794 continue;
3795 Vcb->LastReadTrack = i;
3796 goto check_for_data_track;
3797 }
3798 Vcb->LastReadTrack = 0;
3799 }
3800 if(Vcb->IncrementalSeekState != INCREMENTAL_SEEK_WORKAROUND) {
3801 Vcb->IncrementalSeekState = INCREMENTAL_SEEK_NONE;
3802 return STATUS_SUCCESS;
3803 }
3804 UDFPrint((" UDFPrepareForReadOperation: seek workaround...\n"));
3805 Vcb->IncrementalSeekState = INCREMENTAL_SEEK_DONE;
3806
3807 tmp = (PUCHAR)DbgAllocatePoolWithTag(NonPagedPool, Vcb->BlockSize, 'bNWD');
3808 if(!tmp) {
3809 Vcb->IncrementalSeekState = INCREMENTAL_SEEK_NONE;
3811 }
3812 for(i=0x1000; i<=Lba; i+=0x1000) {
3813 RC = UDFPhReadSynchronous(Vcb->TargetDeviceObject, tmp, Vcb->BlockSize,
3814 ((uint64)UDFFixFPAddress(Vcb,i)) << Vcb->BlockSizeBits, &ReadBytes, 0);
3815 UDFPrint((" seek workaround, LBA %x, status %x\n", i, RC));
3816 }
3817 DbgFreePool(tmp);
3818#endif //_BROWSE_UDF_
3819
3820 return STATUS_SUCCESS;
3821} // end UDFPrepareForReadOperation()
unsigned char BOOLEAN
#define TrkInfo_Dat_Unknown
Definition: cdrw_hw.h:2416
#define TrkInfo_Dat_XA
Definition: cdrw_hw.h:2413
#define TrkInfo_Dat_Mode1
Definition: cdrw_hw.h:2411
#define CdSpeed_RotCtrl_CAV
Definition: cdrw_hw.h:594
#define TrkInfo_Dat_Mask
Definition: cdrw_hw.h:2410
#define IOCTL_CDRW_SET_SPEED
Definition: cdrw_usr.h:80
unsigned long long uint64
Definition: platform.h:18
static NTSTATUS ReadBytes(IN PDEVICE_OBJECT LowerDevice, OUT PUCHAR Buffer, IN ULONG BufferSize, OUT PULONG_PTR FilledBytes)
Definition: detect.c:67
NTSTATUS NTAPI UDFPhReadSynchronous(PDEVICE_OBJECT DeviceObject, PVOID Buffer, SIZE_T Length, LONGLONG Offset, PSIZE_T ReadBytes, ULONG Flags)
Definition: env_spec.cpp:130
#define DbgAllocatePoolWithTag(a, b, c)
Definition: env_spec_w32.h:333
#define DbgFreePool
Definition: env_spec_w32.h:334
NTSTATUS UDFSetMRWMode(IN PVCB Vcb)
Definition: phys_lib.cpp:811
NTSTATUS UDFSyncCache(IN PVCB Vcb)
Definition: phys_lib.cpp:52
#define FILE_DEVICE_CD_ROM_FILE_SYSTEM
Definition: winioctl.h:109
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
unsigned char * PUCHAR
Definition: typedefs.h:53
#define INCREMENTAL_SEEK_DONE
Definition: udf_common.h:303
#define INCREMENTAL_SEEK_WORKAROUND
Definition: udf_common.h:302
#define UDF_VCB_FLAGS_NO_SYNC_CACHE
Definition: udf_common.h:467
#define UDF_VCB_LAST_WRITE
Definition: udf_common.h:472
#define INCREMENTAL_SEEK_NONE
Definition: udf_common.h:301
#define UDFGetBit(arr, bit)
Definition: udf_info.h:1180
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_DEVICE_DATA_ERROR
Definition: udferr_usr.h:159

Referenced by UDFTRead().

◆ UDFPrepareForWriteOperation()

OSSTATUS UDFPrepareForWriteOperation ( IN PVCB  Vcb,
IN uint32  Lba,
IN uint32  BCount 
)

Definition at line 893 of file phys_lib.cpp.

898{
899#ifndef UDF_READ_ONLY_BUILD
900#ifdef UDF_FORMAT_MEDIA
901 PUDFFmtState fms = Vcb->fms;
902#else
903 #define fms FALSE
904#endif //UDF_FORMAT_MEDIA
905
906#ifdef _UDF_STRUCTURES_H_
907 if(Vcb->BSBM_Bitmap) {
908 ULONG i;
909 for(i=0; i<BCount; i++) {
910 if(UDFGetBit((uint32*)(Vcb->BSBM_Bitmap), Lba+i)) {
911 UDFPrint(("W: Known BB @ %#x\n", Lba));
912 //return STATUS_FT_WRITE_RECOVERY; // this shall not be treated as error and
913 // we shall get IO request to BAD block
915 }
916 }
917 }
918#endif //_UDF_STRUCTURES_H_
919
920 Vcb->VCBFlags |= UDF_VCB_LAST_WRITE;
921
922 if(
923#ifdef _BROWSE_UDF_
924 (((Vcb->FsDeviceType != FILE_DEVICE_CD_ROM_FILE_SYSTEM) ||
925 !(Vcb->VCBFlags & UDF_VCB_FLAGS_VOLUME_MOUNTED) ||
926 (Vcb->VCBFlags & UDF_VCB_FLAGS_RAW_DISK))
927 && !fms
928 ) ||
929#endif //_BROWSE_UDF_
930#ifdef UDF_FORMAT_MEDIA
931 (fms && fms->SkipPrepareW) ||
932#endif //UDF_FORMAT_MEDIA
934 ) {
935 UDFPrint(("Skip prepare for Write @%x\n", Lba));
936 return STATUS_SUCCESS;
937 }
938
939 // check if the device requires OPC before each write operation
940 UDFDoOPC(Vcb);
941
942 if(Vcb->SyncCacheState == SYNC_CACHE_RECOVERY_ATTEMPT) {
943 Vcb->SyncCacheState = SYNC_CACHE_RECOVERY_RETRY;
944 } else {
945 Vcb->SyncCacheState = SYNC_CACHE_RECOVERY_NONE;
946 }
947 if(Vcb->LastModifiedTrack &&
948 (Vcb->TrackMap[Vcb->LastModifiedTrack].FirstLba <= Lba) &&
949 (Vcb->TrackMap[Vcb->LastModifiedTrack].LastLba >= Lba) &&
950 !( (Vcb->MediaClassEx == CdMediaClass_DVDRW ||
951 Vcb->MediaClassEx == CdMediaClass_DVDpRW ||
952 Vcb->MediaClassEx == CdMediaClass_DVDRAM ||
953 Vcb->MRWStatus == DiscInfo_BGF_Interrupted ||
954 Vcb->MRWStatus == DiscInfo_BGF_InProgress) && (Lba > Vcb->LastLBA))
955 ) {
956 // Ok, we needn't change Write Parameters
957// if(Vcb->TrackMap[Vcb->LastModifiedTrack].Flags & TrackMap_Try_variation)
958// Vcb->TrackMap[Vcb->LastModifiedTrack].Flags |= TrackMap_Use_variation;
959 UDFPrint(("Skip prepare for Write (2) @%x\n", Lba));
960 return STATUS_SUCCESS;
961 }
962
964
966#ifdef UDF_FORMAT_MEDIA
967 if(fms) {
968 return STATUS_SUCCESS;
969 }
970#endif //UDF_FORMAT_MEDIA
971 }
972
973 for(uint32 i=Vcb->FirstTrackNum; i<=Vcb->LastTrackNum; i++) {
974 if((Vcb->TrackMap[i].FirstLba > Lba) ||
975 (Vcb->TrackMap[i].LastLba < Lba)) {
976 //UDFPrint(("not in track %d\n"));
977 continue;
978 }
979 OSSTATUS RC;
981
983 RC = STATUS_SUCCESS;
984 goto check_dvd_bg_format;
985 }
986
987 if(!Vcb->WParams) {
988 Vcb->WParams =
990 }
991 if(!(WParams = Vcb->WParams)) {
992 UDFPrint(("!WParams\n"));
994 }
995
996 RC = UDFPhSendIOCTL(IOCTL_CDRW_GET_WRITE_MODE, Vcb->TargetDeviceObject,
997 NULL,0,
998 (void*)(Vcb->WParams),sizeof(GET_WRITE_MODE_USER_OUT),
999 FALSE, NULL);
1000 if(!OS_SUCCESS(RC)) {
1001#ifdef UDF_FORMAT_MEDIA
1002 if(fms) {
1003 fms->SkipPrepareW = 1;
1004 MyFreePool__(WParams);
1005 return STATUS_SUCCESS;
1006 }
1007#endif //UDF_FORMAT_MEDIA
1008 UDFPrint(("!get WParams\n"));
1009 return RC;
1010 }
1011 // clear unnecassary flags
1012 WParams->Byte2.Flags &= ~WParam_TestWrite;
1013 WParams->Byte2.Flags &= ~WParam_WType_Mask;
1014 // select packet writing
1015 WParams->Byte2.Flags |= WParam_WType_Packet;
1016
1017 WParams->Byte3.Flags &= ~(WParam_TrkMode_Mask |
1019 WParam_Copy);
1020 WParams->Byte3.Flags |= Vcb->TrackMap[i].TrackParam &
1023 WParam_Copy);
1024
1025 // set packet type (VP/FP)
1026// if(opt_partition == PT_VAT15 ||
1027// opt_blank_vat15)
1028 if(WParams->Byte2.Flags & WParam_LS_V) {
1029 WParams->LinkSize = 7;
1030 }
1031
1032 if(Vcb->TrackMap[i].DataParam & TrkInfo_Packet) {
1033 if((Vcb->TrackMap[i].DataParam & TrkInfo_FP) &&
1034 !Vcb->CDR_Mode) {
1035 WParams->Byte3.Flags |= WParam_FP;
1036 } else {
1037 WParams->Byte3.Flags &= ~WParam_FP;
1038 }
1039 } else {
1040 if(!Vcb->CDR_Mode) {
1041 WParams->Byte3.Flags |= WParam_FP;
1042 } else {
1043 WParams->Byte3.Flags &= ~WParam_FP;
1044 }
1045 }
1046
1047 // select multisession mode
1048 WParams->Byte3.Flags &= ~WParam_MultiSes_Mask;
1049 if((Vcb->DiscStat & DiscInfo_Disk_Mask) == DiscInfo_Disk_Appendable) {
1050 WParams->Byte3.Flags |= WParam_Multises_Multi;
1051 } else
1052 if(Vcb->LastSession > 1) {
1053 WParams->Byte3.Flags |= WParam_Multises_Final;
1054 } else {
1055 WParams->Byte3.Flags |= WParam_Multises_None;
1056 }
1057 // set sector mode (Mode1/XA)
1058 WParams->Byte4.Flags &= ~WParam_BlkType_Mask;
1059 if((Vcb->TrackMap[i].DataParam & TrkInfo_Dat_Mask) == TrkInfo_Dat_XA) {
1060 // XA Mode2
1062 WParams->SesFmt = WParam_SesFmt_CdRomXa;
1063 } else if((Vcb->TrackMap[i].DataParam & TrkInfo_Dat_Mask) == TrkInfo_Dat_Mode1) {
1064 // Mode1
1066 WParams->SesFmt = WParam_SesFmt_CdRom;
1067 } else {
1068#ifdef UDF_FORMAT_MEDIA
1069 if(fms) {
1070 fms->SkipPrepareW = 1;
1071 MyFreePool__(WParams);
1072 return STATUS_SUCCESS;
1073 }
1074#endif //UDF_FORMAT_MEDIA
1075 UDFPrint((" inv sector mode\n"));
1077 }
1078 // set packet size
1079 *((uint32*)&(WParams->PacketSize)) = BCount;
1080 *((uint32*)&(WParams->SubHeader)) = 0;
1081 // set additional flags for VP
1082
1083 if(Vcb->CDR_Mode) {
1084// if(opt_partition == PT_VAT15)
1085 WParams->SubHeader.Params.Params1.SubMode = WParam_SubHdr_SubMode1;
1086 }
1087 WParams->PageLength = sizeof(GET_WRITE_MODE_USER_OUT)-2;
1089 // apply write parameters
1090 RC = UDFPhSendIOCTL(IOCTL_CDRW_SET_WRITE_MODE, Vcb->TargetDeviceObject,
1091 (void*)WParams,sizeof(SET_WRITE_MODE_USER_IN),
1092 NULL,0,FALSE,NULL);
1093
1094#ifdef UDF_FORMAT_MEDIA
1095 if(fms) {
1096 if(!NT_SUCCESS(RC)) {
1097 fms->SkipPrepareW = 1;
1098 MyFreePool__(WParams);
1099 return STATUS_SUCCESS;
1100 }
1101
1102 RC = UDFPhSendIOCTL(IOCTL_CDRW_GET_WRITE_MODE, Vcb->TargetDeviceObject,
1103 NULL,0,
1104 (PVOID)WParams,sizeof(GET_WRITE_MODE_USER_OUT),
1105 FALSE, NULL);
1106 if(!NT_SUCCESS(RC)) {
1107 MyFreePool__(WParams);
1108 return RC;
1109 }
1110
1111 if(fms->opt_partition == PT_VAT15 ||
1112 fms->opt_blank_vat15) {
1113 if(WParams->Byte3.Flags & WParam_FP) {
1114 MyFreePool__(WParams);
1116 }
1117 } else {
1118 if(!(WParams->Byte3.Flags & WParam_FP)) {
1119 MyFreePool__(WParams);
1121 }
1122 }
1123 }
1124#endif //UDF_FORMAT_MEDIA
1125
1126 // switch to random access mode
1127 ((PSET_RANDOM_ACCESS_USER_IN)WParams)->RandomAccessMode = Vcb->CDR_Mode ? FALSE : TRUE;
1128// ((PSET_RANDOM_ACCESS_USER_IN)WParams)->RandomAccessMode = (opt_partition != PT_VAT15) ? TRUE : FALSE;
1129 RC = UDFPhSendIOCTL(IOCTL_CDRW_SET_RANDOM_ACCESS, Vcb->TargetDeviceObject,
1130 (void*)WParams,sizeof(SET_RANDOM_ACCESS_USER_IN),
1131 NULL,0,FALSE, NULL);
1132
1133check_dvd_bg_format:
1134
1135 UDFPrint((" check BGF\n"));
1136 if(!Vcb->CDR_Mode) {
1137 if(OS_SUCCESS(RC)) {
1138 Vcb->LastModifiedTrack = i;
1139 if(!(Vcb->TrackMap[i].Flags & TrackMap_Use_variation)) {
1140 if(Vcb->TrackMap[i].Flags & TrackMap_Try_variation) {
1141 Vcb->TrackMap[i].Flags |= TrackMap_Use_variation;
1142 } else {
1143 Vcb->TrackMap[i].Flags |= TrackMap_Try_variation;
1144 }
1145 }
1146 }
1147 } else {
1148 Vcb->LastModifiedTrack = 0;
1149 }
1150// fms->SkipPrepareW = 1;
1151
1152
1153 if((Vcb->MediaClassEx == CdMediaClass_DVDRW ||
1154 Vcb->MediaClassEx == CdMediaClass_DVDpRW ||
1155 Vcb->MediaClassEx == CdMediaClass_DVDRAM ||
1156 Vcb->MRWStatus == DiscInfo_BGF_Interrupted )
1157 && (Lba > Vcb->LastLBA)) {
1158
1159 ULONG fLba;
1160 SIZE_T WrittenBytes;
1161 ULONG PSz = BCount << Vcb->BlockSizeBits;
1162#ifdef _BROWSE_UDF_
1163 ULONG retry;
1164#endif //_BROWSE_UDF_
1166
1167 ASSERT((Vcb->LastLBA+1) == Vcb->NWA);
1168
1169 if(Lba+BCount <= (Vcb->LastLBA+1) ) {
1170 UDFPrint(("DVD cont. fmt, LBA+BCount<=NWA, exiting\n"));
1171 return STATUS_SUCCESS;
1172 }
1173 if((Vcb->MRWStatus != DiscInfo_BGF_Interrupted) &&
1174 (Lba <= (Vcb->LastLBA+1)) ) {
1175 UDFPrint(("!PausedBGF + DVD cont. fmt, LBA<=NWA, exiting\n"));
1176 return STATUS_SUCCESS;
1177 }
1178
1179 if(Vcb->MRWStatus == DiscInfo_BGF_Interrupted) {
1180 // This code also can restart background MRW formatting
1181 UDFPrint(("DVD cont. fmt, LastLBA %x, Lba %x\n", Vcb->LastLBA, Lba));
1182
1184 if(ForBuf) {
1186 ForBuf->Flags.FlagsEx = FORMAT_UNIT_RESTART_MRW;
1187 ForBuf->BlockCount = 0xffffffff;
1188
1189 RC = UDFPhSendIOCTL(IOCTL_CDRW_FORMAT_UNIT, Vcb->TargetDeviceObject,
1190 ForBuf,sizeof(FORMAT_CDRW_PARAMETERS_USER_IN),
1191 NULL,0,FALSE, NULL);
1192 DbgFreePool(ForBuf);
1193 if(OS_SUCCESS(RC)) {
1194 UDFPrint(("BGFormat restarted Interrupted->InProgress\n"));
1195 Vcb->MRWStatus = DiscInfo_BGF_InProgress;
1196 } else {
1198 if(!Vcb->Error) {
1199 Vcb->Error = (PGET_LAST_ERROR_USER_OUT)
1201 }
1202 Error = Vcb->Error;
1203 if(Error) {
1204 UDFPhSendIOCTL( IOCTL_CDRW_GET_LAST_ERROR, Vcb->TargetDeviceObject,
1205 NULL,0,
1207 TRUE,NULL);
1208 UDFPrint(("SK=%x ASC=%x, ASCQ=%x, IE=%x\n",
1209 Error->SenseKey, Error->AdditionalSenseCode, Error->AdditionalSenseCodeQualifier, Error->LastError));
1210 // check for Long Write In Progress
1211 if( (Error->SenseKey == SCSI_SENSE_NOT_READY) &&
1212 (Error->AdditionalSenseCode == SCSI_ADSENSE_LUN_NOT_READY) &&
1213 ((Error->AdditionalSenseCodeQualifier == SCSI_SENSEQ_LONG_WRITE_IN_PROGRESS) ||
1214 (Error->AdditionalSenseCodeQualifier == SCSI_SENSEQ_FORMAT_IN_PROGRESS)) ) {
1215 RC = STATUS_SUCCESS;
1216 UDFPrint(("Seems, BGFormat already restarted\n"));
1217 Vcb->MRWStatus = DiscInfo_BGF_InProgress;
1218 }
1219 }
1220 }
1221 }
1222 } else {
1223 RC = STATUS_SUCCESS;
1224 }
1225
1226 UDFPrint(("DVD cont. write, LastLBA %x, Lba %x\n", Vcb->LastLBA, Lba));
1227
1228 ASSERT(Vcb->MediaClassEx == CdMediaClass_DVDRW);
1229 if(!Vcb->fZBuffer) {
1230 Vcb->fZBuffer = (PCHAR)DbgAllocatePoolWithTag(NonPagedPool, PSz, 'zNWD');
1231 RtlZeroMemory(Vcb->fZBuffer, PSz);
1232 Vcb->fZBufferSize = PSz;
1233 } else
1234 if(Vcb->fZBufferSize < PSz) {
1235 PSz = Vcb->fZBufferSize;
1236 }
1237 if(!Vcb->fZBuffer) {
1238 BrutePoint();
1240 } else {
1241 for(fLba = Vcb->NWA; fLba < Lba; fLba+=BCount) {
1242#ifdef _BROWSE_UDF_
1243 retry = UDF_WRITE_MAX_RETRY;
1244retry_1:
1245#endif //_BROWSE_UDF_
1246 RC = UDFPhWriteVerifySynchronous(Vcb->TargetDeviceObject, Vcb->fZBuffer, PSz,
1247 ((uint64)fLba) << Vcb->BlockSizeBits, &WrittenBytes, PH_TMP_BUFFER);
1248 Vcb->VCBFlags |= UDF_VCB_SKIP_EJECT_CHECK;
1249 UDFPrint(("Fmt status: %x\n", RC));
1250#ifdef _BROWSE_UDF_
1251 if(!OS_SUCCESS(RC) &&
1252 OS_SUCCESS(RC = UDFRecoverFromError(Vcb, TRUE, RC, fLba, BCount, &retry)) ) {
1253 goto retry_1;
1254 UDFPrint(("Fmt retry\n"));
1255 }
1256#endif //_BROWSE_UDF_
1257 if(!OS_SUCCESS(RC)) {
1258 BrutePoint();
1259 UDFPrint(("Fmt break on ERROR\n"));
1260 break;
1261 }
1262 UDFUpdateNWA(Vcb, fLba, BCount, RC);
1263 }
1264 }
1265 } else {
1266 UDFPrint((" no special processing\n"));
1267 }
1268
1269 return RC;
1270 }
1271#endif //UDF_READ_ONLY_BUILD
1272 UDFPrint((" no suitable track!\n"));
1274} // end UDFPrepareForWriteOperation()
BOOL Error
Definition: chkdsk.c:66
#define SCSI_ADSENSE_LUN_NOT_READY
Definition: cdrw_hw.h:1218
#define WParam_Multises_None
Definition: cdrw_hw.h:2651
#define WParam_SesFmt_CdRom
Definition: cdrw_hw.h:2698
#define WParam_TrkMode_AllowCpy
Definition: cdrw_hw.h:2647
#define WParam_SesFmt_CdRomXa
Definition: cdrw_hw.h:2700
#define DiscInfo_Disk_Appendable
Definition: cdrw_hw.h:2272
#define WParam_LS_V
Definition: cdrw_hw.h:2626
#define WParam_Copy
Definition: cdrw_hw.h:2648
#define WParam_TrkMode_Mask
Definition: cdrw_hw.h:2640
#define WParam_Multises_Final
Definition: cdrw_hw.h:2652
#define TrkInfo_Packet
Definition: cdrw_hw.h:2418
#define MODE_PAGE_WRITE_PARAMS
Definition: cdrw_hw.h:844
#define DiscInfo_BGF_InProgress
Definition: cdrw_hw.h:2301
#define WParam_SubHdr_SubMode1
Definition: cdrw_hw.h:2730
#define WParam_BlkType_M2XAF1_2048
Definition: cdrw_hw.h:2673
#define WParam_WType_Packet
Definition: cdrw_hw.h:2621
#define WParam_Multises_Multi
Definition: cdrw_hw.h:2653
#define DiscInfo_BGF_Interrupted
Definition: cdrw_hw.h:2300
#define WParam_BlkType_M1_2048
Definition: cdrw_hw.h:2671
#define DiscInfo_Disk_Mask
Definition: cdrw_hw.h:2270
#define SCSI_SENSE_NOT_READY
Definition: cdrw_hw.h:1189
#define SCSI_SENSEQ_FORMAT_IN_PROGRESS
Definition: cdrw_hw.h:1316
#define SCSI_SENSEQ_LONG_WRITE_IN_PROGRESS
Definition: cdrw_hw.h:1318
#define WParam_FP
Definition: cdrw_hw.h:2649
struct _FORMAT_CDRW_PARAMETERS_USER_IN * PFORMAT_CDRW_PARAMETERS_USER_IN
#define IOCTL_CDRW_GET_WRITE_MODE
Definition: cdrw_usr.h:85
struct _SET_RANDOM_ACCESS_USER_IN * PSET_RANDOM_ACCESS_USER_IN
#define IOCTL_CDRW_SET_RANDOM_ACCESS
Definition: cdrw_usr.h:99
MODE_WRITE_PARAMS_PAGE_USER GET_WRITE_MODE_USER_OUT
Definition: cdrw_usr.h:1010
#define IOCTL_CDRW_SET_WRITE_MODE
Definition: cdrw_usr.h:86
#define TrackMap_Use_variation
Definition: cdrw_usr.h:1640
PMODE_WRITE_PARAMS_PAGE_USER PGET_WRITE_MODE_USER_OUT
Definition: cdrw_usr.h:1011
#define TrackMap_Try_variation
Definition: cdrw_usr.h:1639
struct _GET_LAST_ERROR_USER_OUT * PGET_LAST_ERROR_USER_OUT
#define IOCTL_CDRW_GET_LAST_ERROR
Definition: cdrw_usr.h:103
#define IOCTL_CDRW_FORMAT_UNIT
Definition: cdrw_usr.h:98
#define FORMAT_UNIT_RESTART_MRW
Definition: cdrw_usr.h:516
#define UDFPhWriteVerifySynchronous
Definition: env_spec.h:46
#define BrutePoint()
Definition: env_spec_w32.h:504
#define PCHAR
Definition: match.c:90
#define ASSERT(a)
Definition: mode.c:44
void UDFUpdateNWA(PVCB Vcb, uint32 LBA, uint32 BCount, OSSTATUS RC)
Definition: phys_lib.cpp:3826
OSSTATUS UDFRecoverFromError(IN PVCB Vcb, IN BOOLEAN WriteOp, IN OSSTATUS status, IN uint32 Lba, IN uint32 BCount, IN OUT uint32 *retry)
Definition: phys_lib.cpp:1283
OSSTATUS UDFDoOPC(IN PVCB Vcb)
Definition: phys_lib.cpp:850
#define PH_TMP_BUFFER
Definition: phys_lib.h:65
union _MODE_WRITE_PARAMS_PAGE_USER::@935 Byte2
union _MODE_WRITE_PARAMS_PAGE_USER::@937 Byte4
union _MODE_WRITE_PARAMS_PAGE_USER::@936 Byte3
struct _MODE_WRITE_PARAMS_PAGE_USER::@939 SubHeader
#define UDFIsWriteParamsReq(Vcb)
Definition: udf_common.h:525
#define UDF_VCB_FLAGS_VOLUME_MOUNTED
Definition: udf_common.h:459
#define SYNC_CACHE_RECOVERY_ATTEMPT
Definition: udf_common.h:278
#define SYNC_CACHE_RECOVERY_NONE
Definition: udf_common.h:277
#define SYNC_CACHE_RECOVERY_RETRY
Definition: udf_common.h:279
#define UDF_VCB_SKIP_EJECT_CHECK
Definition: udf_common.h:470
#define UDF_WRITE_MAX_RETRY
Definition: udf_rel.h:502
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178

Referenced by UDFRecoverFromError(), and UDFTWrite().

◆ UDFReadAndProcessFullToc()

OSSTATUS UDFReadAndProcessFullToc ( PDEVICE_OBJECT  DeviceObject,
PVCB  Vcb 
)

Definition at line 2243 of file phys_lib.cpp.

2247{
2250 uint32 index;
2251 uint8 POINT;
2252 uint8 CurTrack = 0;
2253 uint32 LastLeadOut = 0;
2254// BOOLEAN IsMRW = FALSE;
2255
2256 UDFPrint(("UDFReadAndProcessFullToc\n"));
2257
2258 if(!toc) return STATUS_INSUFFICIENT_RESOURCES;
2259 Vcb->FirstTrackNum = 0xFF;
2260
2262
2264 NULL,0,
2265 toc,sizeof(READ_FULL_TOC_USER_OUT),
2266 TRUE,NULL);
2267
2268 if(!OS_SUCCESS(RC)) {
2269
2270 MyFreePool__(toc);
2271 return RC;
2272 }
2273
2274#ifdef _CONSOLE
2275 Vcb->PhDeviceType = FILE_DEVICE_CD_ROM;
2276#endif //_CONSOLE
2277 Vcb->LastSession = toc->Sessions.Last_TrackSes;
2278
2279 RC = UDFReallocTrackMap(Vcb, 0x100);
2280 if(!OS_SUCCESS(RC)) {
2281 MyFreePool__(toc);
2282 return RC;
2283 }
2284
2285 // get LastPossibleLBA
2286
2287 // Note: some drives return Full TOC items unordered.
2288 // So, LeadOut position may come before Track definition.
2289 // In order to handle such situation, we must initialize
2290 // CurTrack when First or Last Track descriptor comes
2292/* if((toc->SessionData[index].Adr == TOC_ADR_TrackInfo) &&
2293 ((toc->SessionData[index].Control == TOC_CTL_MRWTrackInfo) || (toc->SessionData[index].Control == TOC_CTL_MRWLastSes))) {
2294 IsMRW = TRUE;
2295 }*/
2296 if(toc->SessionData[index].Adr == 1) {
2297 switch (POINT = toc->SessionData[index].POINT) {
2298 case POINT_FirstTrackNum: {
2299 Vcb->FirstTrackNum = toc->SessionData[index].Params.FirstTrackNum.FirstTrackNum;
2300 if(!CurTrack)
2301 CurTrack = (uint8)(Vcb->FirstTrackNum);
2302 break;
2303 }
2304 case POINT_LastTrackNum: {
2305 Vcb->LastTrackNum = toc->SessionData[index].Params.LastTrackNum.LastTrackNum;
2306 if(CurTrack < Vcb->LastTrackNum)
2307 CurTrack = (uint8)(Vcb->FirstTrackNum);
2308 break;
2309 }
2311#define TempMSF toc->SessionData[index].Params.StartPositionOfLeadOut.MSF
2312 Vcb->TrackMap[CurTrack].LastLba = MSF_TO_LBA(TempMSF[0],TempMSF[1],TempMSF[2]);
2313 LastLeadOut = max(LastLeadOut, Vcb->TrackMap[CurTrack].LastLba);
2314#undef TempMSF
2315 break;
2316 }
2317 default: {
2318 if( (Vcb->FirstTrackNum != 0x0FF) &&
2319 (toc->SessionData[index].POINT == Vcb->FirstTrackNum) ) {
2320#define TempMSF toc->SessionData[index].Params.StartPositionOfTrack.MSF
2321 Vcb->FirstLBA = MSF_TO_LBA(TempMSF[0],TempMSF[1],TempMSF[2]);
2322 if(Vcb->FirstLBA & 0x80000000) {
2323 Vcb->FirstLBA = 0;
2324 }
2325#undef TempMSF
2326 }
2327 break;
2328 }
2329 }
2332#define TempMSF toc->SessionData[index].Params.StartPositionOfTrack.MSF
2333 Vcb->TrackMap[POINT].FirstLba = MSF_TO_LBA(TempMSF[0],TempMSF[1],TempMSF[2])-1;
2334 if(Vcb->TrackMap[POINT].FirstLba & 0x80000000) {
2335 if(POINT == 1) {
2336 Vcb->TrackMap[POINT].FirstLba = 0;
2337 } else {
2338 if(Vcb->TrackMap[POINT-1].LastLba) {
2339 Vcb->TrackMap[POINT].FirstLba = Vcb->TrackMap[POINT-1].LastLba+1;
2340 }
2341 }
2342 }
2343#undef TempMSF
2345 Vcb->TrackMap[POINT-1].LastLba = Vcb->TrackMap[POINT].FirstLba-1;
2346 }
2347 CurTrack = POINT;
2348 }
2349 } else
2350 if(toc->SessionData[index].Adr == 5) {
2351 switch (POINT = toc->SessionData[index].POINT) {
2353#define TempMSF toc->SessionData[index].Params.StartPositionOfNextProgramArea.MaxLeadOut_MSF
2354 Vcb->LastPossibleLBA = MSF_TO_LBA(TempMSF[0],TempMSF[1],TempMSF[2]);
2355#undef TempMSF
2356 break;
2357 }
2358 default: {
2359 break;
2360 }
2361 }
2362 }
2363
2364 }
2365
2366/* if(!IsMRW) {
2367 UDFPrint(("No MRW\n"));
2368 Vcb->CompatFlags &= ~UDF_VCB_IC_MRW_ADDR_PROBLEM;
2369 }*/
2370// Vcb->CompatFlags &= ~UDF_VCB_IC_MRW_ADDR_PROBLEM;
2371 // some devices report LastTrackNum=0 for full disks
2372 Vcb->LastTrackNum = max(Vcb->LastTrackNum, Vcb->FirstTrackNum);
2373 Vcb->TrackMap[Vcb->LastTrackNum].LastLba = max(LastLeadOut, Vcb->TrackMap[Vcb->LastTrackNum].LastLba);
2374
2375 Vcb->LastLBA = Vcb->TrackMap[Vcb->LastTrackNum].LastLba;
2376
2377 MyFreePool__(toc);
2378// Vcb->LastLBA=PacketVariable2Fixed(Vcb->LastLBA)-2;
2379 return STATUS_SUCCESS;
2380} // end UDFReadAndProcessFullToc()
#define index(s, c)
Definition: various.h:29
#define POINT_FirstTrackNum
Definition: cdrw_hw.h:1560
#define POINT_LastTrackNum
Definition: cdrw_hw.h:1561
#define POINT_StartPositionOfTrack_Min
Definition: cdrw_hw.h:1558
#define POINT_StartPositionOfNextProgramArea
Definition: cdrw_hw.h:1566
#define POINT_StartPositionOfTrack_Max
Definition: cdrw_hw.h:1559
#define POINT_StartPositionOfLeadOut
Definition: cdrw_hw.h:1562
#define MAXIMUM_NUMBER_OF_SESSIONS
Definition: cdrw_hw.h:835
PREAD_TOC_FULL_TOC PREAD_FULL_TOC_USER_OUT
Definition: cdrw_usr.h:1385
#define IOCTL_CDRW_READ_FULL_TOC
Definition: cdrw_usr.h:113
#define MSF_TO_LBA(Minutes, Seconds, Frames)
Definition: tools.h:269
GLuint index
Definition: glext.h:6031
OSSTATUS UDFReallocTrackMap(IN PVCB Vcb, IN uint32 TrackNum)
Definition: phys_lib.cpp:69
#define TempMSF
#define FILE_DEVICE_CD_ROM
Definition: winioctl.h:108
READ_TOC_HEADER Sessions
Definition: cdrw_hw.h:1688
TOC_SES_INFO SessionData[MAXIMUM_NUMBER_OF_SESSIONS]
Definition: cdrw_hw.h:1689
UCHAR Last_TrackSes
Definition: cdrw_hw.h:1528
UCHAR POINT
Definition: cdrw_hw.h:1584
union _TOC_SES_INFO::@801 Params
UCHAR FirstTrackNum
Definition: cdrw_hw.h:1619
UCHAR LastTrackNum
Definition: cdrw_hw.h:1628
#define POINT
Definition: precomp.h:30

Referenced by UDFGetDiskInfo().

◆ UDFReadDiscTrackInfo()

OSSTATUS UDFReadDiscTrackInfo ( PDEVICE_OBJECT  DeviceObject,
PVCB  Vcb 
)

Definition at line 1635 of file phys_lib.cpp.

1639{
1643 PTRACK_INFO_BLOCK_USER_IN TrackInfoIn = (PTRACK_INFO_BLOCK_USER_IN)TrackInfoOut;
1644 READ_CAPACITY_USER_OUT CapacityBuffer;
1645 LONG TrackNumber;
1646 BOOLEAN NotFP = FALSE;
1647 BOOLEAN ForceFP = FALSE;
1648 BOOLEAN PacketTrack = FALSE;
1649 BOOLEAN MRWRetry = FALSE;
1650// BOOLEAN ReadCapacityOk = FALSE;
1651#ifdef UDF_FORMAT_MEDIA
1652 PUDFFmtState fms = Vcb->fms;
1653#endif
1654
1655 _SEH2_TRY {
1656 if(!DiscInfo || !TrackInfoOut)
1658
1659MRWRetry_label:
1660
1662 NULL, 0,
1663 DiscInfo,sizeof(DISC_INFO_BLOCK_USER_OUT), TRUE, NULL);
1664 if(!OS_SUCCESS(RC)) {
1665 UDFPrint(("ReadDiskInfo failed. Use default.\n"));
1666 if(Vcb->MediaClassEx == CdMediaClass_DVDRW ||
1667 Vcb->MediaClassEx == CdMediaClass_DVDpRW ||
1668 Vcb->MediaClassEx == CdMediaClass_DVDRAM) {
1669 Vcb->LastPossibleLBA = DEFAULT_LAST_LBA_DVD;
1670 } else
1671 if(Vcb->MediaClassEx == CdMediaClass_BDRE) {
1672 Vcb->LastPossibleLBA = DEFAULT_LAST_LBA_BD;
1673 } else {
1674 Vcb->LastPossibleLBA = DEFAULT_LAST_LBA_FP_CD;
1675 }
1676 try_return(RC);
1677 }
1678#ifdef UDF_FORMAT_MEDIA
1679 if(fms && fms->opt_disk_info) {
1680 UserPrint(("ReadDiskInfo OK\n"));
1681 }
1682#endif //UDF_FORMAT_MEDIA
1683
1685 NULL, 0,
1686 &CapacityBuffer,sizeof(READ_CAPACITY_USER_OUT), TRUE, NULL);
1687 if(!OS_SUCCESS(RC)) {
1688 UDFPrint(("ReadCapacity failed.\n"));
1689 if(Vcb->MediaClassEx == CdMediaClass_DVDpRW) {
1690 Vcb->LastPossibleLBA = DEFAULT_LAST_LBA_DVD;
1691 }
1692 } else {
1693 UDFPrint(("ReadCapacity ok.\n"));
1694 UDFPrint(("Last possible LBA %#x.\n", CapacityBuffer.LogicalBlockAddress));
1695 if(!(CapacityBuffer.LogicalBlockAddress & 0xc0000000) &&
1696 (CapacityBuffer.LogicalBlockAddress != 0x7fffffff)) {
1697 // good value from ReadCapacity
1698 UDFPrint(("Update Last possible LBA %#x.\n", CapacityBuffer.LogicalBlockAddress));
1699 Vcb->LastPossibleLBA = CapacityBuffer.LogicalBlockAddress;
1700// ReadCapacityOk = TRUE;
1701#ifdef UDF_FORMAT_MEDIA
1702 if(fms && fms->opt_disk_info) {
1703 UserPrint(("ReadCapacity OK\n"));
1704 }
1705#endif //UDF_FORMAT_MEDIA
1706 }
1707 }
1708
1709#ifdef _CONSOLE
1710 Vcb->PhDeviceType = FILE_DEVICE_CD_ROM;
1711#endif //_CONSOLE
1712 Vcb->PhSerialNumber = *((uint32*)&(DiscInfo->DiskId));
1713 Vcb->PhErasable = DiscInfo->DiscStat.Flags & DiscInfo_Disk_Erasable;
1714 Vcb->PhDiskType = DiscInfo->DiskType;
1715 // save OPC info
1716 if(DiscInfo->OPCNum)
1717 Vcb->OPCNum = DiscInfo->OPCNum;
1718 UDFPrint(("DiskInfo: SN %x, OPCn %x(%x), Stat %x, Flg: %x\n",
1719 Vcb->PhSerialNumber, Vcb->OPCNum, DiscInfo->OPCNum, DiscInfo->DiscStat.Flags, DiscInfo->Flags.Flags));
1720#ifdef UDF_FORMAT_MEDIA
1721 if(fms && fms->opt_disk_info) {
1722 UserPrint(("Media type: "));
1723 switch(Vcb->MediaClassEx) {
1724 case CdMediaClass_CDROM : UserPrint(("CD-ROM \n")); break;
1725 case CdMediaClass_CDR : UserPrint(("CD-R \n")); break;
1726 case CdMediaClass_CDRW : UserPrint(("CD-RW \n")); break;
1727 case CdMediaClass_DVDROM : UserPrint(("DVD-ROM \n")); break;
1728 case CdMediaClass_DVDRAM : UserPrint(("DVD-RAM \n")); break;
1729 case CdMediaClass_DVDR : UserPrint(("DVD-R \n")); break;
1730 case CdMediaClass_DVDRW : UserPrint(("DVD-RW \n")); break;
1731 case CdMediaClass_DVDpR : UserPrint(("DVD+R \n")); break;
1732 case CdMediaClass_DVDpRW : UserPrint(("DVD+RW \n")); break;
1733 case CdMediaClass_DDCDROM : UserPrint(("DDCD-ROM \n")); break;
1734 case CdMediaClass_DDCDR : UserPrint(("DDCD-R \n")); break;
1735 case CdMediaClass_DDCDRW : UserPrint(("DDCD-RW \n")); break;
1736 case CdMediaClass_BDROM : UserPrint(("BD-ROM \n")); break;
1737 case CdMediaClass_BDRE : UserPrint(("BD-RE \n")); break;
1738 case CdMediaClass_BDR : UserPrint(("BD-R \n")); break;
1739 case CdMediaClass_HD_DVDROM : UserPrint(("HD DVD-ROM \n")); break;
1740 case CdMediaClass_HD_DVDRAM : UserPrint(("HD DVD-RAM \n")); break;
1741 case CdMediaClass_HD_DVDR : UserPrint(("HD DVD-R \n")); break;
1742 case CdMediaClass_HD_DVDRW : UserPrint(("HD DVD-RW \n")); break;
1743 default: UserPrint(("Unknown\n")); break;
1744 }
1745 UserPrint(("SN %#x, OPCn %#x\n",
1746 Vcb->PhSerialNumber, Vcb->OPCNum, DiscInfo->OPCNum));
1747 UserPrint(("Disk State: "));
1748 switch(DiscInfo->DiscStat.Flags & DiscInfo_Disk_Mask) {
1750 UserPrint(("Empty\n"));
1751 break;
1753 UserPrint(("Appendable\n"));
1754 break;
1756 UserPrint(("Complete\n"));
1757 break;
1759 UserPrint(("RW in unknown state\n"));
1760 break;
1761 }
1762 UserPrint(("Last Session State: "));
1763 switch(DiscInfo->DiscStat.Flags & DiscInfo_Ses_Mask) {
1764 case DiscInfo_Ses_Empty:
1765 UserPrint(("Empty\n"));
1766 break;
1768 UserPrint(("Incomplete\n"));
1769 break;
1771 UserPrint(("Complete\n"));
1772 break;
1773 default:
1774 UserPrint(("unknown state\n"));
1775 break;
1776 }
1777 UserPrint(("Erasable: %s\n",
1778 (DiscInfo->DiscStat.Flags & DiscInfo_Disk_Erasable) ? "yes" : "no"
1779 ));
1780 }
1781#endif //UDF_FORMAT_MEDIA
1782 // Save disk status
1783 Vcb->DiscStat = DiscInfo->DiscStat.Flags;
1784 if((DiscInfo->DiscStat.Flags & DiscInfo_Disk_Mask) == DiscInfo_Disk_Empty) {
1785 UDFPrint(("Blank\n"));
1786 Vcb->BlankCD = TRUE;
1787 }
1788 if( (DiscInfo->DiscStat.Flags & DiscInfo_Disk_Mask) == DiscInfo_Disk_Empty ||
1789 (DiscInfo->DiscStat.Flags & DiscInfo_Ses_Mask) == DiscInfo_Ses_Incomplete) {
1790 // we shall mount empty disk to make it possible for
1791 // external applications to perform format operation
1792 // or something like this
1793 UDFPrint(("Try RAW_MOUNT\n"));
1794 Vcb->VCBFlags |= UDF_VCB_FLAGS_RAW_DISK;
1795 PacketTrack = TRUE;
1796 }
1797
1798#ifndef _BROWSE_UDF_
1799 // If drive returned reasonable value from ReadCapacity, do not use
1800 // last LeadIn/LeadOut
1801 if(Vcb->MediaClassEx != CdMediaClass_DVDpRW &&
1802 !ReadCapacityOk) {
1803 // +RW returns bad value
1804 UDFPrint(("+RW returns bad value\n"));
1805 Vcb->LastPossibleLBA = (DiscInfo->LastSesLeadOutLBA & 0x80000000) ?
1806 0 : DiscInfo->LastSesLeadOutLBA;
1807 if(!(DiscInfo->LastSesLeadInLBA & 0x80000000)) {
1808 Vcb->LastPossibleLBA = max(DiscInfo->LastSesLeadInLBA, Vcb->LastPossibleLBA);
1809 }
1810 }
1811#endif // _BROWSE_UDF_
1812 if((DiscInfo->Flags.Flags & DiscInfo_BGF_Mask) != 0) {
1813 UDFPrint(("ForceFP + MRW\n"));
1814 ForceFP = TRUE;
1815 Vcb->MRWStatus = DiscInfo->Flags.Flags & DiscInfo_BGF_Mask;
1816 // update addressing mode
1817 if(!MRWRetry) {
1819 MRWRetry = TRUE;
1820 goto MRWRetry_label;
1821 }
1822 }
1823 UDFPrint(("MRW state %x\n", Vcb->MRWStatus));
1824 if(Vcb->MediaClassEx == CdMediaClass_DVDRW) {
1825 if(Vcb->PhMediaCapFlags & CdCapFlags_RandomWritable) {
1826 UDFPrint(("DVD-RW Rewritable\n"));
1827 ForceFP = TRUE;
1828 } else
1829 if((DiscInfo->DiscStat.Flags & DiscInfo_Disk_Mask) == DiscInfo_Disk_Empty) {
1830 UDFPrint(("Blank DVD-RW\n"));
1831 ForceFP = TRUE;
1832 } else {
1833 UDFPrint(("DVD-RW Sequential\n"));
1834 NotFP = TRUE;
1835 }
1836 } else
1837 if(CdrwIsDvdOverwritable(Vcb->MediaClassEx)) {
1838 UDFPrint(("force Rewritable (2)\n"));
1839 ForceFP = TRUE;
1840 }
1841 // We have incomplete last session, so process each track from last to first
1842// Vcb->LastPossibleLBA = DiscInfo->LastSesLeadInLBA;
1843
1844 Vcb->LastSession = DiscInfo->Status.NumOfSes;
1845 Vcb->LastTrackNum = DiscInfo->Status.LastTrackNumLastSes;
1846 Vcb->FirstTrackNum = DiscInfo->FirstTrackNum;
1847 // some devices report LastTrackNum=0 for full disks
1848 Vcb->LastTrackNum = max(Vcb->LastTrackNum, Vcb->FirstTrackNum);
1849 if(!Vcb->LastTrackNum) {
1850 UDFPrint(("Try read 1st track...\n"));
1851 Vcb->LastTrackNum = 1;
1852 }
1853 UDFPrint(("DiskInfo: 1st trk %x, last trk %x\n", Vcb->FirstTrackNum, Vcb->LastTrackNum));
1854#ifdef UDF_FORMAT_MEDIA
1855 if(fms && fms->opt_disk_info) {
1856 UserPrint(("First track: %d\n"
1857 "Last track: %d\n", Vcb->FirstTrackNum, Vcb->LastTrackNum));
1858 UserPrint(("------------------------------------------\n"));
1859 }
1860#endif //UDF_FORMAT_MEDIA
1861
1862 RC = UDFReallocTrackMap(Vcb, Vcb->LastTrackNum+1);
1863 if(!OS_SUCCESS(RC))
1864 try_return(RC);
1865
1866 // Get last LBA from invisible track (if any)
1867 RtlZeroMemory(TrackInfoOut,sizeof(TRACK_INFO_BLOCK_USER_OUT));
1868
1869 TrackInfoIn->LBA_TrkNum = 0; // invisible track
1870 TrackInfoIn->Track = TRUE;
1871
1873 TrackInfoIn, sizeof(TRACK_INFO_BLOCK_USER_IN),
1874 TrackInfoOut,sizeof(TRACK_INFO_BLOCK_USER_OUT), TRUE, NULL);
1875 if(OS_SUCCESS(RC)) {
1876 if((Vcb->LastTrackNum < TrackInfoOut->TrackNum) &&
1877 TrackInfoOut->TrackLength &&
1878 (TrackInfoOut->TrackStartLBA != TrackInfoOut->NextWriteLBA)) {
1879 Vcb->LastTrackNum = TrackInfoOut->TrackNum;
1880 if(!(TrackInfoOut->NextWriteLBA & 0x80000000))
1881 Vcb->NWA = TrackInfoOut->NextWriteLBA;
1882 if(TrackInfoOut->TrackLength > 1) {
1883 Vcb->LastPossibleLBA =
1884 TrackInfoOut->TrackStartLBA + TrackInfoOut->TrackLength - (TrackInfoOut->TrackLength ? 1 : 0);
1885 UDFPrint((" set LastPossibleLBA=%x\n", Vcb->LastPossibleLBA));
1886 }
1887 }
1888
1889 UDFPrint(("Ses %d, Track %d (%x, len %x) PckSize %x: \n"
1890 " NWA: %x (%s) DatType:%x, %s %s %s %s TrkType:%x %s %s\n"
1891 " LRA: %x (%s) RC_LBA:%x\n",
1892 TrackInfoOut->SesNum,
1893 0,
1894 TrackInfoOut->TrackStartLBA,
1895 TrackInfoOut->TrackLength,
1896 TrackInfoOut->FixPacketSize,
1897
1898 TrackInfoOut->NextWriteLBA,
1899 TrackInfoOut->NWA_V & TrkInfo_NWA_V ? "vld" : "inv",
1900 TrackInfoOut->DataParam.Flags & TrkInfo_Dat_Mask,
1901 (TrackInfoOut->DataParam.Flags & TrkInfo_Packet) ? "Pck" : "",
1902 (TrackInfoOut->DataParam.Flags & TrkInfo_FP) ? "FP" : "",
1903 (TrackInfoOut->DataParam.Flags & TrkInfo_Blank) ? "Blank" : "",
1904 (TrackInfoOut->DataParam.Flags & TrkInfo_RT) ? "RT" : "",
1905
1906 TrackInfoOut->TrackParam.Flags & TrkInfo_Trk_Mask,
1907 (TrackInfoOut->TrackParam.Flags & TrkInfo_Copy) ? "Cpy" : "",
1908 (TrackInfoOut->TrackParam.Flags & TrkInfo_Damage) ? "Damage" : "",
1909
1910 TrackInfoOut->LastRecordedAddr,
1911 (TrackInfoOut->NWA_V & TrkInfo_LRA_V) ? "vld" : "inv",
1912
1913 TrackInfoOut->ReadCompatLBA
1914 ));
1915#ifdef UDF_FORMAT_MEDIA
1916 if(fms && fms->opt_disk_info) {
1917 UserPrint(("Invisible track: \n"));
1918 UserPrint((" Ses %d, Track %d (%x, len %x) PckSize %x: \n"
1919 " NWA: %x (%s) DatType:%x, %s %s %s %s TrkType:%x %s %s\n"
1920 " LRA: %x (%s) RC_LBA:%x\n",
1921 TrackInfoOut->SesNum,
1922 0,
1923 TrackInfoOut->TrackStartLBA,
1924 TrackInfoOut->TrackLength,
1925 TrackInfoOut->FixPacketSize,
1926
1927 TrackInfoOut->NextWriteLBA,
1928 TrackInfoOut->NWA_V & TrkInfo_NWA_V ? "vld" : "inv",
1929 TrackInfoOut->DataParam.Flags & TrkInfo_Dat_Mask,
1930 (TrackInfoOut->DataParam.Flags & TrkInfo_Packet) ? "Pck" : "",
1931 (TrackInfoOut->DataParam.Flags & TrkInfo_FP) ? "FP" : "",
1932 (TrackInfoOut->DataParam.Flags & TrkInfo_Blank) ? "Blank" : "",
1933 (TrackInfoOut->DataParam.Flags & TrkInfo_RT) ? "RT" : "",
1934
1935 TrackInfoOut->TrackParam.Flags & TrkInfo_Trk_Mask,
1936 (TrackInfoOut->TrackParam.Flags & TrkInfo_Copy) ? "Cpy" : "",
1937 (TrackInfoOut->TrackParam.Flags & TrkInfo_Damage) ? "Damage" : "",
1938
1939 TrackInfoOut->LastRecordedAddr,
1940 (TrackInfoOut->NWA_V & TrkInfo_LRA_V) ? "vld" : "inv",
1941
1942 TrackInfoOut->ReadCompatLBA
1943 ));
1944 }
1945#endif //UDF_FORMAT_MEDIA
1946
1947 }
1948
1949 for (TrackNumber=(LONG)DiscInfo->FirstTrackNum;TrackNumber <= (LONG)Vcb->LastTrackNum;TrackNumber++) {
1950
1951 RtlZeroMemory(TrackInfoOut,sizeof(TRACK_INFO_BLOCK_USER_OUT));
1952 TrackInfoIn->LBA_TrkNum = TrackNumber;
1953 TrackInfoIn->Track = TRUE;
1954
1956 TrackInfoIn, sizeof(TRACK_INFO_BLOCK_USER_IN),
1957 TrackInfoOut,sizeof(TRACK_INFO_BLOCK_USER_OUT), TRUE, NULL);
1958 // fill sector type map
1959 if(TrackInfoOut->TrackStartLBA & 0x80000000) {
1960 UDFPrint(("TrkInfo: Bad FirstLba (%x), change to %x\n", TrackInfoOut->TrackStartLBA, 0));
1961 Vcb->TrackMap[TrackNumber].FirstLba = 0;
1962 } else {
1963 Vcb->TrackMap[TrackNumber].FirstLba = TrackInfoOut->TrackStartLBA;
1964 }
1965 if(TrackInfoOut->TrackLength & 0x80000000) {
1966 UDFPrint(("TrkInfo: Bad TrackLength (%x), change to %x\n", TrackInfoOut->TrackLength,
1967 Vcb->LastPossibleLBA - Vcb->TrackMap[TrackNumber].FirstLba + 1));
1968 TrackInfoOut->TrackLength = Vcb->LastPossibleLBA - Vcb->TrackMap[TrackNumber].FirstLba + 1;
1969 }
1970 Vcb->TrackMap[TrackNumber].LastLba = TrackInfoOut->TrackStartLBA +
1971 TrackInfoOut->TrackLength -
1972 (TrackInfoOut->TrackLength ? 1 : 0);
1973
1974 Vcb->TrackMap[TrackNumber].TrackParam = TrackInfoOut->TrackParam.Flags;
1975 Vcb->TrackMap[TrackNumber].DataParam = TrackInfoOut->DataParam.Flags;
1976 Vcb->TrackMap[TrackNumber].NWA_V = TrackInfoOut->NWA_V;
1977 if((TrackInfoOut->NextWriteLBA & 0x80000000) ||
1978 (TrackInfoOut->NextWriteLBA < TrackInfoOut->TrackStartLBA)) {
1979 if(!(Vcb->TrackMap[TrackNumber].LastLba & 0x8000000)) {
1980 UDFPrint(("TrkInfo: set NWA to LastLba (%x)\n", Vcb->TrackMap[TrackNumber].LastLba));
1981 Vcb->TrackMap[TrackNumber].NWA =
1982 Vcb->TrackMap[TrackNumber].LastLba;
1983 } else {
1984 UDFPrint(("TrkInfo: set NWA to INV (1)\n"));
1985 Vcb->TrackMap[TrackNumber].NWA = 0;
1986 Vcb->TrackMap[TrackNumber].NWA_V = 0;
1987 }
1988 } else {
1989 if(!(TrackInfoOut->NextWriteLBA & 0x80000000)) {
1990 UDFPrint(("TrkInfo: Good NWA (%x)\n", TrackInfoOut->NextWriteLBA));
1991 Vcb->TrackMap[TrackNumber].NWA =
1992 TrackInfoOut->NextWriteLBA;
1993 } else {
1994 UDFPrint(("TrkInfo: set NWA to INV (2)\n"));
1995 Vcb->TrackMap[TrackNumber].NWA = 0;
1996 Vcb->TrackMap[TrackNumber].NWA_V = 0;
1997 }
1998 }
1999 Vcb->TrackMap[TrackNumber].Session = TrackInfoOut->SesNum;
2000 // for FP tracks we shall get PacketSize from returned info
2001 // otherwise set to default UDF value (0x20)
2002 if(NotFP) {
2003 UDFPrint(("Apply NotFP\n"));
2004 Vcb->TrackMap[TrackNumber].DataParam &= ~TrkInfo_FP;
2005#ifdef DBG
2006 TrackInfoOut->DataParam.Flags &= ~TrkInfo_FP;
2007#endif //DBG
2008 } else
2009 if(ForceFP) {
2010 UDFPrint(("Apply ForceFP\n"));
2011 PacketTrack = TRUE;
2012 Vcb->TrackMap[TrackNumber].DataParam |= TrkInfo_FP;
2013#ifdef DBG
2014 TrackInfoOut->DataParam.Flags |= TrkInfo_FP;
2015#endif //DBG
2016 }
2017 if(Vcb->TrackMap[TrackNumber].DataParam & TrkInfo_FP) {
2018 Vcb->TrackMap[TrackNumber].PacketSize = TrackInfoOut->FixPacketSize;
2019 Vcb->VCBFlags |= UDF_VCB_FLAGS_RAW_DISK;
2020 Vcb->FP_disc = TRUE;
2021 } else {
2022 Vcb->TrackMap[TrackNumber].PacketSize = PACKETSIZE_UDF;
2023 }
2024 // presence of Damaged track means, that we should mount this disk in RAW mode
2025 if(Vcb->TrackMap[TrackNumber].TrackParam & TrkInfo_Damage) {
2026 UDFPrint(("TrkInfo_Damage, Try RAW_MOUNT\n"));
2027 Vcb->VCBFlags |= UDF_VCB_FLAGS_RAW_DISK;
2028 }
2029 // presence of track with Unknown data type means, that we should mount
2030 // this disk in RAW mode
2031 if((TrackInfoOut->DataParam.Flags & TrkInfo_Dat_Mask) == TrkInfo_Trk_unknown) {
2032 UDFPrint(("Unknown DatType, Try RAW_MOUNT\n"));
2033 Vcb->VCBFlags |= UDF_VCB_FLAGS_RAW_DISK;
2034 }
2035
2036 PacketTrack |= ((TrackInfoOut->DataParam.Flags & TrkInfo_Packet) != 0);
2037
2038 UDFPrint(("Ses %d, Track %d (%x - %x) PckSize %x: \n"
2039 " NWA: %x (%s) DatType:%x, %s %s %s %s TrkType:%x %s %s\n"
2040 " LRA: %x (%s) RC_LBA:%x\n",
2041 TrackInfoOut->SesNum,
2042 TrackNumber,
2043 Vcb->TrackMap[TrackNumber].FirstLba,
2044 Vcb->TrackMap[TrackNumber].LastLba,
2045 TrackInfoOut->FixPacketSize,
2046
2047 TrackInfoOut->NextWriteLBA,
2048 TrackInfoOut->NWA_V & TrkInfo_NWA_V ? "vld" : "inv",
2049 TrackInfoOut->DataParam.Flags & TrkInfo_Dat_Mask,
2050 (TrackInfoOut->DataParam.Flags & TrkInfo_Packet) ? "Pck" : "",
2051 (TrackInfoOut->DataParam.Flags & TrkInfo_FP) ? "FP" : "",
2052 (TrackInfoOut->DataParam.Flags & TrkInfo_Blank) ? "Blank" : "",
2053 (TrackInfoOut->DataParam.Flags & TrkInfo_RT) ? "RT" : "",
2054
2055 TrackInfoOut->TrackParam.Flags & TrkInfo_Trk_Mask,
2056 (TrackInfoOut->TrackParam.Flags & TrkInfo_Copy) ? "Cpy" : "",
2057 (TrackInfoOut->TrackParam.Flags & TrkInfo_Damage) ? "Damage" : "",
2058
2059 TrackInfoOut->LastRecordedAddr,
2060 (TrackInfoOut->NWA_V & TrkInfo_LRA_V) ? "vld" : "inv",
2061
2062 TrackInfoOut->ReadCompatLBA
2063 ));
2064#ifdef UDF_FORMAT_MEDIA
2065 if(fms && fms->opt_disk_info) {
2066 UserPrint(("Track %d: \n", TrackNumber));
2067 UserPrint((" Ses %d, Track %d (%x, len %x) PckSize %x: \n"
2068 " NWA: %x (%s) DatType:%x, %s %s %s %s TrkType:%x %s %s\n"
2069 " LRA: %x (%s) RC_LBA:%x\n",
2070 TrackInfoOut->SesNum,
2071 TrackNumber,
2072 TrackInfoOut->TrackStartLBA,
2073 TrackInfoOut->TrackLength,
2074 TrackInfoOut->FixPacketSize,
2075
2076 TrackInfoOut->NextWriteLBA,
2077 TrackInfoOut->NWA_V & TrkInfo_NWA_V ? "vld" : "inv",
2078 TrackInfoOut->DataParam.Flags & TrkInfo_Dat_Mask,
2079 (TrackInfoOut->DataParam.Flags & TrkInfo_Packet) ? "Pck" : "",
2080 (TrackInfoOut->DataParam.Flags & TrkInfo_FP) ? "FP" : "",
2081 (TrackInfoOut->DataParam.Flags & TrkInfo_Blank) ? "Blank" : "",
2082 (TrackInfoOut->DataParam.Flags & TrkInfo_RT) ? "RT" : "",
2083
2084 TrackInfoOut->TrackParam.Flags & TrkInfo_Trk_Mask,
2085 (TrackInfoOut->TrackParam.Flags & TrkInfo_Copy) ? "Cpy" : "",
2086 (TrackInfoOut->TrackParam.Flags & TrkInfo_Damage) ? "Damage" : "",
2087
2088 TrackInfoOut->LastRecordedAddr,
2089 (TrackInfoOut->NWA_V & TrkInfo_LRA_V) ? "vld" : "inv",
2090
2091 TrackInfoOut->ReadCompatLBA
2092 ));
2093 }
2094#endif //UDF_FORMAT_MEDIA
2095
2096 if(TrackNumber == DiscInfo->FirstTrackNum) {
2097 if(!(Vcb->TrackMap[TrackNumber].FirstLba & 0x80000000)) {
2098 UDFPrint(("TrkInfo: Update FirstLBA (%x)\n", Vcb->TrackMap[TrackNumber].FirstLba));
2099 Vcb->FirstLBA = Vcb->TrackMap[TrackNumber].FirstLba;
2100 }
2101 }
2102 if((TrackInfoOut->SesNum == Vcb->LastSession) && !Vcb->FirstTrackNumLastSes) {
2103 if(!(Vcb->TrackMap[TrackNumber].FirstLba & 0x80000000)) {
2104 UDFPrint(("TrkInfo: Update FirstLBALastSes (%x)\n", Vcb->TrackMap[TrackNumber].FirstLba));
2105 Vcb->FirstLBALastSes = Vcb->TrackMap[TrackNumber].FirstLba;
2106 }
2107 Vcb->FirstTrackNumLastSes = TrackNumber;
2108 }
2109 }
2110
2111 if(!(TrackInfoOut->NextWriteLBA & 0x80000000) &&
2112 !(TrackInfoOut->TrackLength & 0x80000000) &&
2113 (Vcb->NWA < TrackInfoOut->NextWriteLBA)
2114 ) {
2115 UDFPrint((" set NWA to %x\n", TrackInfoOut->NextWriteLBA));
2116 if(Vcb->MediaClassEx != CdMediaClass_DVDpRW) {
2117 Vcb->NWA = TrackInfoOut->NextWriteLBA;
2118 } else {
2119 Vcb->NWA =
2120 TrackInfoOut->TrackStartLBA + TrackInfoOut->TrackLength - (TrackInfoOut->TrackLength ? 1 : 0);
2121 }
2122 }
2123 if(Vcb->MediaClassEx != CdMediaClass_DVDpRW &&
2124 !(TrackInfoOut->TrackLength & 0x80000000) &&
2125 TrackInfoOut->TrackLength > 1) {
2126 Vcb->LastPossibleLBA =
2127 TrackInfoOut->TrackStartLBA + TrackInfoOut->TrackLength - (TrackInfoOut->TrackLength ? 1 : 0);
2128 UDFPrint((" set LastPossibleLBA=%x\n", Vcb->LastPossibleLBA));
2129 }
2130 TrackNumber = Vcb->LastTrackNum;
2131 // quick formatted +RW returns bogus value
2132 if(Vcb->MediaClassEx == CdMediaClass_DVDpRW) {
2133 UDFPrint((" check quick formatted +RW\n"));
2134 if(Vcb->TrackMap[TrackNumber].LastLba &&
2135 !(Vcb->TrackMap[TrackNumber].LastLba & 0x80000000) &&
2136 Vcb->TrackMap[TrackNumber].LastLba < Vcb->LastPossibleLBA /*&&
2137 Vcb->TrackMap[TrackNumber].LastLba != Vcb->LastPossibleLBA*/
2138 ) {
2139 UDFPrint((" track LastLBA %x != LastPossibleLBA %x, verify\n",
2140 Vcb->TrackMap[TrackNumber].LastLba, Vcb->LastPossibleLBA));
2141
2142 if(Vcb->MRWStatus == DiscInfo_BGF_Complete) {
2143 UDFPrint((" complete MRW state\n"));
2144#ifdef _BROWSE_UDF_
2145 Vcb->LastPossibleLBA =
2146 Vcb->NWA =
2147 Vcb->LastLBA =
2148 Vcb->TrackMap[TrackNumber].LastLba;
2149 goto valid_track_length;
2150#endif // _BROWSE_UDF_
2151 } else
2152 if(Vcb->MRWStatus) {
2153 uint8* buff;
2155
2156 UDFPrint((" MRW state %x\n", Vcb->MRWStatus));
2157
2158 buff = (uint8*)DbgAllocatePoolWithTag(NonPagedPool, Vcb->WriteBlockSize, 'bNWD' );
2159 if(buff) {
2160 RC = UDFTRead(Vcb,
2161 buff,
2162 Vcb->WriteBlockSize,
2163 Vcb->TrackMap[TrackNumber].LastLba+1,
2164 &ReadBytes,
2167 if(!OS_SUCCESS(RC)) {
2168 UDFPrint((" Can't read beyond track LastLBA (%x)\n", Vcb->TrackMap[TrackNumber].LastLba+1));
2169 Vcb->LastLBA = Vcb->TrackMap[TrackNumber].LastLba;
2170 Vcb->NWA = Vcb->LastLBA+1;
2171 Vcb->TrackMap[TrackNumber].NWA_V = 1;
2172 Vcb->TrackMap[TrackNumber].NWA = Vcb->NWA;
2173 Vcb->TrackMap[TrackNumber].LastLba = Vcb->LastPossibleLBA;
2174 RC = STATUS_SUCCESS;
2175 goto valid_track_length;
2176 }
2177 }
2178 }
2179 }
2180 UDFPrint((" set track LastLBA %x\n", Vcb->LastPossibleLBA));
2181 Vcb->NWA =
2182 Vcb->LastLBA =
2183 Vcb->TrackMap[TrackNumber].LastLba =
2184 Vcb->LastPossibleLBA;
2185 }
2186valid_track_length:
2187 // Test for last empty session
2188 if((Vcb->TrackMap[TrackNumber].Session !=
2189 Vcb->TrackMap[TrackNumber-1].Session) &&
2190 (Vcb->LastSession > 1)) {
2191 // Note: some devices return negative track length
2192 if((Vcb->TrackMap[TrackNumber].LastLba <=
2193 Vcb->TrackMap[TrackNumber].FirstLba) ||
2194 (Vcb->TrackMap[TrackNumber].FirstLba ==
2195 Vcb->TrackMap[TrackNumber].NWA)) {
2196 // empty last session...
2197 Vcb->LastTrackNum--;
2198// TrackNumber--;
2199/* for(SesNum = Vcb->TrackMap[TrackNumber].Session;
2200 Vcb->TrackMap[TrackNumber].Session == SesNum;
2201 TrackNumber--) {
2202 }*/
2203 if(TrackNumber>1)
2204 Vcb->LastSession = Vcb->TrackMap[TrackNumber-1].Session;
2205 }
2206 }
2207
2208 TrackNumber = Vcb->LastTrackNum;
2209#ifdef _BROWSE_UDF_
2210 Vcb->LastLBA = min(Vcb->TrackMap[TrackNumber].LastLba, Vcb->TrackMap[TrackNumber].NWA);
2211#endif //_BROWSE_UDF_
2212
2213 if(Vcb->TrackMap[TrackNumber].NWA_V & TrkInfo_NWA_V) {
2214 UDFPrint((" NWA ok, set LastLBA to min(Last %x, NWA %x\n",
2215 Vcb->TrackMap[TrackNumber].LastLba,
2216 Vcb->TrackMap[TrackNumber].NWA));
2217 Vcb->LastLBA = min(Vcb->TrackMap[TrackNumber].LastLba, Vcb->TrackMap[TrackNumber].NWA);
2218 } else {
2219 UDFPrint((" no NWA, set LastLBA to Last %x\n", Vcb->TrackMap[TrackNumber].LastLba));
2220 Vcb->LastLBA = Vcb->TrackMap[TrackNumber].LastLba;
2221 }
2222
2223 Vcb->VCBFlags |= UDF_VCB_FLAGS_TRACKMAP;
2224 if(!PacketTrack && Vcb->MediaClassEx != CdMediaClass_DVDRAM ) {
2225 UDFPrint((" disable Raw mount\n"));
2226 Vcb->VCBFlags &= ~UDF_VCB_FLAGS_RAW_DISK;
2227 }
2228
2229try_exit: NOTHING;
2230
2231 } _SEH2_FINALLY {
2232 if(DiscInfo) MyFreePool__(DiscInfo);
2233 if(TrackInfoOut) MyFreePool__(TrackInfoOut);
2234 } _SEH2_END;
2235
2236 return RC;
2237} // end UDFReadDiscTrackInfo()
#define DiscInfo_Ses_Complete
Definition: cdrw_hw.h:2279
#define DiscInfo_Disk_OtherRW
Definition: cdrw_hw.h:2274
#define DiscInfo_Ses_Mask
Definition: cdrw_hw.h:2276
#define TrkInfo_RT
Definition: cdrw_hw.h:2420
#define DiscInfo_Disk_Complete
Definition: cdrw_hw.h:2273
#define DiscInfo_Ses_Empty
Definition: cdrw_hw.h:2277
#define TrkInfo_Trk_unknown
Definition: cdrw_hw.h:2393
#define TrkInfo_LRA_V
Definition: cdrw_hw.h:2430
#define TrkInfo_Trk_Mask
Definition: cdrw_hw.h:2385
#define DiscInfo_BGF_Complete
Definition: cdrw_hw.h:2302
#define DiscInfo_Disk_Empty
Definition: cdrw_hw.h:2271
#define DiscInfo_Disk_Erasable
Definition: cdrw_hw.h:2281
#define TrkInfo_NWA_V
Definition: cdrw_hw.h:2429
#define DiscInfo_BGF_Mask
Definition: cdrw_hw.h:2298
#define DiscInfo_Ses_Incomplete
Definition: cdrw_hw.h:2278
#define TrkInfo_Copy
Definition: cdrw_hw.h:2395
#define TrkInfo_Damage
Definition: cdrw_hw.h:2396
#define TrkInfo_Blank
Definition: cdrw_hw.h:2419
#define IOCTL_CDRW_READ_CAPACITY
Definition: cdrw_usr.h:128
struct _TRACK_INFO_BLOCK_USER_OUT * PTRACK_INFO_BLOCK_USER_OUT
struct _TRACK_INFO_BLOCK_USER_IN * PTRACK_INFO_BLOCK_USER_IN
struct _DISC_INFO_BLOCK_USER_OUT * PDISC_INFO_BLOCK_USER_OUT
#define IOCTL_CDRW_READ_TRACK_INFO
Definition: cdrw_usr.h:92
#define CdrwIsDvdOverwritable(MediaClassEx)
Definition: cdrw_usr.h:804
#define DEFAULT_LAST_LBA_BD
Definition: cdrw_usr.h:1822
#define CdMediaClass_DDCDR
Definition: cdrw_usr.h:753
#define CdMediaClass_DDCDRW
Definition: cdrw_usr.h:754
#define CdMediaClass_DDCDROM
Definition: cdrw_usr.h:752
#define IOCTL_CDRW_READ_DISC_INFO
Definition: cdrw_usr.h:93
static unsigned char buff[32768]
Definition: fatten.c:17
OSSTATUS UDFTRead(IN void *_Vcb, IN void *Buffer, IN SIZE_T Length, IN uint32 LBA, OUT PSIZE_T ReadBytes, IN uint32 Flags)
Definition: phys_lib.cpp:596
DISC_STATUS_INFO_USER_OUT Status
Definition: cdrw_usr.h:630
ULONG LogicalBlockAddress
Definition: cdrw_hw.h:1471
union _TRACK_INFO_BLOCK_USER_OUT::@913 TrackParam
union _TRACK_INFO_BLOCK_USER_OUT::@914 DataParam
#define UDF_VCB_FLAGS_TRACKMAP
Definition: udf_common.h:473

Referenced by UDFGetDiskInfo().

◆ UDFReallocTrackMap()

OSSTATUS UDFReallocTrackMap ( IN PVCB  Vcb,
IN uint32  TrackNum 
)

Definition at line 69 of file phys_lib.cpp.

73{
74#ifdef _BROWSE_UDF_
75 if(Vcb->TrackMap) {
76 MyFreePool__(Vcb->TrackMap);
77 Vcb->TrackMap = NULL;
78 }
79 Vcb->TrackMap = (PUDFTrackMap)
80 MyAllocatePool__(NonPagedPool, TrackNum*sizeof(UDFTrackMap));
81 if(!Vcb->TrackMap) {
83 }
84#endif //_BROWSE_UDF_
85 RtlZeroMemory(Vcb->TrackMap,TrackNum*sizeof(UDFTrackMap));
86 return STATUS_SUCCESS;
87} // end UDFReallocTrackMap()
struct _UDFTrackMap * PUDFTrackMap

Referenced by UDFReadAndProcessFullToc(), UDFReadDiscTrackInfo(), and UDFUseStandard().

◆ UDFRecoverFromError()

OSSTATUS UDFRecoverFromError ( IN PVCB  Vcb,
IN BOOLEAN  WriteOp,
IN OSSTATUS  status,
IN uint32  Lba,
IN uint32  BCount,
IN OUT uint32 retry 
)

Definition at line 1283 of file phys_lib.cpp.

1291{
1293 LARGE_INTEGER delay;
1294// OSSTATUS RC;
1295 uint32 i;
1296 BOOLEAN UpdateBB = FALSE;
1297
1298 if(!(*retry) ||
1299 !(Vcb->VCBFlags & UDF_VCB_FLAGS_OUR_DEVICE_DRIVER) ||
1300 (Vcb->FsDeviceType != FILE_DEVICE_CD_ROM_FILE_SYSTEM))
1301 return status;
1302 (*retry)--;
1303 // allocate tmp buffer
1304 _SEH2_TRY {
1305 if(!Vcb->Error) {
1306 if(!(Vcb->Error = (PGET_LAST_ERROR_USER_OUT)
1309 }
1311 UDFPrint(("Error recovery: STATUS_NO_SUCH_DEVICE, die.....\n"));
1314 }
1315
1316#ifdef _UDF_STRUCTURES_H_
1317 if(status == STATUS_NO_MEDIA_IN_DEVICE && !Vcb->EjectWaiter) {
1318 UDFPrint(("Error recovery: STATUS_NO_MEDIA_IN_DEVICE, prevent further remount.....\n"));
1319 // Make sure, that volume will never be quick-remounted
1320 // It is very important for ChkUdf utility and
1321 // some CD-recording libraries
1322 Vcb->SerialNumber--;
1324 }
1325#endif //_UDF_STRUCTURES_H_
1326
1327 Error = Vcb->Error;
1328 UDFPhSendIOCTL( IOCTL_CDRW_GET_LAST_ERROR, Vcb->TargetDeviceObject,
1329 NULL,0,
1331 TRUE,NULL);
1332 UDFPrint(("SK=%x ASC=%x, ASCQ=%x, IE=%x\n",
1333 Error->SenseKey, Error->AdditionalSenseCode, Error->AdditionalSenseCodeQualifier, Error->LastError));
1334 // check for Long Write In Progress
1335 if( ((Error->SenseKey == SCSI_SENSE_NOT_READY) &&
1336 (Error->AdditionalSenseCode == SCSI_ADSENSE_LUN_NOT_READY) &&
1337 (Error->AdditionalSenseCodeQualifier == SCSI_SENSEQ_LONG_WRITE_IN_PROGRESS)) ) {
1338 // we should wait...
1339 if(WriteOp) {
1340 if((*retry) == UDF_WRITE_MAX_RETRY-1) {
1341 UDFPrint(("Error recovery: reserve retry count for write retries\n"));
1342 (*retry) = UDF_WRITE_MAX_RETRY*3;
1343 } else
1344 if((*retry) == UDF_WRITE_MAX_RETRY) {
1345 UDFPrint(("Error recovery: jump over UDF_WRITE_MAX_RETRY\n"));
1346 (*retry)--;
1347 }
1348 delay.QuadPart = -500000; // 0.05 sec
1350 if(WriteOp && ((*retry) > UDF_WRITE_MAX_RETRY-1)) {
1351 UDFPrint(("Error recovery: simple write retry with delay\n"));
1353 }
1354 } else {
1355 delay.QuadPart = -500000; // 0.05 sec
1357 if((*retry) == UDF_WRITE_MAX_RETRY-1) {
1358 UDFPrint(("Error recovery: retry read after small delay\n"));
1360 }
1361 }
1362 UDFPrint(("Error recovery: sync cache\n"));
1363 // ...flush device cache...
1365 // wait again & retry
1366 delay.QuadPart = -1000000; // 0.1 sec
1368#ifdef _UDF_STRUCTURES_H_
1369 if(Vcb->BGWriters) (*retry)++;
1370#endif //_UDF_STRUCTURES_H_
1372 } else
1373 // check for Long Write In Progress
1374 if((Error->SenseKey == SCSI_SENSE_NOT_READY) &&
1375 (Error->AdditionalSenseCode == SCSI_ADSENSE_LUN_NOT_READY) &&
1376 ((Error->AdditionalSenseCodeQualifier == SCSI_SENSEQ_FORMAT_IN_PROGRESS) ||
1377 (Error->AdditionalSenseCodeQualifier == SCSI_SENSEQ_BECOMING_READY) ||
1378 (Error->AdditionalSenseCodeQualifier == SCSI_SENSEQ_OPERATION_IN_PROGRESS) ) ) {
1379 // we should wait & retry
1380 UDFPrint(("Error recovery: op. in progress, waiting 0.3 sec\n"));
1381 delay.QuadPart = -3000000; // 0.3 sec
1383#ifdef _UDF_STRUCTURES_H_
1384 if(Vcb->BGWriters) (*retry)++;
1385#endif //_UDF_STRUCTURES_H_
1386 Vcb->SyncCacheState = SYNC_CACHE_RECOVERY_ATTEMPT;
1388 } else
1389 // check for non empty cache special case
1390 if((Error->SenseKey == SCSI_SENSE_ILLEGAL_REQUEST) &&
1391 (Error->AdditionalSenseCode == SCSI_ADSENSE_INVALID_CMD_SEQUENCE)) {
1392 // we should wait & retry
1393 if(!WriteOp) {
1394 UDFPrint(("Error recovery: invalid command sequence on read\n"));
1395 delay.QuadPart = -1000000; // 0.1 sec
1397 UDFPrint(("Error recovery: sync cache\n"));
1398 // ...flush device cache...
1400 // wait again & retry
1401 delay.QuadPart = -1000000; // 0.1 sec
1403#ifdef _UDF_STRUCTURES_H_
1404 if(Vcb->BGWriters) (*retry)++;
1405#endif //_UDF_STRUCTURES_H_
1407 }
1408 goto reinit_sector_mode;
1409 } else
1410 // check for Bus Reset (sometimes it happends...)
1411 if((Error->SenseKey == SCSI_SENSE_UNIT_ATTENTION) &&
1412 (Error->AdditionalSenseCode == SCSI_ADSENSE_BUS_RESET) ) {
1413 // we should wait
1414 UDFPrint(("Error recovery: bus reset...\n"));
1415 Vcb->MediaChangeCount = Error->MediaChangeCount;
1416 delay.QuadPart = -1000000; // 0.1 sec
1418 // reset driver
1419 UDFResetDeviceDriver(Vcb, Vcb->TargetDeviceObject, FALSE);
1420 delay.QuadPart = -1000000; // 0.1 sec
1422 // lock it
1423/* ((PPREVENT_MEDIA_REMOVAL_USER_IN)(Error))->PreventMediaRemoval = TRUE;
1424 UDFPhSendIOCTL( IOCTL_STORAGE_MEDIA_REMOVAL,
1425 Vcb->TargetDeviceObject,
1426 Error,sizeof(PREVENT_MEDIA_REMOVAL_USER_IN),
1427 NULL,0,
1428 FALSE,NULL);
1429 delay.QuadPart = -1000000; // 0.1 sec
1430 KeDelayExecutionThread(KernelMode, FALSE, &delay);*/
1431
1432 // reinit write mode the following is performed inside UDFResetDeviceDriver()
1433 //Vcb->LastModifiedTrack = 0;
1434 //Vcb->OPCDone = FALSE;
1435
1436reinit_sector_mode:
1437 // reinit sector mode
1438 Vcb->LastModifiedTrack = 0;
1439 UDFPrepareForWriteOperation(Vcb, Lba, BCount);
1441 } else
1442 // check for Illegal Sector Mode.
1443 // We can get this error 'cause of 2 reasons:
1444 // a) Bus reset occured. We should reinit
1445 // b) CopyProtection settings missmatch
1446 // c) preblems with DNA of firmware developer, some TEACs fall into such state
1447 // after failed streaming read
1448 if((Error->SenseKey == SCSI_SENSE_ILLEGAL_REQUEST) &&
1449 (Error->AdditionalSenseCode == SCSI_ADSENSE_ILLEGAL_MODE_FOR_THIS_TRACK)) {
1450bad_rw_seek_recovery:
1451 if(WriteOp) {
1452
1453 if((*retry) <= 1) {
1454 // Variate CopyProtection...
1455 for(i=Vcb->FirstTrackNum; i<=Vcb->LastTrackNum; i++) {
1456 if((Vcb->TrackMap[i].FirstLba > Lba) ||
1457 (Vcb->TrackMap[i].LastLba < Lba))
1458 continue;
1459 /* if(Vcb->TrackMap[i].Flags & TrackMap_CopyBit_variated)
1460 // Last chance....
1461 goto reinit_sector_mode;*/
1462
1463 // check if we have successuflly completed WriteOp
1464 // using Variation.
1465 // We should not variate these bits again in this case.
1466 if(Vcb->TrackMap[i].Flags & TrackMap_Use_variation)
1467 break;
1468 Vcb->TrackMap[i].Flags &= ~TrackMap_Try_variation;
1469 /* if((Vcb->TrackMap[i].Flags & TrackMap_Try_variation) &&
1470 (Vcb->TrackMap[i].Flags & (TrackMap_AllowCopyBit_variated |
1471 TrackMap_CopyBit_variated)))
1472 break;*/
1473 /* if(Vcb->TrackMap[i].Flags & TrackMap_Use_variation)
1474 break;*/
1475 Vcb->TrackMap[i].Flags |= TrackMap_Try_variation;
1476 // Try variation.
1477 if(!(Vcb->TrackMap[i].Flags ^= TrackMap_AllowCopyBit_variated))
1478 Vcb->TrackMap[i].Flags ^= TrackMap_CopyBit_variated;
1479 if(Vcb->TrackMap[i].Flags & (TrackMap_AllowCopyBit_variated |
1481 (*retry) = 1;
1482 } else {
1483 Vcb->TrackMap[i].Flags &= ~TrackMap_Try_variation;
1484 }
1485 // reinit sector mode
1486 Vcb->LastModifiedTrack = 0;
1487 UDFPrepareForWriteOperation(Vcb, Lba, BCount);
1488 break;
1489 }
1490 } else {
1491 // Reinit...
1492//reinit_sector_mode:
1493 // we should wait
1494 delay.QuadPart = -1000000; // 0.1 sec
1496 // reinit sector mode
1497 goto reinit_sector_mode;
1498/*
1499 Vcb->LastModifiedTrack = 0;
1500 UDFPrepareForWriteOperation(Vcb, Lba, BCount);
1501 try_return(status = STATUS_SUCCESS);
1502*/
1503 }
1504 } else
1505 if((Vcb->CompatFlags & UDF_VCB_IC_BAD_RW_SEEK) &&
1506 (Vcb->IncrementalSeekState != INCREMENTAL_SEEK_DONE)) {
1507 UDFPrint(("Using incremental seek workaround...\n"));
1508 Vcb->IncrementalSeekState = INCREMENTAL_SEEK_WORKAROUND;
1510 } else {
1511 UDFPrint(("Seems to be BB @ %x\n", Lba));
1512 UpdateBB = TRUE;
1513 }
1514 } else
1515 if((Error->SenseKey == SCSI_SENSE_ILLEGAL_REQUEST) &&
1516 (Error->AdditionalSenseCode == SCSI_ADSENSE_INVALID_SESSION_MODE)) {
1517 if(WriteOp &&
1518 (Vcb->SavedFeatures & CDRW_FEATURE_STREAMING) &&
1519 Lba+BCount <= Vcb->LastLBA+1) {
1520 UDFPrint(("bad Session in streaming mode. Lba %x, try fix-up\n", Lba));
1521 // ...flush device cache...
1523 // we should wait
1524 delay.QuadPart = -10000000; // 1 sec
1527 }
1528 } else
1529 if((Error->LastError == CDRW_ERR_WRITE_IN_PROGRESS_BUSY) ||
1531 delay.QuadPart = -5000000; // 0.5 sec
1532 UDFPrint(("CDRW_ERR_WRITE_IN_PROGRESS_BUSY || STATUS_DEVICE_BUSY\n"));
1534#ifdef _UDF_STRUCTURES_H_
1535 if(Vcb->BGWriters) (*retry)++;
1536#endif //_UDF_STRUCTURES_H_
1538 } else
1539 // some devices (SONY) return such a strange sequence....
1540 if( ((Error->SenseKey == SCSI_SENSE_ILLEGAL_REQUEST) &&
1541 (Error->AdditionalSenseCode == SCSI_ADSENSE_INVALID_CDB)) &&
1542 WriteOp) {
1543 // reinit write mode
1544 Vcb->LastModifiedTrack = 0;
1545 UDFPrepareForWriteOperation(Vcb, Lba, BCount);
1547 } else
1548 // No seek on Read... to morgue, I'm afraid
1549 if((Error->SenseKey == SCSI_SENSE_MEDIUM_ERROR) /*&&
1550 ((Error->AdditionalSenseCode == SCSI_ADSENSE_CD_READ_ERROR) ||
1551 (Error->AdditionalSenseCode == SCSI_ADSENSE_NO_SENSE) ||
1552 (Error->AdditionalSenseCode == SCSI_ADSENSE_FORMAT_CORRUPTED) ||
1553 (Error->AdditionalSenseCode == SCSI_ADSENSE_SEEK_ERROR))*/ &&
1554 !WriteOp) {
1555 if(Error->AdditionalSenseCode == SCSI_ADSENSE_SEEK_ERROR) {
1556 UDFPrint(("Seek error\n"));
1557 if(Vcb->CompatFlags & UDF_VCB_IC_BAD_RW_SEEK) {
1558 UDFPrint(("try recovery\n"));
1559 goto bad_rw_seek_recovery;
1560 }
1561 UDFPrint(("map error to STATUS_NONEXISTENT_SECTOR\n"));
1563 }
1564 UDFPrint(("Seems to be BB @ %x (read 2)\n", Lba));
1565 UpdateBB = TRUE;
1566 } else
1567 // handle invalid block address
1568 if( ((Error->SenseKey == SCSI_SENSE_ILLEGAL_REQUEST) &&
1569 (Error->AdditionalSenseCode == SCSI_ADSENSE_ILLEGAL_BLOCK)) ) {
1570 if(!WriteOp &&
1571 (Vcb->SavedFeatures & CDRW_FEATURE_STREAMING) &&
1572 Lba+BCount <= Vcb->LastLBA+1) {
1573 UDFPrint(("bad LBA %x in streaming mode, try fix-up\n", Lba));
1574 // ...flush device cache...
1577 }
1578
1579 if((Lba+BCount >= Vcb->LastLBA) &&
1580 (Vcb->MRWStatus == DiscInfo_BGF_Interrupted)) {
1581 UDFPrint(("stupid drive, cannot read beyond formatted area on DiscInfo_BGF_Interrupted\n"));
1582 UpdateBB = FALSE;
1584 }
1585 // prevent Bad Block Bitmap modification
1586 }
1587
1588try_exit: NOTHING;
1589
1590 } _SEH2_FINALLY {
1591#ifdef UDF_DBG
1592 if(OS_SUCCESS(status)) {
1593 UDFPrint(("Retry\n"));
1594 }
1595#endif //UDF_DBG
1596 } _SEH2_END;
1597 if(!OS_SUCCESS(status)) {
1598 if((Vcb->MountPhErrorCount != (ULONG)-1) &&
1599 (Vcb->MountPhErrorCount < 0x7fffffff)) {
1600 Vcb->MountPhErrorCount++;
1601 }
1602//#ifdef _UDF_STRUCTURES_H_
1603 if(UpdateBB && (BCount == 1)) {
1604 uint32* bm;
1605 if(!(bm = (uint32*)(Vcb->BSBM_Bitmap))) {
1606 bm = (uint32*)(Vcb->BSBM_Bitmap = (int8*)DbgAllocatePoolWithTag(NonPagedPool, (i = (Vcb->LastPossibleLBA+1+7)>>3), 'mNWD' ));
1607 if(bm) {
1608 RtlZeroMemory(bm, i);
1609 } else {
1610 UDFPrint(("Can't alloc BSBM for %x blocks\n", Vcb->LastPossibleLBA));
1611 }
1612 }
1613 if(bm) {
1614 UDFSetBit(bm, Lba);
1615 UDFPrint(("Set BB @ %#x\n", Lba));
1616 }
1617#ifdef _BROWSE_UDF_
1618 bm = (uint32*)(Vcb->FSBM_Bitmap);
1619 if(bm) {
1620 UDFSetUsedBit(bm, Lba);
1621 UDFPrint(("Set BB @ %#x as used\n", Lba));
1622 }
1623#endif //_BROWSE_UDF_
1624 }
1625//#endif //_UDF_STRUCTURES_H_
1626 }
1627 return status;
1628} // end UDFRecoverFromError()
#define SCSI_ADSENSE_ILLEGAL_BLOCK
Definition: cdrw_hw.h:1264
#define SCSI_SENSEQ_OPERATION_IN_PROGRESS
Definition: cdrw_hw.h:1317
#define SCSI_ADSENSE_SEEK_ERROR
Definition: cdrw_hw.h:1232
#define SCSI_ADSENSE_INVALID_CDB
Definition: cdrw_hw.h:1265
#define SCSI_SENSE_MEDIUM_ERROR
Definition: cdrw_hw.h:1190
#define SCSI_ADSENSE_INVALID_CMD_SEQUENCE
Definition: cdrw_hw.h:1270
#define SCSI_SENSEQ_BECOMING_READY
Definition: cdrw_hw.h:1313
#define SCSI_SENSE_ILLEGAL_REQUEST
Definition: cdrw_hw.h:1192
#define SCSI_SENSE_UNIT_ATTENTION
Definition: cdrw_hw.h:1193
#define SCSI_ADSENSE_INVALID_SESSION_MODE
Definition: cdrw_hw.h:1271
#define SCSI_ADSENSE_ILLEGAL_MODE_FOR_THIS_TRACK
Definition: cdrw_hw.h:1278
#define SCSI_ADSENSE_BUS_RESET
Definition: cdrw_hw.h:1289
#define TrackMap_AllowCopyBit_variated
Definition: cdrw_usr.h:1637
#define CDRW_ERR_WRITE_IN_PROGRESS_BUSY
Definition: cdrw_usr.h:1691
#define TrackMap_CopyBit_variated
Definition: cdrw_usr.h:1638
#define KeDelayExecutionThread(mode, foo, t)
Definition: env_spec_w32.h:484
#define KernelMode
Definition: asm.h:34
OSSTATUS UDFPrepareForWriteOperation(IN PVCB Vcb, IN uint32 Lba, IN uint32 BCount)
Definition: phys_lib.cpp:893
Definition: ps.c:97
#define UDF_VCB_FLAGS_UNSAFE_IOCTL
Definition: udf_common.h:488
#define UDF_VCB_FLAGS_DEAD
Definition: udf_common.h:489
#define UDFSetBit(arr, bit)
Definition: udf_info.h:1181
#define UDFSetUsedBit(arr, bit)
Definition: udf_info.h:1200
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
#define STATUS_NONEXISTENT_SECTOR
Definition: udferr_usr.h:143
#define STATUS_NO_MEDIA_IN_DEVICE
Definition: udferr_usr.h:141
#define STATUS_DEVICE_BUSY
Definition: udferr_usr.h:129
#define STATUS_BUFFER_ALL_ZEROS
Definition: udferr_usr.h:125

Referenced by UDFPrepareForWriteOperation(), UDFTRead(), and UDFTWrite().

◆ UDFResetDeviceDriver()

OSSTATUS UDFResetDeviceDriver ( IN PVCB  Vcb,
IN PDEVICE_OBJECT  TargetDeviceObject,
IN BOOLEAN  Unlock 
)

Definition at line 4199 of file phys_lib.cpp.

4204{
4207 OSSTATUS RC;
4208 if(!tmp)
4211 tmp->UnlockTray = (Unlock ? 1 : 0);
4212 tmp->MagicWord = 0x3a6 | (Unlock ? 1 : 0);
4214 tmp, sizeof(CDRW_RESET_DRIVER_USER_IN), NULL, 0, TRUE,NULL);
4215 if(Vcb) {
4216 Vcb->LastReadTrack = 0;
4217 Vcb->LastModifiedTrack = 0;
4218 Vcb->OPCDone = FALSE;
4219 if((Vcb->VCBFlags & UDF_VCB_FLAGS_USE_CAV) &&
4220 Vcb->TargetDeviceObject) {
4221 // limit both read & write speed to last write speed for CAV mode
4222 // some drives damage data when speed is adjusted during recording process
4223 // even in packet mode
4225 }
4227 }
4228
4229 MyFreePool__(tmp);
4230 return RC;
4231} // end UDFResetDeviceDriver()
#define IOCTL_CDRW_RESET_DRIVER_EX
Definition: cdrw_usr.h:122
struct _CDRW_RESET_DRIVER_USER_IN * PCDRW_RESET_DRIVER_USER_IN
IN OUT PVCB IN PDEVICE_OBJECT TargetDeviceObject
Definition: fatprocs.h:1674
@ Unlock
Definition: ntsecapi.h:294

Referenced by UDFCommonCleanup(), UDFDoDismountSequence(), UDFGetDiskInfo(), UDFMountVolume(), and UDFRecoverFromError().

◆ UDFSetCaching()

NTSTATUS UDFSetCaching ( IN PVCB  Vcb)

Definition at line 4263 of file phys_lib.cpp.

4266{
4267#pragma pack(push,1)
4268 struct {
4271 CHAR Padding [16];
4272 } CachingPage;
4273
4274 struct {
4277 CHAR Padding [16];
4278 } RecoveryPage;
4279#ifdef _MSC_VER
4280#pragma pack(pop,1)
4281#else
4282#pragma pack(pop)
4283#endif
4284
4285 MODE_SENSE_USER_IN ModeSenseCtl;
4286 OSSTATUS RC;
4287
4288 UDFPrint(("UDFSetCaching:\n"));
4289
4290 ModeSenseCtl.PageCode.Byte = MODE_PAGE_ERROR_RECOVERY;
4291 RC = UDFPhSendIOCTL(IOCTL_CDRW_MODE_SENSE, Vcb->TargetDeviceObject,
4292 &ModeSenseCtl,sizeof(ModeSenseCtl),
4293 (PVOID)&RecoveryPage,sizeof(RecoveryPage),
4294 FALSE, NULL);
4295 if(OS_SUCCESS(RC)) {
4296 UDFPrint((" Error recovery page:\n"
4297 "PageCode %d\n"
4298 "PageLength %d\n"
4299
4300 "DCRBit %d\n"
4301 "DTEBit %d\n"
4302 "PERBit %d\n"
4303 "EERBit %d\n"
4304 "RCBit %d\n"
4305 "TBBit %d\n"
4306 "ARRE %d\n"
4307 "AWRE %d\n"
4308
4309 "ReadRetryCount %d\n"
4310 "CorrectionSpan %d\n"
4311 "HeadOffsetCount %d\n"
4312 "DataStrobOffsetCount %d\n"
4313
4314 "ErrorRecoveryParam2.Fields.EMCDR %d\n"
4315
4316 "WriteRetryCount %d\n",
4317
4318 RecoveryPage.Data.PageCode,
4319 RecoveryPage.Data.PageLength,
4320
4321 RecoveryPage.Data.ErrorRecoveryParam.Fields.DCRBit,
4322 RecoveryPage.Data.ErrorRecoveryParam.Fields.DTEBit,
4323 RecoveryPage.Data.ErrorRecoveryParam.Fields.PERBit,
4324 RecoveryPage.Data.ErrorRecoveryParam.Fields.EERBit,
4325 RecoveryPage.Data.ErrorRecoveryParam.Fields.RCBit,
4326 RecoveryPage.Data.ErrorRecoveryParam.Fields.TBBit,
4327 RecoveryPage.Data.ErrorRecoveryParam.Fields.ARRE,
4328 RecoveryPage.Data.ErrorRecoveryParam.Fields.AWRE,
4329
4330 RecoveryPage.Data.ReadRetryCount,
4331 RecoveryPage.Data.CorrectionSpan,
4332 RecoveryPage.Data.HeadOffsetCount,
4333 RecoveryPage.Data.DataStrobOffsetCount,
4334
4335 RecoveryPage.Data.ErrorRecoveryParam2.Fields.EMCDR,
4336
4337 RecoveryPage.Data.WriteRetryCount
4338
4339 ));
4340 }
4341
4342 ModeSenseCtl.PageCode.Byte = MODE_PAGE_CACHING;
4343 RC = UDFPhSendIOCTL(IOCTL_CDRW_MODE_SENSE, Vcb->TargetDeviceObject,
4344 &ModeSenseCtl,sizeof(ModeSenseCtl),
4345 (PVOID)&CachingPage,sizeof(CachingPage),
4346 FALSE, NULL);
4347 if(!OS_SUCCESS(RC)) {
4348 return RC;
4349 }
4350
4351 UDFPrint((" Caching page:\n"
4352 "PageCode %d\n"
4353 "PageLength %d\n"
4354 "ReadDisableCache %d\n"
4355 "MultiplicationFactor %d\n"
4356 "WriteCacheEnable %d\n"
4357 "WriteRetensionPriority %d\n"
4358 "ReadRetensionPriority %d\n",
4359
4360 CachingPage.Data.PageCode,
4361 CachingPage.Data.PageLength,
4362 CachingPage.Data.ReadDisableCache,
4363 CachingPage.Data.MultiplicationFactor,
4364 CachingPage.Data.WriteCacheEnable,
4365 CachingPage.Data.WriteRetensionPriority,
4366 CachingPage.Data.ReadRetensionPriority
4367 ));
4368
4369 RtlZeroMemory(&CachingPage.Header, sizeof(CachingPage.Header));
4370 CachingPage.Data.PageCode = MODE_PAGE_CACHING;
4371 CachingPage.Data.PageSavable = 0;
4372 if( CachingPage.Data.ReadDisableCache ||
4373 !CachingPage.Data.WriteCacheEnable) {
4374 CachingPage.Data.ReadDisableCache = 0;
4375 CachingPage.Data.WriteCacheEnable = 1;
4376 RC = UDFPhSendIOCTL(IOCTL_CDRW_MODE_SELECT, Vcb->TargetDeviceObject,
4377 (PVOID)&CachingPage,sizeof(CachingPage.Header) + 2 + CachingPage.Data.PageLength,
4378 NULL,0,
4379 FALSE, NULL);
4380 } else {
4381 RC = STATUS_SUCCESS;
4382 }
4383 UDFPrint(("UDFSetCaching: %x\n", RC));
4384 return RC;
4385} // end UDFSetCaching()
#define MODE_PAGE_CACHING
Definition: cdrw_hw.h:846
#define MODE_PAGE_ERROR_RECOVERY
Definition: cdrw_hw.h:842
#define IOCTL_CDRW_MODE_SENSE
Definition: cdrw_usr.h:104
#define IOCTL_CDRW_MODE_SELECT
Definition: cdrw_usr.h:105
Definition: Header.h:9
char CHAR
Definition: xmlstorage.h:175

Referenced by UDFGetDiskInfo(), and UDFResetDeviceDriver().

◆ UDFSetMRWMode()

NTSTATUS UDFSetMRWMode ( IN PVCB  Vcb)

Definition at line 811 of file phys_lib.cpp.

814{
815 GET_MRW_MODE_USER_OUT MRWPage;
816 OSSTATUS RC;
817
818 if(Vcb->MediaClassEx != CdMediaClass_CDRW)
819 return STATUS_SUCCESS;
820//#ifdef _BROWSE_UDF_
821 if(Vcb->CompatFlags & UDF_VCB_IC_MRW_ADDR_PROBLEM)
822 return STATUS_SUCCESS;
823//#endif //_BROWSE_UDF_
824
825 if(!Vcb->MRWStatus) {
826 UDFPrint(("Non-MRW disk. Skip setting MRW_MODE\n"));
827 return STATUS_SUCCESS;
828 }
829 UDFPrint(("try set MRW_MODE\n"));
830 RC = UDFPhSendIOCTL(IOCTL_CDRW_GET_MRW_MODE, Vcb->TargetDeviceObject,
831 NULL,0,
832 (PVOID)&MRWPage,sizeof(MRWPage),
833 FALSE, NULL);
834 if(!NT_SUCCESS(RC)) {
835 return RC;
836 }
837 UDFPrint(("GET_MRW_MODE ok (current %x)\n", MRWPage.AddressMode));
838 MRWPage.AddressMode = Vcb->MRWStatus ? 0 : MrwPage_use_GAA;
839 UDFPrint(("SET_MRW_MODE %x\n", MRWPage.AddressMode));
840 RC = UDFPhSendIOCTL(IOCTL_CDRW_SET_MRW_MODE, Vcb->TargetDeviceObject,
841 (PVOID)&MRWPage,sizeof(MRWPage),
842 NULL,0,
843 FALSE, NULL);
844 UDFPrint(("SET_MRW_MODE status %x\n", RC));
845
846 return STATUS_SUCCESS;
847} // end UDFSetMRWMode()
#define MrwPage_use_GAA
Definition: cdrw_hw.h:3192
#define IOCTL_CDRW_SET_MRW_MODE
Definition: cdrw_usr.h:126
#define IOCTL_CDRW_GET_MRW_MODE
Definition: cdrw_usr.h:125
UCHAR AddressMode
Definition: cdrw_hw.h:3194

Referenced by UDFPrepareForReadOperation(), UDFPrepareForWriteOperation(), and UDFReadDiscTrackInfo().

◆ UDFSetSpeeds()

OSSTATUS UDFSetSpeeds ( IN PVCB  Vcb)

Definition at line 4234 of file phys_lib.cpp.

4237{
4238 OSSTATUS RC;
4239
4240 RtlZeroMemory(&(Vcb->SpeedBuf), sizeof(SET_CD_SPEED_EX_USER_IN));
4241 if(Vcb->VCBFlags & UDF_VCB_FLAGS_USE_CAV) {
4242 Vcb->SpeedBuf.RotCtrl = CdSpeed_RotCtrl_CAV;
4243 Vcb->CurSpeed =
4244 Vcb->SpeedBuf.ReadSpeed =
4245 Vcb->SpeedBuf.WriteSpeed = Vcb->MaxWriteSpeed;
4246 } else {
4247 Vcb->SpeedBuf.ReadSpeed = Vcb->CurSpeed;
4248 Vcb->SpeedBuf.WriteSpeed = Vcb->MaxWriteSpeed;
4249 }
4250 UDFPrint((" UDFSetSpeeds: set speed to %s %dX/%dX\n",
4251 (Vcb->VCBFlags & UDF_VCB_FLAGS_USE_CAV) ? "CAV" : "CLV",
4252 Vcb->SpeedBuf.ReadSpeed / 176,
4253 Vcb->SpeedBuf.WriteSpeed / 176));
4255 Vcb->TargetDeviceObject,
4256 &(Vcb->SpeedBuf),sizeof(SET_CD_SPEED_EX_USER_IN),
4257 NULL,0,TRUE,NULL);
4258 UDFPrint(("UDFSetSpeeds: %x\n", RC));
4259 return RC;
4260} // end UDFSetSpeeds()

Referenced by UDFGetDiskInfo(), and UDFResetDeviceDriver().

◆ UDFSyncCache()

NTSTATUS UDFSyncCache ( IN PVCB  Vcb)

Definition at line 52 of file phys_lib.cpp.

55{
56 UDFPrint(("UDFSyncCache:\n"));
57 OSSTATUS RC;
58 RC = UDFPhSendIOCTL( IOCTL_CDRW_SYNC_CACHE, Vcb->TargetDeviceObject,
59 NULL,0, NULL,0, FALSE, NULL);
60 if(OS_SUCCESS(RC)) {
61 // clear LAST_WRITE flag
62 Vcb->VCBFlags &= ~UDF_VCB_LAST_WRITE;
63 }
64 return RC;
65} // end UDFSyncCache()
#define IOCTL_CDRW_SYNC_CACHE
Definition: cdrw_usr.h:81

Referenced by UDFPrepareForReadOperation(), UDFRecoverFromError(), and UDFUpdateNWA().

◆ UDFTRead()

OSSTATUS UDFTRead ( IN void _Vcb,
IN void Buffer,
IN SIZE_T  Length,
IN uint32  LBA,
OUT PSIZE_T  ReadBytes,
IN uint32  Flags 
)

Definition at line 596 of file phys_lib.cpp.

604{
605 uint32 rLba;
607 uint32 retry;
608 PVCB Vcb = (PVCB)_Vcb;
609 uint32 BCount = Length >> Vcb->BlockSizeBits;
610 uint32 i;
611#ifdef _BROWSE_UDF_
612 PEXTENT_MAP RelocExtent;
613 PEXTENT_MAP RelocExtent_saved = NULL;
614 BOOLEAN res_acq = FALSE;
615// LARGE_INTEGER delay;
616 Vcb->VCBFlags |= UDF_VCB_SKIP_EJECT_CHECK;
617
618 ASSERT(Buffer);
619
620 (*ReadBytes) = 0;
621
622 if(Vcb->VCBFlags & UDF_VCB_FLAGS_DEAD)
624
625 RelocExtent = UDFRelocateSectors(Vcb, LBA, BCount);
626 if(!RelocExtent) return STATUS_INSUFFICIENT_RESOURCES;
627
628 _SEH2_TRY {
629
630 if(!(Flags & PH_IO_LOCKED)) {
631 UDFAcquireResourceExclusive(&(Vcb->IoResource), TRUE);
632 res_acq = TRUE;
633 }
634
635 if(RelocExtent == UDF_NO_EXTENT_MAP) {
636 rLba = LBA;
637 if(rLba >= (Vcb->CDR_Mode ? Vcb->NWA : Vcb->LastLBA + 1)) {
640 }
641 retry = UDF_WRITE_MAX_RETRY;
642retry_1:
643 RC = UDFPrepareForReadOperation(Vcb, rLba, Length >> Vcb->BlockSizeBits);
644 if(!OS_SUCCESS(RC)) try_return(RC);
645 rLba = UDFFixFPAddress(Vcb, rLba);
646#else
647 rLba = LBA;
648 retry = UDF_WRITE_MAX_RETRY;
649retry_1:
650 RC = UDFPrepareForReadOperation(Vcb, rLba, Length >> Vcb->BlockSizeBits);
651 if(!OS_SUCCESS(RC)) return RC; // this is for !_BROWSE_UDF only
652#endif //_BROWSE_UDF_
653 if(Flags & PH_VCB_IN_RETLEN) {
654 (*ReadBytes) = (SIZE_T)Vcb;
655 }
656 RC = UDFPhReadSynchronous(Vcb->TargetDeviceObject, Buffer, Length,
657 ((uint64)rLba) << Vcb->BlockSizeBits, ReadBytes, Flags);
658 Vcb->VCBFlags &= ~UDF_VCB_LAST_WRITE;
659#ifdef _BROWSE_UDF_
660 Vcb->VCBFlags |= UDF_VCB_SKIP_EJECT_CHECK;
661#endif //_BROWSE_UDF_
662 if(!OS_SUCCESS(RC) &&
663 OS_SUCCESS(RC = UDFRecoverFromError(Vcb, FALSE, RC, rLba, BCount, &retry)) ) {
664 if(RC != STATUS_BUFFER_ALL_ZEROS) {
665 goto retry_1;
666 }
668 (*ReadBytes) = Length;
669 RC = STATUS_SUCCESS;
670 }
671#ifdef _BROWSE_UDF_
672 try_return(RC);
673 }
674 // read according to relocation table
675 RelocExtent_saved = RelocExtent;
676 for(i=0; RelocExtent->extLength; i++, RelocExtent++) {
677 SIZE_T _ReadBytes;
678 rLba = RelocExtent->extLocation;
679 if(rLba >= (Vcb->CDR_Mode ? Vcb->NWA : Vcb->LastLBA + 1)) {
680 RtlZeroMemory(Buffer, _ReadBytes = RelocExtent->extLength);
681 RC = STATUS_SUCCESS;
682 goto TR_continue;
683 }
684 BCount = RelocExtent->extLength>>Vcb->BlockSizeBits;
685 retry = UDF_WRITE_MAX_RETRY;
686retry_2:
687 RC = UDFPrepareForReadOperation(Vcb, rLba, RelocExtent->extLength >> Vcb->BlockSizeBits);
688 if(!OS_SUCCESS(RC)) break;
689 rLba = UDFFixFPAddress(Vcb, rLba);
690 if(Flags & PH_VCB_IN_RETLEN) {
691 _ReadBytes = (SIZE_T)Vcb;
692 }
693 RC = UDFPhReadSynchronous(Vcb->TargetDeviceObject, Buffer, RelocExtent->extLength,
694 ((uint64)rLba) << Vcb->BlockSizeBits, &_ReadBytes, Flags);
695 Vcb->VCBFlags &= ~UDF_VCB_LAST_WRITE;
696 Vcb->VCBFlags |= UDF_VCB_SKIP_EJECT_CHECK;
697 if(!OS_SUCCESS(RC) &&
698 OS_SUCCESS(RC = UDFRecoverFromError(Vcb, FALSE, RC, rLba, BCount, &retry)) ) {
699 if(RC != STATUS_BUFFER_ALL_ZEROS) {
700 goto retry_2;
701 }
702 RtlZeroMemory(Buffer, RelocExtent->extLength);
703 _ReadBytes = RelocExtent->extLength;
704 RC = STATUS_SUCCESS;
705 }
706TR_continue:
707 (*ReadBytes) += _ReadBytes;
708 if(!OS_SUCCESS(RC)) break;
709 *((uint32*)&Buffer) += RelocExtent->extLength;
710 }
711try_exit: NOTHING;
712 } _SEH2_FINALLY {
713 if(res_acq) {
714 UDFReleaseResource(&(Vcb->IoResource));
715 }
716 if(RelocExtent_saved) {
717 MyFreePool__(RelocExtent_saved);
718 }
719 } _SEH2_END;
720#endif //_BROWSE_UDF_
721 return RC;
722} // end UDFTRead()
struct _VCB * PVCB
Definition: fatstruc.h:557
Definition: bufpool.h:45
#define UDFReleaseResource(Resource)
Definition: env_spec_w32.h:661
#define UDFAcquireResourceExclusive(Resource, CanWait)
Definition: env_spec_w32.h:656
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
OSSTATUS UDFPrepareForReadOperation(IN PVCB Vcb, IN uint32 Lba, IN uint32 BCount)
Definition: phys_lib.cpp:3670
#define PH_VCB_IN_RETLEN
Definition: phys_lib.h:66
#define PH_IO_LOCKED
Definition: phys_lib.h:70
PEXTENT_MAP __fastcall UDFRelocateSectors(IN PVCB Vcb, IN uint32 Lba, IN uint32 BlockCount)
Definition: remap.cpp:1029
uint32 extLength
Definition: ecma_167.h:128
uint32 extLocation
Definition: ecma_167.h:129
Definition: cdstruc.h:498
#define UDF_NO_EXTENT_MAP
Definition: udf_rel.h:519
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by UDFCheckArea(), UDFCommonRead(), UDFReadDiscTrackInfo(), and UDFVerifyVolume().

◆ UDFTWrite()

OSSTATUS UDFTWrite ( IN void _Vcb,
IN void Buffer,
IN SIZE_T  Length,
IN uint32  LBA,
OUT PSIZE_T  WrittenBytes,
IN uint32  Flags 
)

Definition at line 453 of file phys_lib.cpp.

461{
462#ifndef UDF_READ_ONLY_BUILD
463#define Vcb ((PVCB)_Vcb)
464
465#ifdef _BROWSE_UDF_
466 PEXTENT_MAP RelocExtent;
467 PEXTENT_MAP RelocExtent_saved = NULL;
468#endif //_BROWSE_UDF_
469 uint32 retry;
470 BOOLEAN res_acq = FALSE;
471
473 uint32 rLba;
474 uint32 BCount;
475 uint32 i;
476
477#ifdef DBG
478 //ASSERT(!(LBA & (32-1)));
479#endif //DBG
480
481 (*WrittenBytes) = 0;
482 BCount = Length>>Vcb->BlockSizeBits;
483
484 UDFPrint(("TWrite %x (%x)\n", LBA, BCount));
485#ifdef _BROWSE_UDF_
486 if(Vcb->VCBFlags & UDF_VCB_FLAGS_DEAD) {
487 UDFPrint(("DEAD\n"));
489 }
490
492 if(!Vcb->CDR_Mode) {
493 RelocExtent = UDFRelocateSectors(Vcb, LBA, BCount);
494 if(!RelocExtent) {
495 UDFPrint(("can't relocate\n"));
497 }
498 rLba = LBA;
499 } else {
500 RelocExtent = UDF_NO_EXTENT_MAP;
501 rLba = Vcb->NWA;
502 }
503#else //_BROWSE_UDF_
504 rLba = LBA;
505#endif //_BROWSE_UDF_
506
507#ifdef DBG
508 //ASSERT(!(rLba & (32-1)));
509#endif //DBG
510
511 _SEH2_TRY {
512#ifdef _BROWSE_UDF_
513
514 if(!(Flags & PH_IO_LOCKED)) {
515 UDFAcquireResourceExclusive(&(Vcb->IoResource), TRUE);
516 res_acq = TRUE;
517 }
518
519 if(RelocExtent == UDF_NO_EXTENT_MAP) {
520#endif //_BROWSE_UDF_
521 retry = UDF_WRITE_MAX_RETRY;
522retry_1:
523 RC = UDFPrepareForWriteOperation(Vcb, rLba, BCount);
524 if(!OS_SUCCESS(RC)) {
525 UDFPrint(("prepare failed\n"));
526 try_return(RC);
527 }
528 if(Flags & PH_VCB_IN_RETLEN) {
529 (*WrittenBytes) = (ULONG_PTR)Vcb;
530 }
531 RC = UDFPhWriteVerifySynchronous(Vcb->TargetDeviceObject, Buffer, Length,
532 ((uint64)rLba) << Vcb->BlockSizeBits, WrittenBytes, Flags);
533#ifdef _BROWSE_UDF_
534 Vcb->VCBFlags |= UDF_VCB_SKIP_EJECT_CHECK;
535#endif //_BROWSE_UDF_
536 if(!OS_SUCCESS(RC) &&
537 OS_SUCCESS(RC = UDFRecoverFromError(Vcb, TRUE, RC, rLba, BCount, &retry)) )
538 goto retry_1;
539 UDFUpdateNWA((PVCB)_Vcb, rLba, BCount, RC);
540 try_return(RC);
541#ifdef _BROWSE_UDF_
542 }
543 // write according to relocation table
544 RelocExtent_saved = RelocExtent;
545 for(i=0; RelocExtent->extLength; i++, RelocExtent++) {
546 SIZE_T _WrittenBytes;
547 rLba = RelocExtent->extLocation;
548 BCount = RelocExtent->extLength>>Vcb->BlockSizeBits;
549 retry = UDF_WRITE_MAX_RETRY;
550retry_2:
551 RC = UDFPrepareForWriteOperation(Vcb, rLba, BCount);
552 if(!OS_SUCCESS(RC)) {
553 UDFPrint(("prepare failed (2)\n"));
554 break;
555 }
556 if(Flags & PH_VCB_IN_RETLEN) {
557 _WrittenBytes = (ULONG_PTR)Vcb;
558 }
559 RC = UDFPhWriteVerifySynchronous(Vcb->TargetDeviceObject, Buffer, RelocExtent->extLength,
560 ((uint64)rLba) << Vcb->BlockSizeBits, &_WrittenBytes, Flags);
561 Vcb->VCBFlags |= UDF_VCB_SKIP_EJECT_CHECK;
562 if(!OS_SUCCESS(RC) &&
563 OS_SUCCESS(RC = UDFRecoverFromError(Vcb, TRUE, RC, rLba, BCount, &retry)) )
564 goto retry_2;
565 UDFUpdateNWA((PVCB)_Vcb, rLba, BCount, RC);
566 LBA += BCount;
567 (*WrittenBytes) += _WrittenBytes;
568 if(!OS_SUCCESS(RC)) break;
569 *((uint32*)&Buffer) += RelocExtent->extLength;
570 }
571#endif //_BROWSE_UDF_
572try_exit: NOTHING;
573 } _SEH2_FINALLY {
574 if(res_acq) {
575 UDFReleaseResource(&(Vcb->IoResource));
576 }
577#ifdef _BROWSE_UDF_
578 if(RelocExtent_saved) {
579 MyFreePool__(RelocExtent_saved);
580 }
581#endif //_BROWSE_UDF_
582 } _SEH2_END;
583 UDFPrint(("TWrite: %x\n", RC));
584 return RC;
585
586#undef Vcb
587#else //UDF_READ_ONLY_BUILD
589#endif //UDF_READ_ONLY_BUILD
590} // end UDFTWrite()
#define ULONG_PTR
Definition: config.h:101
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145

Referenced by UDFCommonWrite(), UDFVerifyVolume(), and UDFWriteSectors().

◆ UDFUpdateNWA()

void UDFUpdateNWA ( PVCB  Vcb,
uint32  LBA,
uint32  BCount,
OSSTATUS  RC 
)

Definition at line 3826 of file phys_lib.cpp.

3832{
3833#ifndef UDF_READ_ONLY_BUILD
3834#ifdef _BROWSE_UDF_
3835 if(!OS_SUCCESS(RC)) {
3836 return;
3837 }
3838 if(!Vcb->CDR_Mode) {
3839
3840 if((Vcb->MediaClassEx == CdMediaClass_DVDRW ||
3841 Vcb->MediaClassEx == CdMediaClass_DVDpRW ||
3842 Vcb->MediaClassEx == CdMediaClass_DVDRAM ||
3843 Vcb->MRWStatus == DiscInfo_BGF_Interrupted ||
3844 Vcb->MRWStatus == DiscInfo_BGF_InProgress)
3845 && (LBA+BCount-1) > Vcb->LastLBA) {
3846 ASSERT(Vcb->NWA > Vcb->LastLBA);
3847 Vcb->NWA = LBA+BCount;
3848 Vcb->LastLBA = Vcb->NWA-1;
3849 }
3850 if(Vcb->VCBFlags & UDF_VCB_FLAGS_FORCE_SYNC_CACHE)
3851 goto sync_cache;
3852/* if(Vcb->CdrwBufferSize) {
3853 Vcb->CdrwBufferSizeCounter += BCount * 2048;
3854 if(Vcb->CdrwBufferSizeCounter >= Vcb->CdrwBufferSize + 2*2048) {
3855 UDFPrint((" UDFUpdateNWA: buffer is full, sync...\n"));
3856 Vcb->CdrwBufferSizeCounter = 0;
3857 goto sync_cache;
3858 }
3859 }*/
3860 if(Vcb->SyncCacheState == SYNC_CACHE_RECOVERY_RETRY) {
3862 }
3863 Vcb->SyncCacheState = SYNC_CACHE_RECOVERY_NONE;
3864 return;
3865 }
3866 if(Vcb->LastLBA < (LBA+BCount))
3867 Vcb->LastLBA = LBA+BCount;
3868 if(Vcb->NWA)
3869 Vcb->NWA+=BCount+7;
3870sync_cache:
3871 if(!(Vcb->CompatFlags & UDF_VCB_IC_NO_SYNCCACHE_AFTER_WRITE)) {
3872 UDFPrint((" UDFUpdateNWA: syncing...\n"));
3873 RC = UDFSyncCache(Vcb);
3874 }
3875#endif //_BROWSE_UDF_
3876#endif //UDF_READ_ONLY_BUILD
3877} // end UDFUpdateNWA()

Referenced by UDFPrepareForWriteOperation(), and UDFTWrite().

◆ UDFUseStandard()

OSSTATUS UDFUseStandard ( PDEVICE_OBJECT  DeviceObject,
PVCB  Vcb 
)

Definition at line 2386 of file phys_lib.cpp.

2390{
2394 uint32 LocalTrackCount;
2395// uint32 LocalTocLength;
2396 uint32 TocEntry;
2397#ifdef _BROWSE_UDF_
2398 uint32 OldTrkNum;
2399 uint32 TrkNum;
2401#endif //_BROWSE_UDF_
2402#ifdef UDF_FORMAT_MEDIA
2403 PUDFFmtState fms = Vcb->fms;
2404#else
2405 #define fms FALSE
2406#endif //UDF_FORMAT_MEDIA
2407
2408 UDFPrint(("UDFUseStandard\n"));
2409
2410 _SEH2_TRY {
2411
2412 if(!toc || !LastSes) {
2414 }
2415 RtlZeroMemory(toc,sizeof(READ_TOC_TOC));
2416
2417 Vcb->VCBFlags |= UDF_VCB_FLAGS_USE_STD;
2418
2420 toc,sizeof(READ_TOC_USER_OUT),
2421 toc,sizeof(READ_TOC_USER_OUT),
2422 TRUE,NULL );
2423
2424 if((RC == STATUS_DEVICE_NOT_READY) || (RC == STATUS_NO_MEDIA_IN_DEVICE)) {
2425 try_return(RC);
2426 }
2427#ifdef UDF_FORMAT_MEDIA
2428 if(fms->opt_media == MT_none) {
2430 }
2431#endif //UDF_FORMAT_MEDIA
2432
2433 // If even standard read toc does not work, then use default values
2434 if(!OS_SUCCESS(RC)) {
2435
2436 RC = UDFReallocTrackMap(Vcb, 2);
2437 if(!OS_SUCCESS(RC)) {
2438 try_return(RC);
2439 }
2440
2441 Vcb->LastSession=1;
2442 Vcb->FirstTrackNum=1;
2443// Vcb->FirstLBA=0;
2444 Vcb->LastTrackNum=1;
2445 Vcb->TrackMap[1].FirstLba = Vcb->FirstLBA;
2446 Vcb->TrackMap[1].LastLba = Vcb->LastLBA;
2447 Vcb->TrackMap[1].PacketSize = PACKETSIZE_UDF;
2448#ifdef UDF_FORMAT_MEDIA
2449 if(!fms) {
2450#endif //UDF_FORMAT_MEDIA
2451
2452#ifdef _BROWSE_UDF_
2453#ifdef UDF_HDD_SUPPORT
2456 }
2457#endif //UDF_HDD_SUPPORT
2458#endif //_BROWSE_UDF_
2459
2460#ifdef UDF_FORMAT_MEDIA
2461 } else {
2462
2463 if(fms->opt_media == MT_HD) {
2464 Vcb->LastPossibleLBA = Vcb->LastLBA;
2466 }
2467 }
2468#endif //UDF_FORMAT_MEDIA
2469 Vcb->LastPossibleLBA = max(Vcb->LastLBA, DEFAULT_LAST_LBA_FP_CD);
2470 Vcb->TrackMap[1].DataParam = TrkInfo_Dat_XA | TrkInfo_FP | TrkInfo_Packet;
2471 Vcb->TrackMap[1].TrackParam = TrkInfo_Trk_XA;
2472 Vcb->TrackMap[1].NWA = 0xffffffff;
2473 Vcb->NWA = DEFAULT_LAST_LBA_FP_CD + 7 + 1;
2475 }
2476
2477#ifdef _CONSOLE
2478 Vcb->PhDeviceType = FILE_DEVICE_CD_ROM;
2479#endif //_CONSOLE
2480
2481 LocalTrackCount = toc->Tracks.Last_TrackSes - toc->Tracks.First_TrackSes + 1;
2482// LocalTocLength = PtrOffset( toc, &(toc->TrackData[LocalTrackCount + 1]) ); /* FIXME ReactOS Assume PtrOffset is not changing it's arguments? */
2483
2484 // Get out if there is an immediate problem with the TOC.
2485 if(toc->Tracks.First_TrackSes > toc->Tracks.Last_TrackSes) {
2487 }
2488
2489#ifdef _BROWSE_UDF_
2490 Vcb->LastTrackNum=toc->Tracks.Last_TrackSes;
2491 Vcb->FirstTrackNum=toc->Tracks.First_TrackSes;
2492 // some devices report LastTrackNum=0 for full disks
2493 Vcb->LastTrackNum = max(Vcb->LastTrackNum, Vcb->FirstTrackNum);
2494
2496/* if(Vcb->TrackMap) {
2497 MyFreePool__(Vcb->TrackMap);
2498 Vcb->TrackMap = NULL;
2499 }
2500 Vcb->TrackMap = (PUDFTrackMap)
2501 MyAllocatePool__(NonPagedPool, (MAXIMUM_NUMBER_OF_TRACKS+1)*sizeof(UDFTrackMap));
2502 if(!Vcb->TrackMap) {
2503 MyFreePool__(toc);
2504 return STATUS_INSUFFICIENT_RESOURCES;
2505 }
2506 RtlZeroMemory(Vcb->TrackMap,(MAXIMUM_NUMBER_OF_TRACKS+1)*sizeof(UDFTrackMap));
2507*/
2508 if(!OS_SUCCESS(RC)) {
2509 BrutePoint();
2510 try_return(RC);
2511 }
2512 // find 1st and last session
2514 LastSes,sizeof(GET_LAST_SESSION_USER_OUT),
2515 LastSes,sizeof(GET_LAST_SESSION_USER_OUT),
2516 TRUE,NULL );
2517
2518 if(OS_SUCCESS(RC)) {
2519 TrkNum = LastSes->LastSes_1stTrack.TrackNum;
2520 Vcb->LastSession = LastSes->Sessions.First_TrackSes;
2521 for(TocEntry=0;TocEntry<LocalTrackCount + 1;TocEntry++) {
2522 if(toc->TrackData[TocEntry].TrackNum == TrkNum) {
2523 Vcb->TrackMap[TrkNum].Session = Vcb->LastSession;
2524 }
2525 }
2526 }
2527
2528 OldTrkNum = 0;
2529 // Scan toc for first & last LBA
2530 for(TocEntry=0;TocEntry<LocalTrackCount + 1;TocEntry++) {
2531#define TempMSF toc->TrackData[TocEntry].LBA
2532 TrkNum = toc->TrackData[TocEntry].TrackNum;
2533#ifdef UDF_DBG
2534 if (TrkNum >= MAXIMUM_NUMBER_OF_TRACKS &&
2535 TrkNum != TOC_LastTrack_ID) {
2536 UDFPrint(("UDFUseStandard: Array out of bounds\n"));
2537 BrutePoint();
2539 }
2540 UDFPrint(("Track N %d (0x%x) first LBA %ld (%lx) \n",TrkNum,TrkNum,
2542 MSF_TO_LBA(TempMSF[1],TempMSF[2],TempMSF[3])));
2543#endif // UDF_DBG
2544 if(Vcb->FirstTrackNum == TrkNum) {
2545 Vcb->FirstLBA = MSF_TO_LBA(TempMSF[1],TempMSF[2],TempMSF[3]);
2546 if(Vcb->FirstLBA & 0x80000000) {
2547 Vcb->FirstLBA = 0;
2548 }
2549