Index: trunk/src/VBox/Runtime/common/fs/isovfs.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/fs/isovfs.cpp	(revision 69013)
+++ trunk/src/VBox/Runtime/common/fs/isovfs.cpp	(revision 69023)
@@ -50,303 +50,4 @@
 
 /** @todo move to err.h:   */
-#define VERR_ISOFS_IPE_0                                (-25390)
-
-
-/*********************************************************************************************************************************
-*   Structures and Typedefs                                                                                                      *
-*********************************************************************************************************************************/
-/** Pointer to an ISO volume (VFS instance data). */
-typedef struct RTFSISOVOL *PRTFSISOVOL;
-/** Pointer to a const ISO volume (VFS instance data). */
-typedef struct RTFSISOVOL const *PCRTFSISOVOL;
-
-/** Pointer to a ISO directory instance. */
-typedef struct RTFSISODIRSHRD *PRTFSISODIRSHRD;
-
-
-
-/**
- * ISO extent (internal to the VFS not a disk structure).
- */
-typedef struct RTFSISOEXTENT
-{
-    /** The disk offset. */
-    uint64_t            offDisk;
-    /** The size of the extent in bytes. */
-    uint64_t            cbExtent;
-} RTFSISOEXTENT;
-/** Pointer to an ISO 9660 extent. */
-typedef RTFSISOEXTENT *PRTFSISOEXTENT;
-/** Pointer to a const ISO 9660 extent. */
-typedef RTFSISOEXTENT const *PCRTFSISOEXTENT;
-
-
-/**
- * ISO file system object, shared part.
- */
-typedef struct RTFSISOCORE
-{
-    /** The parent directory keeps a list of open objects (RTFSISOCORE). */
-    RTLISTNODE          Entry;
-    /** Reference counter.   */
-    uint32_t volatile   cRefs;
-    /** The parent directory (not released till all children are close). */
-    PRTFSISODIRSHRD     pParentDir;
-    /** The byte offset of the first directory record. */
-    uint64_t            offDirRec;
-    /** Attributes. */
-    RTFMODE             fAttrib;
-    /** The object size. */
-    uint64_t            cbObject;
-    /** The access time. */
-    RTTIMESPEC          AccessTime;
-    /** The modificaton time. */
-    RTTIMESPEC          ModificationTime;
-    /** The change time. */
-    RTTIMESPEC          ChangeTime;
-    /** The birth time. */
-    RTTIMESPEC          BirthTime;
-    /** Pointer to the volume. */
-    PRTFSISOVOL         pVol;
-    /** The version number. */
-    uint32_t            uVersion;
-    /** Number of extents. */
-    uint32_t            cExtents;
-    /** The first extent. */
-    RTFSISOEXTENT       FirstExtent;
-    /** Array of additional extents. */
-    PRTFSISOEXTENT      paExtents;
-} RTFSISOCORE;
-typedef RTFSISOCORE *PRTFSISOCORE;
-
-/**
- * ISO file, shared data.
- */
-typedef struct RTFSISOFILESHRD
-{
-    /** Core ISO9660 object info.  */
-    RTFSISOCORE         Core;
-} RTFSISOFILESHRD;
-/** Pointer to a ISO 9660 file object. */
-typedef RTFSISOFILESHRD *PRTFSISOFILESHRD;
-
-
-/**
- * ISO directory, shared data.
- *
- * We will always read in the whole directory just to keep things really simple.
- */
-typedef struct RTFSISODIRSHRD
-{
-    /** Core ISO 9660 object info.  */
-    RTFSISOCORE         Core;
-    /** Open child objects (RTFSISOCORE). */
-    RTLISTNODE          OpenChildren;
-
-    /** Pointer to the directory content. */
-    uint8_t            *pbDir;
-    /** The size of the directory content (duplicate of Core.cbObject). */
-    uint32_t            cbDir;
-} RTFSISODIRSHRD;
-/** Pointer to a ISO directory instance. */
-typedef RTFSISODIRSHRD *PRTFSISODIRSHRD;
-
-
-/**
- * Private data for a VFS file object.
- */
-typedef struct RTFSISOFILEOBJ
-{
-    /** Pointer to the shared data. */
-    PRTFSISOFILESHRD    pShared;
-    /** The current file offset. */
-    uint64_t            offFile;
-} RTFSISOFILEOBJ;
-typedef RTFSISOFILEOBJ *PRTFSISOFILEOBJ;
-
-/**
- * Private data for a VFS directory object.
- */
-typedef struct RTFSISODIROBJ
-{
-    /** Pointer to the shared data. */
-    PRTFSISODIRSHRD     pShared;
-    /** The current directory offset. */
-    uint32_t            offDir;
-} RTFSISODIROBJ;
-typedef RTFSISODIROBJ *PRTFSISODIROBJ;
-
-/** Pointer to info about a UDF volume. */
-typedef struct RTFSISOUDFVOLINFO *PRTFSISOUDFVOLINFO;
-
-
-/** @name RTFSISO_UDF_PMAP_T_XXX
- * @{ */
-#define RTFSISO_UDF_PMAP_T_PLAIN        1
-#define RTFSISO_UDF_PMAP_T_VPM_15       2
-#define RTFSISO_UDF_PMAP_T_VPM_20       3
-#define RTFSISO_UDF_PMAP_T_SPM          4
-#define RTFSISO_UDF_PMAP_T_MPM          5
-/** @} */
-
-/**
- * Information about a logical UDF partition.
- *
- * This combins information from the partition descriptor, the UDFPARTMAPTYPE1
- * and the UDFPARTMAPTYPE2 structure.
- */
-typedef struct RTFSISOVOLUDFPMAP
-{
-    /** Partition starting location as a byte offset. */
-    uint64_t            offByteLocation;
-    /** Partition starting location (logical sector number). */
-    uint32_t            offLocation;
-    /** Number of sectors. */
-    uint32_t            cSectors;
-
-    /** Partition descriptor index (for processing). */
-    uint16_t            idxPartDesc;
-    /** Offset info the map table. */
-    uint16_t            offMapTable;
-    /** Partition number (not index). */
-    uint16_t            uPartitionNo;
-    /** Partition number (not index). */
-    uint16_t            uVolumeSeqNo;
-
-    /** The access type (UDF_PART_ACCESS_TYPE_XXX). */
-    uint32_t            uAccessType;
-    /** Partition flags (UDF_PARTITION_FLAGS_XXX). */
-    uint16_t            fFlags;
-    /** RTFSISO_UDF_PMAP_T_XXX. */
-    uint8_t             bType;
-    /** Set if Hdr is valid. */
-    bool                fHaveHdr;
-    /** Copy of UDFPARTITIONDESC::ContentsUse::Hdr. */
-    UDFPARTITIONHDRDESC Hdr;
-
-} RTFSISOVOLUDFPMAP;
-typedef RTFSISOVOLUDFPMAP *PRTFSISOVOLUDFPMAP;
-
-/**
- * Information about a UDF volume (/ volume set).
- *
- * This combines information from the primary and logical descriptors.
- *
- * @note There is only one volume per volume set in the current UDF
- *       implementation.  So, this can be considered a volume and a volume set.
- */
-typedef struct RTFSISOUDFVOLINFO
-{
-    /** The extent containing the file set descriptor. */
-    UDFLONGAD           FileSetDescriptor;
-
-    /** The root directory location (from the file set descriptor). */
-    UDFLONGAD           RootDirIcb;
-    /** Location of the system stream directory associated with the file set. */
-    UDFLONGAD           SystemStreamDirIcb;
-
-    /** The logical block size on this volume. */
-    uint32_t            cbBlock;
-    /** The log2 of cbBlock. */
-    uint32_t            cShiftBlock;
-    /** Flags (UDF_PVD_FLAGS_XXX). */
-    uint16_t            fFlags;
-
-    /** Number of partitions mapp in this volume. */
-    uint16_t            cPartitions;
-    /** Partitions in this volume. */
-    PRTFSISOVOLUDFPMAP  paPartitions;
-
-    /** The volume ID string. */
-    UDFDSTRING          achLogicalVolumeID[128];
-} RTFSISOUDFVOLINFO;
-
-
-/**
- * Indicates which of the possible content types we're accessing.
- */
-typedef enum RTFSISOVOLTYPE
-{
-    /** Accessing the primary ISO-9660 volume. */
-    RTFSISOVOLTYPE_ISO9960 = 0,
-    /** Accessing the joliet volume (secondary ISO-9660). */
-    RTFSISOVOLTYPE_JOLIET,
-    /** Accessing the UDF volume. */
-    RTFSISOVOLTYPE_UDF
-} RTFSISOVOLTYPE;
-
-/**
- * A ISO volume.
- */
-typedef struct RTFSISOVOL
-{
-    /** Handle to itself. */
-    RTVFS               hVfsSelf;
-    /** The file, partition, or whatever backing the ISO 9660 volume. */
-    RTVFSFILE           hVfsBacking;
-    /** The size of the backing thingy. */
-    uint64_t            cbBacking;
-    /** The size of the backing thingy in sectors (cbSector). */
-    uint64_t            cBackingSectors;
-    /** Flags. */
-    uint32_t            fFlags;
-    /** The sector size (in bytes). */
-    uint32_t            cbSector;
-    /** What we're accessing. */
-    RTFSISOVOLTYPE      enmType;
-
-    /** @name ISO 9660 specific data
-     *  @{ */
-    /** The size of a logical block in bytes. */
-    uint32_t            cbBlock;
-    /** The primary volume space size in blocks. */
-    uint32_t            cBlocksInPrimaryVolumeSpace;
-    /** The primary volume space size in bytes. */
-    uint64_t            cbPrimaryVolumeSpace;
-    /** The number of volumes in the set. */
-    uint32_t            cVolumesInSet;
-    /** The primary volume sequence ID. */
-    uint32_t            idPrimaryVol;
-    /** Set if using UTF16-2 (joliet). */
-    bool                fIsUtf16;
-    /** @} */
-
-    /** UDF specific data. */
-    struct
-    {
-        /** Volume information. */
-        RTFSISOUDFVOLINFO   VolInfo;
-        /** The UDF level. */
-        uint8_t             uLevel;
-    } Udf;
-
-    /** The root directory shared data. */
-    PRTFSISODIRSHRD     pRootDir;
-} RTFSISOVOL;
-
-
-/**
- * Info gathered from a VDS sequence.
- */
-typedef struct RTFSISOVDSINFO
-{
-    /** Number of entries in apPrimaryVols. */
-    uint32_t                cPrimaryVols;
-    /** Number of entries in apLogicalVols. */
-    uint32_t                cLogicalVols;
-    /** Number of entries in apPartitions. */
-    uint32_t                cPartitions;
-    /** Pointer to primary volume descriptors (native endian). */
-    PUDFPRIMARYVOLUMEDESC   apPrimaryVols[8];
-    /** Pointer to logical volume descriptors (native endian). */
-    PUDFLOGICALVOLUMEDESC   apLogicalVols[8];
-    /** Pointer to partition descriptors (native endian). */
-    PUDFPARTITIONDESC       apPartitions[16];
-
-    /** Created after scanning the sequence (here for cleanup purposes). */
-    PRTFSISOVOLUDFPMAP      paPartMaps;
-} RTFSISOVDSINFO;
-/** Pointer to VDS sequence info. */
-typedef RTFSISOVDSINFO *PRTFSISOVDSINFO;
 
 
@@ -355,4 +56,13 @@
 *   Defined Constants And Macros                                                                                                 *
 *********************************************************************************************************************************/
+/** The maximum logical block size. */
+#define RTFSISO_MAX_LOGICAL_BLOCK_SIZE                  _16K
+/** Max directory size. */
+#if ARCH_BITS == 32
+# define RTFSISO_MAX_DIR_SIZE                           _32M
+#else
+# define RTFSISO_MAX_DIR_SIZE                           _64M
+#endif
+
 /** Check if an entity ID field equals the given ID string. */
 #define UDF_ENTITY_ID_EQUALS(a_pEntityId, a_szId)  \
@@ -431,4 +141,304 @@
 
 
+
+/*********************************************************************************************************************************
+*   Structures and Typedefs                                                                                                      *
+*********************************************************************************************************************************/
+/** Pointer to an ISO volume (VFS instance data). */
+typedef struct RTFSISOVOL *PRTFSISOVOL;
+/** Pointer to a const ISO volume (VFS instance data). */
+typedef struct RTFSISOVOL const *PCRTFSISOVOL;
+
+/** Pointer to a ISO directory instance. */
+typedef struct RTFSISODIRSHRD *PRTFSISODIRSHRD;
+
+
+
+/**
+ * ISO extent (internal to the VFS not a disk structure).
+ */
+typedef struct RTFSISOEXTENT
+{
+    /** The disk offset. */
+    uint64_t            offDisk;
+    /** The size of the extent in bytes. */
+    uint64_t            cbExtent;
+} RTFSISOEXTENT;
+/** Pointer to an ISO 9660 extent. */
+typedef RTFSISOEXTENT *PRTFSISOEXTENT;
+/** Pointer to a const ISO 9660 extent. */
+typedef RTFSISOEXTENT const *PCRTFSISOEXTENT;
+
+
+/**
+ * ISO file system object, shared part.
+ */
+typedef struct RTFSISOCORE
+{
+    /** The parent directory keeps a list of open objects (RTFSISOCORE). */
+    RTLISTNODE          Entry;
+    /** Reference counter.   */
+    uint32_t volatile   cRefs;
+    /** The parent directory (not released till all children are close). */
+    PRTFSISODIRSHRD     pParentDir;
+    /** The byte offset of the first directory record. */
+    uint64_t            offDirRec;
+    /** Attributes. */
+    RTFMODE             fAttrib;
+    /** The object size. */
+    uint64_t            cbObject;
+    /** The access time. */
+    RTTIMESPEC          AccessTime;
+    /** The modificaton time. */
+    RTTIMESPEC          ModificationTime;
+    /** The change time. */
+    RTTIMESPEC          ChangeTime;
+    /** The birth time. */
+    RTTIMESPEC          BirthTime;
+    /** Pointer to the volume. */
+    PRTFSISOVOL         pVol;
+    /** The version number. */
+    uint32_t            uVersion;
+    /** Number of extents. */
+    uint32_t            cExtents;
+    /** The first extent. */
+    RTFSISOEXTENT       FirstExtent;
+    /** Array of additional extents. */
+    PRTFSISOEXTENT      paExtents;
+} RTFSISOCORE;
+typedef RTFSISOCORE *PRTFSISOCORE;
+
+/**
+ * ISO file, shared data.
+ */
+typedef struct RTFSISOFILESHRD
+{
+    /** Core ISO9660 object info.  */
+    RTFSISOCORE         Core;
+} RTFSISOFILESHRD;
+/** Pointer to a ISO 9660 file object. */
+typedef RTFSISOFILESHRD *PRTFSISOFILESHRD;
+
+
+/**
+ * ISO directory, shared data.
+ *
+ * We will always read in the whole directory just to keep things really simple.
+ */
+typedef struct RTFSISODIRSHRD
+{
+    /** Core ISO 9660 object info.  */
+    RTFSISOCORE         Core;
+    /** Open child objects (RTFSISOCORE). */
+    RTLISTNODE          OpenChildren;
+
+    /** Pointer to the directory content. */
+    uint8_t            *pbDir;
+    /** The size of the directory content (duplicate of Core.cbObject). */
+    uint32_t            cbDir;
+} RTFSISODIRSHRD;
+/** Pointer to a ISO directory instance. */
+typedef RTFSISODIRSHRD *PRTFSISODIRSHRD;
+
+
+/**
+ * Private data for a VFS file object.
+ */
+typedef struct RTFSISOFILEOBJ
+{
+    /** Pointer to the shared data. */
+    PRTFSISOFILESHRD    pShared;
+    /** The current file offset. */
+    uint64_t            offFile;
+} RTFSISOFILEOBJ;
+typedef RTFSISOFILEOBJ *PRTFSISOFILEOBJ;
+
+/**
+ * Private data for a VFS directory object.
+ */
+typedef struct RTFSISODIROBJ
+{
+    /** Pointer to the shared data. */
+    PRTFSISODIRSHRD     pShared;
+    /** The current directory offset. */
+    uint32_t            offDir;
+} RTFSISODIROBJ;
+typedef RTFSISODIROBJ *PRTFSISODIROBJ;
+
+/** Pointer to info about a UDF volume. */
+typedef struct RTFSISOUDFVOLINFO *PRTFSISOUDFVOLINFO;
+
+
+/** @name RTFSISO_UDF_PMAP_T_XXX
+ * @{ */
+#define RTFSISO_UDF_PMAP_T_PLAIN        1
+#define RTFSISO_UDF_PMAP_T_VPM_15       2
+#define RTFSISO_UDF_PMAP_T_VPM_20       3
+#define RTFSISO_UDF_PMAP_T_SPM          4
+#define RTFSISO_UDF_PMAP_T_MPM          5
+/** @} */
+
+/**
+ * Information about a logical UDF partition.
+ *
+ * This combins information from the partition descriptor, the UDFPARTMAPTYPE1
+ * and the UDFPARTMAPTYPE2 structure.
+ */
+typedef struct RTFSISOVOLUDFPMAP
+{
+    /** Partition starting location as a byte offset. */
+    uint64_t            offByteLocation;
+    /** Partition starting location (logical sector number). */
+    uint32_t            offLocation;
+    /** Number of sectors. */
+    uint32_t            cSectors;
+
+    /** Partition descriptor index (for processing). */
+    uint16_t            idxPartDesc;
+    /** Offset info the map table. */
+    uint16_t            offMapTable;
+    /** Partition number (not index). */
+    uint16_t            uPartitionNo;
+    /** Partition number (not index). */
+    uint16_t            uVolumeSeqNo;
+
+    /** The access type (UDF_PART_ACCESS_TYPE_XXX). */
+    uint32_t            uAccessType;
+    /** Partition flags (UDF_PARTITION_FLAGS_XXX). */
+    uint16_t            fFlags;
+    /** RTFSISO_UDF_PMAP_T_XXX. */
+    uint8_t             bType;
+    /** Set if Hdr is valid. */
+    bool                fHaveHdr;
+    /** Copy of UDFPARTITIONDESC::ContentsUse::Hdr. */
+    UDFPARTITIONHDRDESC Hdr;
+
+} RTFSISOVOLUDFPMAP;
+typedef RTFSISOVOLUDFPMAP *PRTFSISOVOLUDFPMAP;
+
+/**
+ * Information about a UDF volume (/ volume set).
+ *
+ * This combines information from the primary and logical descriptors.
+ *
+ * @note There is only one volume per volume set in the current UDF
+ *       implementation.  So, this can be considered a volume and a volume set.
+ */
+typedef struct RTFSISOUDFVOLINFO
+{
+    /** The extent containing the file set descriptor. */
+    UDFLONGAD           FileSetDescriptor;
+
+    /** The root directory location (from the file set descriptor). */
+    UDFLONGAD           RootDirIcb;
+    /** Location of the system stream directory associated with the file set. */
+    UDFLONGAD           SystemStreamDirIcb;
+
+    /** The logical block size on this volume. */
+    uint32_t            cbBlock;
+    /** The log2 of cbBlock. */
+    uint32_t            cShiftBlock;
+    /** Flags (UDF_PVD_FLAGS_XXX). */
+    uint16_t            fFlags;
+
+    /** Number of partitions mapp in this volume. */
+    uint16_t            cPartitions;
+    /** Partitions in this volume. */
+    PRTFSISOVOLUDFPMAP  paPartitions;
+
+    /** The volume ID string. */
+    UDFDSTRING          achLogicalVolumeID[128];
+} RTFSISOUDFVOLINFO;
+
+
+/**
+ * Indicates which of the possible content types we're accessing.
+ */
+typedef enum RTFSISOVOLTYPE
+{
+    /** Accessing the primary ISO-9660 volume. */
+    RTFSISOVOLTYPE_ISO9960 = 0,
+    /** Accessing the joliet volume (secondary ISO-9660). */
+    RTFSISOVOLTYPE_JOLIET,
+    /** Accessing the UDF volume. */
+    RTFSISOVOLTYPE_UDF
+} RTFSISOVOLTYPE;
+
+/**
+ * A ISO volume.
+ */
+typedef struct RTFSISOVOL
+{
+    /** Handle to itself. */
+    RTVFS               hVfsSelf;
+    /** The file, partition, or whatever backing the ISO 9660 volume. */
+    RTVFSFILE           hVfsBacking;
+    /** The size of the backing thingy. */
+    uint64_t            cbBacking;
+    /** The size of the backing thingy in sectors (cbSector). */
+    uint64_t            cBackingSectors;
+    /** Flags. */
+    uint32_t            fFlags;
+    /** The sector size (in bytes). */
+    uint32_t            cbSector;
+    /** What we're accessing. */
+    RTFSISOVOLTYPE      enmType;
+
+    /** @name ISO 9660 specific data
+     *  @{ */
+    /** The size of a logical block in bytes. */
+    uint32_t            cbBlock;
+    /** The primary volume space size in blocks. */
+    uint32_t            cBlocksInPrimaryVolumeSpace;
+    /** The primary volume space size in bytes. */
+    uint64_t            cbPrimaryVolumeSpace;
+    /** The number of volumes in the set. */
+    uint32_t            cVolumesInSet;
+    /** The primary volume sequence ID. */
+    uint32_t            idPrimaryVol;
+    /** Set if using UTF16-2 (joliet). */
+    bool                fIsUtf16;
+    /** @} */
+
+    /** UDF specific data. */
+    struct
+    {
+        /** Volume information. */
+        RTFSISOUDFVOLINFO   VolInfo;
+        /** The UDF level. */
+        uint8_t             uLevel;
+    } Udf;
+
+    /** The root directory shared data. */
+    PRTFSISODIRSHRD     pRootDir;
+} RTFSISOVOL;
+
+
+/**
+ * Info gathered from a VDS sequence.
+ */
+typedef struct RTFSISOVDSINFO
+{
+    /** Number of entries in apPrimaryVols. */
+    uint32_t                cPrimaryVols;
+    /** Number of entries in apLogicalVols. */
+    uint32_t                cLogicalVols;
+    /** Number of entries in apPartitions. */
+    uint32_t                cPartitions;
+    /** Pointer to primary volume descriptors (native endian). */
+    PUDFPRIMARYVOLUMEDESC   apPrimaryVols[8];
+    /** Pointer to logical volume descriptors (native endian). */
+    PUDFLOGICALVOLUMEDESC   apLogicalVols[8];
+    /** Pointer to partition descriptors (native endian). */
+    PUDFPARTITIONDESC       apPartitions[16];
+
+    /** Created after scanning the sequence (here for cleanup purposes). */
+    PRTFSISOVOLUDFPMAP      paPartMaps;
+} RTFSISOVDSINFO;
+/** Pointer to VDS sequence info. */
+typedef RTFSISOVDSINFO *PRTFSISOVDSINFO;
+
+
+
 /*********************************************************************************************************************************
 *   Global Variables                                                                                                             *
@@ -769,4 +779,85 @@
         }
     }
+    return VINF_SUCCESS;
+}
+
+
+static int rtFsIsoCore_InitFromUdfIcbAndFileIdDesc(PRTFSISOCORE pCore, PCUDFLONGAD pAllocDesc,
+                                                   PCUDFFILEIDDESC pFileIdDesc, PRTFSISOVOL pThis)
+{
+#if 1
+    RT_NOREF(pCore, pAllocDesc, pFileIdDesc, pThis);
+#else
+    /*
+     * Allocate a temporary buffer.
+     */
+    if (pAllocDesc->cb > _64K)
+        return VERR_ISOFS_DIR_ICB_TOO_BIG;
+    if (pAllocDesc->cb < sizeof(UDFTAG) + sizeof(UDFICBTAG))
+        return VERR_ISOFS_DIR_ICB_TOO_SMALL;
+
+    size_t const    cbBuf = pThis->Udf.VolInfo.cbBlock * 2;
+    uint8_t * const pbBuf = RTMemTmpAlloc(pThis->Udf.VolInfo.cbBlock * 2);
+    if (!pbBuf)
+        return VERR_NO_TMP_MEMORY;
+
+    /*
+     *
+     */
+    uint32_t offIcb = 0;
+    int      rc;
+    do
+    {
+        size_t cbToRead = RT_MIN(cbBuf, pAllocDesc->cb);
+        rc = rtFsIsoVolUdfVpRead(pThis, pAllocDesc->Location.uPartitionNo, pAllocDesc->Location.off, offIcb, pbBuf, cbToRead);
+        if (RT_FAILURE(rc))
+            break;
+
+
+    } while (0);
+
+
+    /*
+     * Read the ICB into a temporary buffer.
+     */
+
+    uint32_t cbBuf = RT_ALIGN_32(pAllocDesc->cb, pThis->cbSector);
+    void *pvBuf = RTMemTmpAllocZ(cbBuf);
+    if (!pvBuf)
+        return VERR_NO_TMP_MEMORY;
+
+    int rc = rtFsIsoVolUdfVpRead(pThis, pAllocDesc->Location.uPartitionNo,  pAllocDesc->Location.off, 0, pvBuf, cbBuf);
+    if (RT_SUCCESS(rc))
+    {
+        /*
+         * Parse the buffer.
+         */
+        size_t   cbLeft = pAllocDesc->cb;
+        uint8_t *pbCur  = (uint8_t *)
+        do
+        {
+            PCUDFFILEENTRY pFe = (PCUDFFILEENTRY)pbCur;
+
+        }
+
+        while (cbLeft > 0)
+        {
+            PCUDFFILEENTRY pFe = (PCUDFFILEENTRY)pbCur;
+
+        }
+
+
+        union
+        {
+            void               *pv;
+            PCUDFFILEENTRY      pFe;
+            PCUDFEXFILEENTRY    pExFe;
+        } uBuf;
+
+
+    }
+    RTMemTmpFree(uBuf.pv);
+#endif
+
     return VINF_SUCCESS;
 }
@@ -2138,5 +2229,5 @@
             if (offSysUse < pDirRec->cbDirRec)
             {
-                Log2(("ISO9660:       system use (%#x bytes):\n%.*Rhxd\n", pDirRec->cbDirRec - offSysUse,
+                Log2(("ISO9660:       system use (%#x bytes):\n%.*RhxD\n", pDirRec->cbDirRec - offSysUse,
                       pDirRec->cbDirRec - offSysUse, (uint8_t *)pDirRec + offSysUse));
             }
@@ -2206,7 +2297,6 @@
 
 
-#if 0
-/**
- * Instantiates a new shared directory structure, given 9660 records.
+/**
+ * Instantiates a new shared directory structure, given UDF descriptors.
  *
  * @returns IPRT status code.
@@ -2214,15 +2304,10 @@
  * @param   pParentDir      The parent directory.  This is NULL for the root
  *                          directory.
- * @param   pDirRec         The directory record.  Will access @a cDirRecs
- *                          records.
- * @param   cDirRecs        Number of directory records if more than one.
- * @param   offDirRec       The byte offset of the directory record.
+ * @param   pAllocDesc      The allocation descriptor for the directory ICB.
+ * @param   pFileIdDesc     The file ID descriptor.  This is NULL for the root.
  * @param   ppShared        Where to return the shared directory structure.
  */
-static int rtFsIsoDirShrd_NewUdf(PRTFSISOVOL pThis, PRTFSISODIRSHRD pParentDir,
-                                 PCUDFEXTVOLDESCNSR
-
-                                 PCISO9660DIRREC pDirRec, uint32_t cDirRecs, uint64_t offDirRec,
-                                 PRTFSISODIRSHRD *ppShared)
+static int rtFsIsoDirShrd_NewUdf(PRTFSISOVOL pThis, PRTFSISODIRSHRD pParentDir, PCUDFLONGAD pAllocDesc,
+                                 PCUDFFILEIDDESC pFileIdDesc, PRTFSISODIRSHRD *ppShared)
 {
     /*
@@ -2233,27 +2318,31 @@
     if (pShared)
     {
-        rc = rtFsIsoCore_InitFrom9660DirRec(&pShared->Core, pDirRec, cDirRecs, offDirRec, 0 /*uVersion*/, pThis);
+        rc = rtFsIsoCore_InitFromUdfIcbAndFileIdDesc(&pShared->Core, pAllocDesc, pFileIdDesc, pThis);
         if (RT_SUCCESS(rc))
         {
             RTListInit(&pShared->OpenChildren);
-            pShared->cbDir = ISO9660_GET_ENDIAN(&pDirRec->cbData);
-            pShared->pbDir = (uint8_t *)RTMemAllocZ(pShared->cbDir + 256);
-            if (pShared->pbDir)
+
+            if (pShared->Core.cbObject < RTFSISO_MAX_DIR_SIZE)
             {
-                rc = RTVfsFileReadAt(pThis->hVfsBacking, pShared->Core.FirstExtent.offDisk, pShared->pbDir, pShared->cbDir, NULL);
-                if (RT_SUCCESS(rc))
+                pShared->cbDir = (uint32_t)pShared->Core.cbObject;
+                pShared->pbDir = (uint8_t *)RTMemAllocZ(RT_ALIGN_32(pShared->cbDir, 512));
+                if (pShared->pbDir)
                 {
+                    rc = RTVfsFileReadAt(pThis->hVfsBacking, pShared->Core.FirstExtent.offDisk, pShared->pbDir, pShared->cbDir, NULL);
+                    if (RT_SUCCESS(rc))
+                    {
 #ifdef LOG_ENABLED
-                    rtFsIsoDirShrd_Log9660Content(pShared);
+                        //rtFsIsoDirShrd_Log9660Content(pShared);
 #endif
 
-                    /*
-                     * Link into parent directory so we can use it to update
-                     * our directory entry.
-                     */
-                    if (pParentDir)
-                        rtFsIsoDirShrd_AddOpenChild(pParentDir, &pShared->Core);
-                    *ppShared = pShared;
-                    return VINF_SUCCESS;
+                        /*
+                         * Link into parent directory so we can use it to update
+                         * our directory entry.
+                         */
+                        if (pParentDir)
+                            rtFsIsoDirShrd_AddOpenChild(pParentDir, &pShared->Core);
+                        *ppShared = pShared;
+                        return VINF_SUCCESS;
+                    }
                 }
             }
@@ -2261,8 +2350,8 @@
         RTMemFree(pShared);
     }
+
     *ppShared = NULL;
     return rc;
 }
-#endif
 
 
@@ -2721,5 +2810,5 @@
             {
                 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",
-                        off, pHdr->cb, pLvd->cbMapTable, pHdr->bType));
+                        cPartMaps - pLvd->cPartitionMaps, off, pHdr->cb, pLvd->cbMapTable, pHdr->bType));
                 break;
             }
@@ -2825,5 +2914,5 @@
      */
     if (   pLvd->cbLogicalBlock < pThis->cbSector
-        || pLvd->cbLogicalBlock > _16K
+        || pLvd->cbLogicalBlock > RTFSISO_MAX_LOGICAL_BLOCK_SIZE
         || (pLvd->cbLogicalBlock % pThis->cbSector) != 0)
         return RTERRINFO_LOG_SET_F(pErrInfo, VERR_ISOFS_UNSUPPORTED_LOGICAL_BLOCK_SIZE,
@@ -3004,5 +3093,5 @@
         UDF_LOG2_MEMBER_ENTITY_ID(pDesc, idImplementation);
         if (!ASMMemIsZero(&pDesc->ImplementationUse.ab[0], sizeof(pDesc->ImplementationUse.ab)))
-            Log2(("ISO/UDF:   %-32s\n%.128Rhxd\n", "ImplementationUse.ab[128]:", &pDesc->ImplementationUse.ab[0]));
+            Log2(("ISO/UDF:   %-32s\n%.128RhxD\n", "ImplementationUse.ab[128]:", &pDesc->ImplementationUse.ab[0]));
         UDF_LOG2_MEMBER_EXTENTAD(pDesc, IntegritySeqExtent);
         if (pDesc->cbMapTable)
@@ -3139,8 +3228,8 @@
             UDF_LOG2_MEMBER_SHORTAD(&pDesc->ContentsUse, Hdr.FreedSpaceBitmap);
             if (!ASMMemIsZero(&pDesc->ContentsUse.Hdr.abReserved[0], sizeof(pDesc->ContentsUse.Hdr.abReserved)))
-                Log2(("ISO/UDF:   %-32s\n%.88Rhxd\n", "Hdr.abReserved[88]:", &pDesc->ContentsUse.Hdr.abReserved[0]));
+                Log2(("ISO/UDF:   %-32s\n%.88RhxD\n", "Hdr.abReserved[88]:", &pDesc->ContentsUse.Hdr.abReserved[0]));
         }
         else if (!ASMMemIsZero(&pDesc->ContentsUse.ab[0], sizeof(pDesc->ContentsUse.ab)))
-            Log2(("ISO/UDF:   %-32s\n%.128Rhxd\n", "ContentsUse.ab[128]:", &pDesc->ContentsUse.ab[0]));
+            Log2(("ISO/UDF:   %-32s\n%.128RhxD\n", "ContentsUse.ab[128]:", &pDesc->ContentsUse.ab[0]));
         UDF_LOG2_MEMBER(pDesc, "#010RX32", uAccessType);
         UDF_LOG2_MEMBER(pDesc, "#010RX32", offLocation);
@@ -3148,8 +3237,8 @@
         UDF_LOG2_MEMBER_ENTITY_ID(pDesc, idImplementation);
         if (!ASMMemIsZero(&pDesc->ImplementationUse.ab[0], sizeof(pDesc->ImplementationUse.ab)))
-            Log2(("ISO/UDF:   %-32s\n%.128Rhxd\n", "ImplementationUse.ab[128]:", &pDesc->ImplementationUse.ab[0]));
+            Log2(("ISO/UDF:   %-32s\n%.128RhxD\n", "ImplementationUse.ab[128]:", &pDesc->ImplementationUse.ab[0]));
 
         if (!ASMMemIsZero(&pDesc->abReserved[0], sizeof(pDesc->abReserved)))
-            Log2(("ISO/UDF:   %-32s\n%.156Rhxd\n", "ImplementationUse.ab[156]:", &pDesc->abReserved[0]));
+            Log2(("ISO/UDF:   %-32s\n%.156RhxD\n", "ImplementationUse.ab[156]:", &pDesc->abReserved[0]));
     }
 #endif
@@ -3234,8 +3323,8 @@
             UDF_LOG2_MEMBER_ENTITY_ID(&pDesc->ImplementationUse, Lvi.idImplementation);
             if (!ASMMemIsZero(&pDesc->ImplementationUse.Lvi.abUse[0], sizeof(pDesc->ImplementationUse.Lvi.abUse)))
-                Log2(("ISO/UDF:   %-32s\n%.128Rhxd\n", "Lvi.abUse[128]:", &pDesc->ImplementationUse.Lvi.abUse[0]));
+                Log2(("ISO/UDF:   %-32s\n%.128RhxD\n", "Lvi.abUse[128]:", &pDesc->ImplementationUse.Lvi.abUse[0]));
         }
         else if (!ASMMemIsZero(&pDesc->ImplementationUse.ab[0], sizeof(pDesc->ImplementationUse.ab)))
-            Log2(("ISO/UDF:   %-32s\n%.460Rhxd\n", "ImplementationUse.ab[460]:", &pDesc->ImplementationUse.ab[0]));
+            Log2(("ISO/UDF:   %-32s\n%.460RhxD\n", "ImplementationUse.ab[460]:", &pDesc->ImplementationUse.ab[0]));
     }
 #endif
@@ -3808,5 +3897,5 @@
         if (offSysUse < pVolDesc->RootDir.DirRec.cbDirRec)
         {
-            Log2(("ISO9660:  RootDir System Use:\n%.*Rhxd\n",
+            Log2(("ISO9660:  RootDir System Use:\n%.*RhxD\n",
                   pVolDesc->RootDir.DirRec.cbDirRec - offSysUse, &pVolDesc->RootDir.ab[offSysUse]));
         }
@@ -4063,7 +4152,7 @@
     union
     {
-        uint8_t                 ab[_4K];
-        uint16_t                au16[_4K / 2];
-        uint32_t                au32[_4K / 4];
+        uint8_t                 ab[RTFSISO_MAX_LOGICAL_BLOCK_SIZE];
+        uint16_t                au16[RTFSISO_MAX_LOGICAL_BLOCK_SIZE / 2];
+        uint32_t                au32[RTFSISO_MAX_LOGICAL_BLOCK_SIZE / 4];
         ISO9660VOLDESCHDR       VolDescHdr;
         ISO9660BOOTRECORD       BootRecord;
@@ -4254,10 +4343,16 @@
     {
         pThis->enmType = RTFSISOVOLTYPE_UDF;
-        //return rtFsIsoDirShrd_NewUdf(pThis, xxx);
-        return VERR_NOT_IMPLEMENTED;
+        rc = rtFsIsoDirShrd_NewUdf(pThis, NULL /*pParent*/, &pThis->Udf.VolInfo.RootDirIcb,
+                                   NULL /*pFileIdDesc*/, &pThis->pRootDir);
+        /** @todo fall back on failure? */
+        return rc;
     }
 #else
     if (uUdfLevel > 0 && !(fFlags & RTFSISO9660_F_NO_UDF) && /* Just disable this code for now: */ (fFlags & RT_BIT(24)))
+    {
         rc = rtFsIsoVolHandleUdfDetection(pThis, &uUdfLevel, offUdfBootVolDesc, Buf.ab, sizeof(Buf), pErrInfo);
+        rc = rtFsIsoDirShrd_NewUdf(pThis, NULL /*pParent*/, &pThis->Udf.VolInfo.RootDirIcb,
+                                   NULL /*pFileIdDesc*/, &pThis->pRootDir);
+    }
 
     /*
