Changeset 69023 in vbox for trunk/src/VBox/Runtime/common/fs
- Timestamp:
- Oct 10, 2017 8:35:02 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/fs/isovfs.cpp
r69013 r69023 50 50 51 51 /** @todo move to err.h: */ 52 #define VERR_ISOFS_IPE_0 (-25390)53 54 55 /*********************************************************************************************************************************56 * Structures and Typedefs *57 *********************************************************************************************************************************/58 /** Pointer to an ISO volume (VFS instance data). */59 typedef struct RTFSISOVOL *PRTFSISOVOL;60 /** Pointer to a const ISO volume (VFS instance data). */61 typedef struct RTFSISOVOL const *PCRTFSISOVOL;62 63 /** Pointer to a ISO directory instance. */64 typedef struct RTFSISODIRSHRD *PRTFSISODIRSHRD;65 66 67 68 /**69 * ISO extent (internal to the VFS not a disk structure).70 */71 typedef struct RTFSISOEXTENT72 {73 /** The disk offset. */74 uint64_t offDisk;75 /** The size of the extent in bytes. */76 uint64_t cbExtent;77 } RTFSISOEXTENT;78 /** Pointer to an ISO 9660 extent. */79 typedef RTFSISOEXTENT *PRTFSISOEXTENT;80 /** Pointer to a const ISO 9660 extent. */81 typedef RTFSISOEXTENT const *PCRTFSISOEXTENT;82 83 84 /**85 * ISO file system object, shared part.86 */87 typedef struct RTFSISOCORE88 {89 /** The parent directory keeps a list of open objects (RTFSISOCORE). */90 RTLISTNODE Entry;91 /** Reference counter. */92 uint32_t volatile cRefs;93 /** The parent directory (not released till all children are close). */94 PRTFSISODIRSHRD pParentDir;95 /** The byte offset of the first directory record. */96 uint64_t offDirRec;97 /** Attributes. */98 RTFMODE fAttrib;99 /** The object size. */100 uint64_t cbObject;101 /** The access time. */102 RTTIMESPEC AccessTime;103 /** The modificaton time. */104 RTTIMESPEC ModificationTime;105 /** The change time. */106 RTTIMESPEC ChangeTime;107 /** The birth time. */108 RTTIMESPEC BirthTime;109 /** Pointer to the volume. */110 PRTFSISOVOL pVol;111 /** The version number. */112 uint32_t uVersion;113 /** Number of extents. */114 uint32_t cExtents;115 /** The first extent. */116 RTFSISOEXTENT FirstExtent;117 /** Array of additional extents. */118 PRTFSISOEXTENT paExtents;119 } RTFSISOCORE;120 typedef RTFSISOCORE *PRTFSISOCORE;121 122 /**123 * ISO file, shared data.124 */125 typedef struct RTFSISOFILESHRD126 {127 /** Core ISO9660 object info. */128 RTFSISOCORE Core;129 } RTFSISOFILESHRD;130 /** Pointer to a ISO 9660 file object. */131 typedef RTFSISOFILESHRD *PRTFSISOFILESHRD;132 133 134 /**135 * ISO directory, shared data.136 *137 * We will always read in the whole directory just to keep things really simple.138 */139 typedef struct RTFSISODIRSHRD140 {141 /** Core ISO 9660 object info. */142 RTFSISOCORE Core;143 /** Open child objects (RTFSISOCORE). */144 RTLISTNODE OpenChildren;145 146 /** Pointer to the directory content. */147 uint8_t *pbDir;148 /** The size of the directory content (duplicate of Core.cbObject). */149 uint32_t cbDir;150 } RTFSISODIRSHRD;151 /** Pointer to a ISO directory instance. */152 typedef RTFSISODIRSHRD *PRTFSISODIRSHRD;153 154 155 /**156 * Private data for a VFS file object.157 */158 typedef struct RTFSISOFILEOBJ159 {160 /** Pointer to the shared data. */161 PRTFSISOFILESHRD pShared;162 /** The current file offset. */163 uint64_t offFile;164 } RTFSISOFILEOBJ;165 typedef RTFSISOFILEOBJ *PRTFSISOFILEOBJ;166 167 /**168 * Private data for a VFS directory object.169 */170 typedef struct RTFSISODIROBJ171 {172 /** Pointer to the shared data. */173 PRTFSISODIRSHRD pShared;174 /** The current directory offset. */175 uint32_t offDir;176 } RTFSISODIROBJ;177 typedef RTFSISODIROBJ *PRTFSISODIROBJ;178 179 /** Pointer to info about a UDF volume. */180 typedef struct RTFSISOUDFVOLINFO *PRTFSISOUDFVOLINFO;181 182 183 /** @name RTFSISO_UDF_PMAP_T_XXX184 * @{ */185 #define RTFSISO_UDF_PMAP_T_PLAIN 1186 #define RTFSISO_UDF_PMAP_T_VPM_15 2187 #define RTFSISO_UDF_PMAP_T_VPM_20 3188 #define RTFSISO_UDF_PMAP_T_SPM 4189 #define RTFSISO_UDF_PMAP_T_MPM 5190 /** @} */191 192 /**193 * Information about a logical UDF partition.194 *195 * This combins information from the partition descriptor, the UDFPARTMAPTYPE1196 * and the UDFPARTMAPTYPE2 structure.197 */198 typedef struct RTFSISOVOLUDFPMAP199 {200 /** Partition starting location as a byte offset. */201 uint64_t offByteLocation;202 /** Partition starting location (logical sector number). */203 uint32_t offLocation;204 /** Number of sectors. */205 uint32_t cSectors;206 207 /** Partition descriptor index (for processing). */208 uint16_t idxPartDesc;209 /** Offset info the map table. */210 uint16_t offMapTable;211 /** Partition number (not index). */212 uint16_t uPartitionNo;213 /** Partition number (not index). */214 uint16_t uVolumeSeqNo;215 216 /** The access type (UDF_PART_ACCESS_TYPE_XXX). */217 uint32_t uAccessType;218 /** Partition flags (UDF_PARTITION_FLAGS_XXX). */219 uint16_t fFlags;220 /** RTFSISO_UDF_PMAP_T_XXX. */221 uint8_t bType;222 /** Set if Hdr is valid. */223 bool fHaveHdr;224 /** Copy of UDFPARTITIONDESC::ContentsUse::Hdr. */225 UDFPARTITIONHDRDESC Hdr;226 227 } RTFSISOVOLUDFPMAP;228 typedef RTFSISOVOLUDFPMAP *PRTFSISOVOLUDFPMAP;229 230 /**231 * Information about a UDF volume (/ volume set).232 *233 * This combines information from the primary and logical descriptors.234 *235 * @note There is only one volume per volume set in the current UDF236 * implementation. So, this can be considered a volume and a volume set.237 */238 typedef struct RTFSISOUDFVOLINFO239 {240 /** The extent containing the file set descriptor. */241 UDFLONGAD FileSetDescriptor;242 243 /** The root directory location (from the file set descriptor). */244 UDFLONGAD RootDirIcb;245 /** Location of the system stream directory associated with the file set. */246 UDFLONGAD SystemStreamDirIcb;247 248 /** The logical block size on this volume. */249 uint32_t cbBlock;250 /** The log2 of cbBlock. */251 uint32_t cShiftBlock;252 /** Flags (UDF_PVD_FLAGS_XXX). */253 uint16_t fFlags;254 255 /** Number of partitions mapp in this volume. */256 uint16_t cPartitions;257 /** Partitions in this volume. */258 PRTFSISOVOLUDFPMAP paPartitions;259 260 /** The volume ID string. */261 UDFDSTRING achLogicalVolumeID[128];262 } RTFSISOUDFVOLINFO;263 264 265 /**266 * Indicates which of the possible content types we're accessing.267 */268 typedef enum RTFSISOVOLTYPE269 {270 /** Accessing the primary ISO-9660 volume. */271 RTFSISOVOLTYPE_ISO9960 = 0,272 /** Accessing the joliet volume (secondary ISO-9660). */273 RTFSISOVOLTYPE_JOLIET,274 /** Accessing the UDF volume. */275 RTFSISOVOLTYPE_UDF276 } RTFSISOVOLTYPE;277 278 /**279 * A ISO volume.280 */281 typedef struct RTFSISOVOL282 {283 /** Handle to itself. */284 RTVFS hVfsSelf;285 /** The file, partition, or whatever backing the ISO 9660 volume. */286 RTVFSFILE hVfsBacking;287 /** The size of the backing thingy. */288 uint64_t cbBacking;289 /** The size of the backing thingy in sectors (cbSector). */290 uint64_t cBackingSectors;291 /** Flags. */292 uint32_t fFlags;293 /** The sector size (in bytes). */294 uint32_t cbSector;295 /** What we're accessing. */296 RTFSISOVOLTYPE enmType;297 298 /** @name ISO 9660 specific data299 * @{ */300 /** The size of a logical block in bytes. */301 uint32_t cbBlock;302 /** The primary volume space size in blocks. */303 uint32_t cBlocksInPrimaryVolumeSpace;304 /** The primary volume space size in bytes. */305 uint64_t cbPrimaryVolumeSpace;306 /** The number of volumes in the set. */307 uint32_t cVolumesInSet;308 /** The primary volume sequence ID. */309 uint32_t idPrimaryVol;310 /** Set if using UTF16-2 (joliet). */311 bool fIsUtf16;312 /** @} */313 314 /** UDF specific data. */315 struct316 {317 /** Volume information. */318 RTFSISOUDFVOLINFO VolInfo;319 /** The UDF level. */320 uint8_t uLevel;321 } Udf;322 323 /** The root directory shared data. */324 PRTFSISODIRSHRD pRootDir;325 } RTFSISOVOL;326 327 328 /**329 * Info gathered from a VDS sequence.330 */331 typedef struct RTFSISOVDSINFO332 {333 /** Number of entries in apPrimaryVols. */334 uint32_t cPrimaryVols;335 /** Number of entries in apLogicalVols. */336 uint32_t cLogicalVols;337 /** Number of entries in apPartitions. */338 uint32_t cPartitions;339 /** Pointer to primary volume descriptors (native endian). */340 PUDFPRIMARYVOLUMEDESC apPrimaryVols[8];341 /** Pointer to logical volume descriptors (native endian). */342 PUDFLOGICALVOLUMEDESC apLogicalVols[8];343 /** Pointer to partition descriptors (native endian). */344 PUDFPARTITIONDESC apPartitions[16];345 346 /** Created after scanning the sequence (here for cleanup purposes). */347 PRTFSISOVOLUDFPMAP paPartMaps;348 } RTFSISOVDSINFO;349 /** Pointer to VDS sequence info. */350 typedef RTFSISOVDSINFO *PRTFSISOVDSINFO;351 52 352 53 … … 355 56 * Defined Constants And Macros * 356 57 *********************************************************************************************************************************/ 58 /** The maximum logical block size. */ 59 #define RTFSISO_MAX_LOGICAL_BLOCK_SIZE _16K 60 /** Max directory size. */ 61 #if ARCH_BITS == 32 62 # define RTFSISO_MAX_DIR_SIZE _32M 63 #else 64 # define RTFSISO_MAX_DIR_SIZE _64M 65 #endif 66 357 67 /** Check if an entity ID field equals the given ID string. */ 358 68 #define UDF_ENTITY_ID_EQUALS(a_pEntityId, a_szId) \ … … 431 141 432 142 143 144 /********************************************************************************************************************************* 145 * Structures and Typedefs * 146 *********************************************************************************************************************************/ 147 /** Pointer to an ISO volume (VFS instance data). */ 148 typedef struct RTFSISOVOL *PRTFSISOVOL; 149 /** Pointer to a const ISO volume (VFS instance data). */ 150 typedef struct RTFSISOVOL const *PCRTFSISOVOL; 151 152 /** Pointer to a ISO directory instance. */ 153 typedef struct RTFSISODIRSHRD *PRTFSISODIRSHRD; 154 155 156 157 /** 158 * ISO extent (internal to the VFS not a disk structure). 159 */ 160 typedef struct RTFSISOEXTENT 161 { 162 /** The disk offset. */ 163 uint64_t offDisk; 164 /** The size of the extent in bytes. */ 165 uint64_t cbExtent; 166 } RTFSISOEXTENT; 167 /** Pointer to an ISO 9660 extent. */ 168 typedef RTFSISOEXTENT *PRTFSISOEXTENT; 169 /** Pointer to a const ISO 9660 extent. */ 170 typedef RTFSISOEXTENT const *PCRTFSISOEXTENT; 171 172 173 /** 174 * ISO file system object, shared part. 175 */ 176 typedef struct RTFSISOCORE 177 { 178 /** The parent directory keeps a list of open objects (RTFSISOCORE). */ 179 RTLISTNODE Entry; 180 /** Reference counter. */ 181 uint32_t volatile cRefs; 182 /** The parent directory (not released till all children are close). */ 183 PRTFSISODIRSHRD pParentDir; 184 /** The byte offset of the first directory record. */ 185 uint64_t offDirRec; 186 /** Attributes. */ 187 RTFMODE fAttrib; 188 /** The object size. */ 189 uint64_t cbObject; 190 /** The access time. */ 191 RTTIMESPEC AccessTime; 192 /** The modificaton time. */ 193 RTTIMESPEC ModificationTime; 194 /** The change time. */ 195 RTTIMESPEC ChangeTime; 196 /** The birth time. */ 197 RTTIMESPEC BirthTime; 198 /** Pointer to the volume. */ 199 PRTFSISOVOL pVol; 200 /** The version number. */ 201 uint32_t uVersion; 202 /** Number of extents. */ 203 uint32_t cExtents; 204 /** The first extent. */ 205 RTFSISOEXTENT FirstExtent; 206 /** Array of additional extents. */ 207 PRTFSISOEXTENT paExtents; 208 } RTFSISOCORE; 209 typedef RTFSISOCORE *PRTFSISOCORE; 210 211 /** 212 * ISO file, shared data. 213 */ 214 typedef struct RTFSISOFILESHRD 215 { 216 /** Core ISO9660 object info. */ 217 RTFSISOCORE Core; 218 } RTFSISOFILESHRD; 219 /** Pointer to a ISO 9660 file object. */ 220 typedef RTFSISOFILESHRD *PRTFSISOFILESHRD; 221 222 223 /** 224 * ISO directory, shared data. 225 * 226 * We will always read in the whole directory just to keep things really simple. 227 */ 228 typedef struct RTFSISODIRSHRD 229 { 230 /** Core ISO 9660 object info. */ 231 RTFSISOCORE Core; 232 /** Open child objects (RTFSISOCORE). */ 233 RTLISTNODE OpenChildren; 234 235 /** Pointer to the directory content. */ 236 uint8_t *pbDir; 237 /** The size of the directory content (duplicate of Core.cbObject). */ 238 uint32_t cbDir; 239 } RTFSISODIRSHRD; 240 /** Pointer to a ISO directory instance. */ 241 typedef RTFSISODIRSHRD *PRTFSISODIRSHRD; 242 243 244 /** 245 * Private data for a VFS file object. 246 */ 247 typedef struct RTFSISOFILEOBJ 248 { 249 /** Pointer to the shared data. */ 250 PRTFSISOFILESHRD pShared; 251 /** The current file offset. */ 252 uint64_t offFile; 253 } RTFSISOFILEOBJ; 254 typedef RTFSISOFILEOBJ *PRTFSISOFILEOBJ; 255 256 /** 257 * Private data for a VFS directory object. 258 */ 259 typedef struct RTFSISODIROBJ 260 { 261 /** Pointer to the shared data. */ 262 PRTFSISODIRSHRD pShared; 263 /** The current directory offset. */ 264 uint32_t offDir; 265 } RTFSISODIROBJ; 266 typedef RTFSISODIROBJ *PRTFSISODIROBJ; 267 268 /** Pointer to info about a UDF volume. */ 269 typedef struct RTFSISOUDFVOLINFO *PRTFSISOUDFVOLINFO; 270 271 272 /** @name RTFSISO_UDF_PMAP_T_XXX 273 * @{ */ 274 #define RTFSISO_UDF_PMAP_T_PLAIN 1 275 #define RTFSISO_UDF_PMAP_T_VPM_15 2 276 #define RTFSISO_UDF_PMAP_T_VPM_20 3 277 #define RTFSISO_UDF_PMAP_T_SPM 4 278 #define RTFSISO_UDF_PMAP_T_MPM 5 279 /** @} */ 280 281 /** 282 * Information about a logical UDF partition. 283 * 284 * This combins information from the partition descriptor, the UDFPARTMAPTYPE1 285 * and the UDFPARTMAPTYPE2 structure. 286 */ 287 typedef struct RTFSISOVOLUDFPMAP 288 { 289 /** Partition starting location as a byte offset. */ 290 uint64_t offByteLocation; 291 /** Partition starting location (logical sector number). */ 292 uint32_t offLocation; 293 /** Number of sectors. */ 294 uint32_t cSectors; 295 296 /** Partition descriptor index (for processing). */ 297 uint16_t idxPartDesc; 298 /** Offset info the map table. */ 299 uint16_t offMapTable; 300 /** Partition number (not index). */ 301 uint16_t uPartitionNo; 302 /** Partition number (not index). */ 303 uint16_t uVolumeSeqNo; 304 305 /** The access type (UDF_PART_ACCESS_TYPE_XXX). */ 306 uint32_t uAccessType; 307 /** Partition flags (UDF_PARTITION_FLAGS_XXX). */ 308 uint16_t fFlags; 309 /** RTFSISO_UDF_PMAP_T_XXX. */ 310 uint8_t bType; 311 /** Set if Hdr is valid. */ 312 bool fHaveHdr; 313 /** Copy of UDFPARTITIONDESC::ContentsUse::Hdr. */ 314 UDFPARTITIONHDRDESC Hdr; 315 316 } RTFSISOVOLUDFPMAP; 317 typedef RTFSISOVOLUDFPMAP *PRTFSISOVOLUDFPMAP; 318 319 /** 320 * Information about a UDF volume (/ volume set). 321 * 322 * This combines information from the primary and logical descriptors. 323 * 324 * @note There is only one volume per volume set in the current UDF 325 * implementation. So, this can be considered a volume and a volume set. 326 */ 327 typedef struct RTFSISOUDFVOLINFO 328 { 329 /** The extent containing the file set descriptor. */ 330 UDFLONGAD FileSetDescriptor; 331 332 /** The root directory location (from the file set descriptor). */ 333 UDFLONGAD RootDirIcb; 334 /** Location of the system stream directory associated with the file set. */ 335 UDFLONGAD SystemStreamDirIcb; 336 337 /** The logical block size on this volume. */ 338 uint32_t cbBlock; 339 /** The log2 of cbBlock. */ 340 uint32_t cShiftBlock; 341 /** Flags (UDF_PVD_FLAGS_XXX). */ 342 uint16_t fFlags; 343 344 /** Number of partitions mapp in this volume. */ 345 uint16_t cPartitions; 346 /** Partitions in this volume. */ 347 PRTFSISOVOLUDFPMAP paPartitions; 348 349 /** The volume ID string. */ 350 UDFDSTRING achLogicalVolumeID[128]; 351 } RTFSISOUDFVOLINFO; 352 353 354 /** 355 * Indicates which of the possible content types we're accessing. 356 */ 357 typedef enum RTFSISOVOLTYPE 358 { 359 /** Accessing the primary ISO-9660 volume. */ 360 RTFSISOVOLTYPE_ISO9960 = 0, 361 /** Accessing the joliet volume (secondary ISO-9660). */ 362 RTFSISOVOLTYPE_JOLIET, 363 /** Accessing the UDF volume. */ 364 RTFSISOVOLTYPE_UDF 365 } RTFSISOVOLTYPE; 366 367 /** 368 * A ISO volume. 369 */ 370 typedef struct RTFSISOVOL 371 { 372 /** Handle to itself. */ 373 RTVFS hVfsSelf; 374 /** The file, partition, or whatever backing the ISO 9660 volume. */ 375 RTVFSFILE hVfsBacking; 376 /** The size of the backing thingy. */ 377 uint64_t cbBacking; 378 /** The size of the backing thingy in sectors (cbSector). */ 379 uint64_t cBackingSectors; 380 /** Flags. */ 381 uint32_t fFlags; 382 /** The sector size (in bytes). */ 383 uint32_t cbSector; 384 /** What we're accessing. */ 385 RTFSISOVOLTYPE enmType; 386 387 /** @name ISO 9660 specific data 388 * @{ */ 389 /** The size of a logical block in bytes. */ 390 uint32_t cbBlock; 391 /** The primary volume space size in blocks. */ 392 uint32_t cBlocksInPrimaryVolumeSpace; 393 /** The primary volume space size in bytes. */ 394 uint64_t cbPrimaryVolumeSpace; 395 /** The number of volumes in the set. */ 396 uint32_t cVolumesInSet; 397 /** The primary volume sequence ID. */ 398 uint32_t idPrimaryVol; 399 /** Set if using UTF16-2 (joliet). */ 400 bool fIsUtf16; 401 /** @} */ 402 403 /** UDF specific data. */ 404 struct 405 { 406 /** Volume information. */ 407 RTFSISOUDFVOLINFO VolInfo; 408 /** The UDF level. */ 409 uint8_t uLevel; 410 } Udf; 411 412 /** The root directory shared data. */ 413 PRTFSISODIRSHRD pRootDir; 414 } RTFSISOVOL; 415 416 417 /** 418 * Info gathered from a VDS sequence. 419 */ 420 typedef struct RTFSISOVDSINFO 421 { 422 /** Number of entries in apPrimaryVols. */ 423 uint32_t cPrimaryVols; 424 /** Number of entries in apLogicalVols. */ 425 uint32_t cLogicalVols; 426 /** Number of entries in apPartitions. */ 427 uint32_t cPartitions; 428 /** Pointer to primary volume descriptors (native endian). */ 429 PUDFPRIMARYVOLUMEDESC apPrimaryVols[8]; 430 /** Pointer to logical volume descriptors (native endian). */ 431 PUDFLOGICALVOLUMEDESC apLogicalVols[8]; 432 /** Pointer to partition descriptors (native endian). */ 433 PUDFPARTITIONDESC apPartitions[16]; 434 435 /** Created after scanning the sequence (here for cleanup purposes). */ 436 PRTFSISOVOLUDFPMAP paPartMaps; 437 } RTFSISOVDSINFO; 438 /** Pointer to VDS sequence info. */ 439 typedef RTFSISOVDSINFO *PRTFSISOVDSINFO; 440 441 442 433 443 /********************************************************************************************************************************* 434 444 * Global Variables * … … 769 779 } 770 780 } 781 return VINF_SUCCESS; 782 } 783 784 785 static int rtFsIsoCore_InitFromUdfIcbAndFileIdDesc(PRTFSISOCORE pCore, PCUDFLONGAD pAllocDesc, 786 PCUDFFILEIDDESC pFileIdDesc, PRTFSISOVOL pThis) 787 { 788 #if 1 789 RT_NOREF(pCore, pAllocDesc, pFileIdDesc, pThis); 790 #else 791 /* 792 * Allocate a temporary buffer. 793 */ 794 if (pAllocDesc->cb > _64K) 795 return VERR_ISOFS_DIR_ICB_TOO_BIG; 796 if (pAllocDesc->cb < sizeof(UDFTAG) + sizeof(UDFICBTAG)) 797 return VERR_ISOFS_DIR_ICB_TOO_SMALL; 798 799 size_t const cbBuf = pThis->Udf.VolInfo.cbBlock * 2; 800 uint8_t * const pbBuf = RTMemTmpAlloc(pThis->Udf.VolInfo.cbBlock * 2); 801 if (!pbBuf) 802 return VERR_NO_TMP_MEMORY; 803 804 /* 805 * 806 */ 807 uint32_t offIcb = 0; 808 int rc; 809 do 810 { 811 size_t cbToRead = RT_MIN(cbBuf, pAllocDesc->cb); 812 rc = rtFsIsoVolUdfVpRead(pThis, pAllocDesc->Location.uPartitionNo, pAllocDesc->Location.off, offIcb, pbBuf, cbToRead); 813 if (RT_FAILURE(rc)) 814 break; 815 816 817 } while (0); 818 819 820 /* 821 * Read the ICB into a temporary buffer. 822 */ 823 824 uint32_t cbBuf = RT_ALIGN_32(pAllocDesc->cb, pThis->cbSector); 825 void *pvBuf = RTMemTmpAllocZ(cbBuf); 826 if (!pvBuf) 827 return VERR_NO_TMP_MEMORY; 828 829 int rc = rtFsIsoVolUdfVpRead(pThis, pAllocDesc->Location.uPartitionNo, pAllocDesc->Location.off, 0, pvBuf, cbBuf); 830 if (RT_SUCCESS(rc)) 831 { 832 /* 833 * Parse the buffer. 834 */ 835 size_t cbLeft = pAllocDesc->cb; 836 uint8_t *pbCur = (uint8_t *) 837 do 838 { 839 PCUDFFILEENTRY pFe = (PCUDFFILEENTRY)pbCur; 840 841 } 842 843 while (cbLeft > 0) 844 { 845 PCUDFFILEENTRY pFe = (PCUDFFILEENTRY)pbCur; 846 847 } 848 849 850 union 851 { 852 void *pv; 853 PCUDFFILEENTRY pFe; 854 PCUDFEXFILEENTRY pExFe; 855 } uBuf; 856 857 858 } 859 RTMemTmpFree(uBuf.pv); 860 #endif 861 771 862 return VINF_SUCCESS; 772 863 } … … 2138 2229 if (offSysUse < pDirRec->cbDirRec) 2139 2230 { 2140 Log2(("ISO9660: system use (%#x bytes):\n%.*Rhx d\n", pDirRec->cbDirRec - offSysUse,2231 Log2(("ISO9660: system use (%#x bytes):\n%.*RhxD\n", pDirRec->cbDirRec - offSysUse, 2141 2232 pDirRec->cbDirRec - offSysUse, (uint8_t *)pDirRec + offSysUse)); 2142 2233 } … … 2206 2297 2207 2298 2208 #if 0 2209 /** 2210 * Instantiates a new shared directory structure, given 9660 records. 2299 /** 2300 * Instantiates a new shared directory structure, given UDF descriptors. 2211 2301 * 2212 2302 * @returns IPRT status code. … … 2214 2304 * @param pParentDir The parent directory. This is NULL for the root 2215 2305 * directory. 2216 * @param pDirRec The directory record. Will access @a cDirRecs 2217 * records. 2218 * @param cDirRecs Number of directory records if more than one. 2219 * @param offDirRec The byte offset of the directory record. 2306 * @param pAllocDesc The allocation descriptor for the directory ICB. 2307 * @param pFileIdDesc The file ID descriptor. This is NULL for the root. 2220 2308 * @param ppShared Where to return the shared directory structure. 2221 2309 */ 2222 static int rtFsIsoDirShrd_NewUdf(PRTFSISOVOL pThis, PRTFSISODIRSHRD pParentDir, 2223 PCUDFEXTVOLDESCNSR 2224 2225 PCISO9660DIRREC pDirRec, uint32_t cDirRecs, uint64_t offDirRec, 2226 PRTFSISODIRSHRD *ppShared) 2310 static int rtFsIsoDirShrd_NewUdf(PRTFSISOVOL pThis, PRTFSISODIRSHRD pParentDir, PCUDFLONGAD pAllocDesc, 2311 PCUDFFILEIDDESC pFileIdDesc, PRTFSISODIRSHRD *ppShared) 2227 2312 { 2228 2313 /* … … 2233 2318 if (pShared) 2234 2319 { 2235 rc = rtFsIsoCore_InitFrom 9660DirRec(&pShared->Core, pDirRec, cDirRecs, offDirRec, 0 /*uVersion*/, pThis);2320 rc = rtFsIsoCore_InitFromUdfIcbAndFileIdDesc(&pShared->Core, pAllocDesc, pFileIdDesc, pThis); 2236 2321 if (RT_SUCCESS(rc)) 2237 2322 { 2238 2323 RTListInit(&pShared->OpenChildren); 2239 pShared->cbDir = ISO9660_GET_ENDIAN(&pDirRec->cbData); 2240 pShared->pbDir = (uint8_t *)RTMemAllocZ(pShared->cbDir + 256); 2241 if (pShared->pbDir) 2324 2325 if (pShared->Core.cbObject < RTFSISO_MAX_DIR_SIZE) 2242 2326 { 2243 rc = RTVfsFileReadAt(pThis->hVfsBacking, pShared->Core.FirstExtent.offDisk, pShared->pbDir, pShared->cbDir, NULL); 2244 if (RT_SUCCESS(rc)) 2327 pShared->cbDir = (uint32_t)pShared->Core.cbObject; 2328 pShared->pbDir = (uint8_t *)RTMemAllocZ(RT_ALIGN_32(pShared->cbDir, 512)); 2329 if (pShared->pbDir) 2245 2330 { 2331 rc = RTVfsFileReadAt(pThis->hVfsBacking, pShared->Core.FirstExtent.offDisk, pShared->pbDir, pShared->cbDir, NULL); 2332 if (RT_SUCCESS(rc)) 2333 { 2246 2334 #ifdef LOG_ENABLED 2247 rtFsIsoDirShrd_Log9660Content(pShared);2335 //rtFsIsoDirShrd_Log9660Content(pShared); 2248 2336 #endif 2249 2337 2250 /* 2251 * Link into parent directory so we can use it to update 2252 * our directory entry. 2253 */ 2254 if (pParentDir) 2255 rtFsIsoDirShrd_AddOpenChild(pParentDir, &pShared->Core); 2256 *ppShared = pShared; 2257 return VINF_SUCCESS; 2338 /* 2339 * Link into parent directory so we can use it to update 2340 * our directory entry. 2341 */ 2342 if (pParentDir) 2343 rtFsIsoDirShrd_AddOpenChild(pParentDir, &pShared->Core); 2344 *ppShared = pShared; 2345 return VINF_SUCCESS; 2346 } 2258 2347 } 2259 2348 } … … 2261 2350 RTMemFree(pShared); 2262 2351 } 2352 2263 2353 *ppShared = NULL; 2264 2354 return rc; 2265 2355 } 2266 #endif2267 2356 2268 2357 … … 2721 2810 { 2722 2811 LogRel(("ISO/UDF: Warning: LVD::cPartitionMaps is %u but there are more bytes in the table. (off=%#x cb=%#x cbMapTable=%#x bType=%#x)\n", 2723 off, pHdr->cb, pLvd->cbMapTable, pHdr->bType));2812 cPartMaps - pLvd->cPartitionMaps, off, pHdr->cb, pLvd->cbMapTable, pHdr->bType)); 2724 2813 break; 2725 2814 } … … 2825 2914 */ 2826 2915 if ( pLvd->cbLogicalBlock < pThis->cbSector 2827 || pLvd->cbLogicalBlock > _16K2916 || pLvd->cbLogicalBlock > RTFSISO_MAX_LOGICAL_BLOCK_SIZE 2828 2917 || (pLvd->cbLogicalBlock % pThis->cbSector) != 0) 2829 2918 return RTERRINFO_LOG_SET_F(pErrInfo, VERR_ISOFS_UNSUPPORTED_LOGICAL_BLOCK_SIZE, … … 3004 3093 UDF_LOG2_MEMBER_ENTITY_ID(pDesc, idImplementation); 3005 3094 if (!ASMMemIsZero(&pDesc->ImplementationUse.ab[0], sizeof(pDesc->ImplementationUse.ab))) 3006 Log2(("ISO/UDF: %-32s\n%.128Rhx d\n", "ImplementationUse.ab[128]:", &pDesc->ImplementationUse.ab[0]));3095 Log2(("ISO/UDF: %-32s\n%.128RhxD\n", "ImplementationUse.ab[128]:", &pDesc->ImplementationUse.ab[0])); 3007 3096 UDF_LOG2_MEMBER_EXTENTAD(pDesc, IntegritySeqExtent); 3008 3097 if (pDesc->cbMapTable) … … 3139 3228 UDF_LOG2_MEMBER_SHORTAD(&pDesc->ContentsUse, Hdr.FreedSpaceBitmap); 3140 3229 if (!ASMMemIsZero(&pDesc->ContentsUse.Hdr.abReserved[0], sizeof(pDesc->ContentsUse.Hdr.abReserved))) 3141 Log2(("ISO/UDF: %-32s\n%.88Rhx d\n", "Hdr.abReserved[88]:", &pDesc->ContentsUse.Hdr.abReserved[0]));3230 Log2(("ISO/UDF: %-32s\n%.88RhxD\n", "Hdr.abReserved[88]:", &pDesc->ContentsUse.Hdr.abReserved[0])); 3142 3231 } 3143 3232 else if (!ASMMemIsZero(&pDesc->ContentsUse.ab[0], sizeof(pDesc->ContentsUse.ab))) 3144 Log2(("ISO/UDF: %-32s\n%.128Rhx d\n", "ContentsUse.ab[128]:", &pDesc->ContentsUse.ab[0]));3233 Log2(("ISO/UDF: %-32s\n%.128RhxD\n", "ContentsUse.ab[128]:", &pDesc->ContentsUse.ab[0])); 3145 3234 UDF_LOG2_MEMBER(pDesc, "#010RX32", uAccessType); 3146 3235 UDF_LOG2_MEMBER(pDesc, "#010RX32", offLocation); … … 3148 3237 UDF_LOG2_MEMBER_ENTITY_ID(pDesc, idImplementation); 3149 3238 if (!ASMMemIsZero(&pDesc->ImplementationUse.ab[0], sizeof(pDesc->ImplementationUse.ab))) 3150 Log2(("ISO/UDF: %-32s\n%.128Rhx d\n", "ImplementationUse.ab[128]:", &pDesc->ImplementationUse.ab[0]));3239 Log2(("ISO/UDF: %-32s\n%.128RhxD\n", "ImplementationUse.ab[128]:", &pDesc->ImplementationUse.ab[0])); 3151 3240 3152 3241 if (!ASMMemIsZero(&pDesc->abReserved[0], sizeof(pDesc->abReserved))) 3153 Log2(("ISO/UDF: %-32s\n%.156Rhx d\n", "ImplementationUse.ab[156]:", &pDesc->abReserved[0]));3242 Log2(("ISO/UDF: %-32s\n%.156RhxD\n", "ImplementationUse.ab[156]:", &pDesc->abReserved[0])); 3154 3243 } 3155 3244 #endif … … 3234 3323 UDF_LOG2_MEMBER_ENTITY_ID(&pDesc->ImplementationUse, Lvi.idImplementation); 3235 3324 if (!ASMMemIsZero(&pDesc->ImplementationUse.Lvi.abUse[0], sizeof(pDesc->ImplementationUse.Lvi.abUse))) 3236 Log2(("ISO/UDF: %-32s\n%.128Rhx d\n", "Lvi.abUse[128]:", &pDesc->ImplementationUse.Lvi.abUse[0]));3325 Log2(("ISO/UDF: %-32s\n%.128RhxD\n", "Lvi.abUse[128]:", &pDesc->ImplementationUse.Lvi.abUse[0])); 3237 3326 } 3238 3327 else if (!ASMMemIsZero(&pDesc->ImplementationUse.ab[0], sizeof(pDesc->ImplementationUse.ab))) 3239 Log2(("ISO/UDF: %-32s\n%.460Rhx d\n", "ImplementationUse.ab[460]:", &pDesc->ImplementationUse.ab[0]));3328 Log2(("ISO/UDF: %-32s\n%.460RhxD\n", "ImplementationUse.ab[460]:", &pDesc->ImplementationUse.ab[0])); 3240 3329 } 3241 3330 #endif … … 3808 3897 if (offSysUse < pVolDesc->RootDir.DirRec.cbDirRec) 3809 3898 { 3810 Log2(("ISO9660: RootDir System Use:\n%.*Rhx d\n",3899 Log2(("ISO9660: RootDir System Use:\n%.*RhxD\n", 3811 3900 pVolDesc->RootDir.DirRec.cbDirRec - offSysUse, &pVolDesc->RootDir.ab[offSysUse])); 3812 3901 } … … 4063 4152 union 4064 4153 { 4065 uint8_t ab[ _4K];4066 uint16_t au16[ _4K/ 2];4067 uint32_t au32[ _4K/ 4];4154 uint8_t ab[RTFSISO_MAX_LOGICAL_BLOCK_SIZE]; 4155 uint16_t au16[RTFSISO_MAX_LOGICAL_BLOCK_SIZE / 2]; 4156 uint32_t au32[RTFSISO_MAX_LOGICAL_BLOCK_SIZE / 4]; 4068 4157 ISO9660VOLDESCHDR VolDescHdr; 4069 4158 ISO9660BOOTRECORD BootRecord; … … 4254 4343 { 4255 4344 pThis->enmType = RTFSISOVOLTYPE_UDF; 4256 //return rtFsIsoDirShrd_NewUdf(pThis, xxx); 4257 return VERR_NOT_IMPLEMENTED; 4345 rc = rtFsIsoDirShrd_NewUdf(pThis, NULL /*pParent*/, &pThis->Udf.VolInfo.RootDirIcb, 4346 NULL /*pFileIdDesc*/, &pThis->pRootDir); 4347 /** @todo fall back on failure? */ 4348 return rc; 4258 4349 } 4259 4350 #else 4260 4351 if (uUdfLevel > 0 && !(fFlags & RTFSISO9660_F_NO_UDF) && /* Just disable this code for now: */ (fFlags & RT_BIT(24))) 4352 { 4261 4353 rc = rtFsIsoVolHandleUdfDetection(pThis, &uUdfLevel, offUdfBootVolDesc, Buf.ab, sizeof(Buf), pErrInfo); 4354 rc = rtFsIsoDirShrd_NewUdf(pThis, NULL /*pParent*/, &pThis->Udf.VolInfo.RootDirIcb, 4355 NULL /*pFileIdDesc*/, &pThis->pRootDir); 4356 } 4262 4357 4263 4358 /*
Note:
See TracChangeset
for help on using the changeset viewer.