VirtualBox

Changeset 69027 in vbox


Ignore:
Timestamp:
Oct 10, 2017 3:48:37 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
118302
Message:

IPRT: UDF reading updates.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/formats/udf.h

    r69023 r69027  
    11211121/** Using UDFEXTAD. */
    11221122#define UDF_ICB_FLAGS_AD_TYPE_EXTENDED          UINT16_C(0x0002)
    1123 /** Single descriptor. */
    1124 #define UDF_ICB_FLAGS_AD_TYPE_SINGLE            UINT16_C(0x0003)
     1123/** File content is embedded in the allocation descriptor area. */
     1124#define UDF_ICB_FLAGS_AD_TYPE_EMBEDDED          UINT16_C(0x0003)
    11251125/** Allocation type mask. */
    11261126#define UDF_ICB_FLAGS_AD_TYPE_MASK              UINT16_C(0x0007)
     
    11791179#define UDF_FILE_TYPE_METADATA_BITMAP_FILE      UINT8_C(0xfc)
    11801180/** @} */
     1181
     1182
     1183/**
     1184 * UDF ICB header (derived structure).
     1185 */
     1186typedef struct UDFICBHDR
     1187{
     1188    /** 0x00: The descriptor tag (UDF_TAG_ID_INDIRECT_ENTRY). */
     1189    UDFTAG          Tag;
     1190    /** 0x10: ICB Tag. */
     1191    UDFICBTAG       IcbTag;
     1192} UDFICBHDR;
     1193AssertCompileSize(UDFICBHDR, 36);
     1194/** Pointer to an UDF ICB header. */
     1195typedef UDFICBHDR *PUDFICBHDR;
     1196/** Pointer to a const UDF ICB header. */
     1197typedef UDFICBHDR const *PCUDFICBHDR;
    11811198
    11821199
  • trunk/src/VBox/Runtime/common/fs/isovfs.cpp

    r69023 r69027  
    160160typedef struct RTFSISOEXTENT
    161161{
    162     /** The disk offset. */
    163     uint64_t            offDisk;
     162    /** The disk or partition byte offset.
     163     * This is set to UINT64_MAX for parts of sparse files that aren't  recorded.*/
     164    uint64_t            off;
    164165    /** The size of the extent in bytes. */
    165166    uint64_t            cbExtent;
     167    /** UDF virtual partition number, UINT32_MAX for ISO 9660. */
     168    uint32_t            idxPart;
     169    /** Reserved.   */
     170    uint32_t            uReserved;
    166171} RTFSISOEXTENT;
    167172/** Pointer to an ISO 9660 extent. */
     
    454459static PRTFSISOCORE rtFsIsoDir_LookupShared(PRTFSISODIRSHRD pThis, uint64_t offDirRec);
    455460
     461static int rtFsIsoVolValidateUdfDescCrc(PCUDFTAG pTag, size_t cbDesc, PRTERRINFO pErrInfo);
     462static int rtFsIsoVolValidateUdfDescTag(PCUDFTAG pTag, uint16_t idTag, uint32_t offTag, PRTERRINFO pErrInfo);
     463static int rtFsIsoVolValidateUdfDescTagAndCrc(PCUDFTAG pTag, size_t cbDesc, uint16_t idTag, uint32_t offTag, PRTERRINFO pErrInfo);
     464
    456465
    457466/**
     
    727736    pCore->cExtents             = 1;
    728737    pCore->FirstExtent.cbExtent = pCore->cbObject;
    729     pCore->FirstExtent.offDisk  = (ISO9660_GET_ENDIAN(&pDirRec->offExtent) + pDirRec->cExtAttrBlocks) * (uint64_t)pVol->cbBlock;
     738    pCore->FirstExtent.off      = (ISO9660_GET_ENDIAN(&pDirRec->offExtent) + pDirRec->cExtAttrBlocks) * (uint64_t)pVol->cbBlock;
     739    pCore->FirstExtent.idxPart  = UINT32_MAX;
     740    pCore->FirstExtent.uReserved = 0;
    730741
    731742    rtFsIso9660DateTime2TimeSpec(&pCore->ModificationTime, &pDirRec->RecTime);
     
    748759            if (pDirRec->cbDirRec != 0)
    749760            {
    750                 uint64_t offDisk = ISO9660_GET_ENDIAN(&pDirRec->offExtent) * (uint64_t)pVol->cbBlock;
    751                 uint32_t cbExtent  = ISO9660_GET_ENDIAN(&pDirRec->cbData);
     761                uint64_t offDisk  = ISO9660_GET_ENDIAN(&pDirRec->offExtent) * (uint64_t)pVol->cbBlock;
     762                uint32_t cbExtent = ISO9660_GET_ENDIAN(&pDirRec->cbData);
    752763                pCore->cbObject += cbExtent;
    753764
    754                 if (pCurExtent->offDisk + pCurExtent->cbExtent == offDisk)
     765                if (pCurExtent->off + pCurExtent->cbExtent == offDisk)
    755766                    pCurExtent->cbExtent += cbExtent;
    756767                else
     
    765776                    }
    766777                    pCurExtent = &pCore->paExtents[pCore->cExtents - 1];
    767                     pCurExtent->cbExtent = cbExtent;
    768                     pCurExtent->offDisk  = offDisk;
     778                    pCurExtent->cbExtent  = cbExtent;
     779                    pCurExtent->off       = offDisk;
     780                    pCurExtent->idxPart   = UINT32_MAX;
     781                    pCurExtent->uReserved = 0;
    769782                    pCore->cExtents++;
    770783                }
     
    782795}
    783796
     797/** No direct ICB entries found. */
     798#define VERR_ISOFS_NO_DIRECT_ICB_ENTRIES                (-25336)
     799/** Too many ICB indirections, possibly a loop. */
     800#define VERR_ISOFS_TOO_MANY_ICB_INDIRECTIONS            (-25337)
     801/** Too deep ICB recursion. */
     802#define VERR_ISOFS_TOO_DEEP_ICB_RECURSION               (-25338)
     803/** ICB is too small to contain anything useful.   */
     804#define VERR_ISOFS_ICB_TOO_SMALL                        (-25339)
     805/** Unsupported tag encountered in ICB. */
     806#define VERR_ISOFS_UNSUPPORTED_ICB                      (-25340)
     807/** Bad file entry (ICB). */
     808#define VERR_ISOFS_BAD_FILE_ENTRY                       (-25341)
     809/** Unknown allocation descriptor type.   */
     810#define VERR_ISO_FS_UNKNOWN_AD_TYPE                     (-25342)
     811/** Malformed extended allocation descriptor. */
     812#define VERR_ISOFS_BAD_EXTAD                            (-25343)
     813
     814
     815/**
     816 * Initalizes the allocation extends of a core structure.
     817 *
     818 * @returns IPRT status code
     819 * @param   pCore           .
     820 * @param   pbAllocDescs    .
     821 * @param   cbAllocDescs    .
     822 * @param   fIcbTagFlags    .
     823 * @param   idxDefaultPart  .
     824 * @param   offAllocDescs   .
     825 * @param   pThis           .
     826 */
     827static int rtFsIsoCore_InitExtentsUdfIcbEntry(PRTFSISOCORE pCore, uint8_t const *pbAllocDescs, uint32_t cbAllocDescs,
     828                                              uint32_t fIcbTagFlags, uint32_t idxDefaultPart, uint64_t offAllocDescs,
     829                                              PRTFSISOVOL pThis)
     830{
     831    /*
     832     * Just in case there are mutiple file entries in the ICB.
     833     */
     834    if (pCore->paExtents != NULL)
     835    {
     836        LogRelMax(45, ("ISO/UDF: Re-reading extents - multiple file entries?\n"));
     837        RTMemFree(pCore->paExtents);
     838        pCore->paExtents = NULL;
     839    }
     840
     841    /*
     842     * Figure the (minimal) size of an allocation descriptor, deal with the
     843     * embedded storage and invalid descriptor types.
     844     */
     845    uint32_t cbOneDesc;
     846    switch (fIcbTagFlags & UDF_ICB_FLAGS_AD_TYPE_MASK)
     847    {
     848        case UDF_ICB_FLAGS_AD_TYPE_EMBEDDED:
     849            pCore->cExtents             = 1;
     850            pCore->FirstExtent.cbExtent = cbAllocDescs;
     851            pCore->FirstExtent.off      = offAllocDescs;
     852            pCore->FirstExtent.idxPart  = idxDefaultPart;
     853            return VINF_SUCCESS;
     854
     855        case UDF_ICB_FLAGS_AD_TYPE_SHORT:       cbOneDesc = sizeof(UDFSHORTAD); break;
     856        case UDF_ICB_FLAGS_AD_TYPE_LONG:        cbOneDesc = sizeof(UDFLONGAD); break;
     857        case UDF_ICB_FLAGS_AD_TYPE_EXTENDED:    cbOneDesc = sizeof(UDFEXTAD); break;
     858
     859        default:
     860            LogRelMax(45, ("ISO/UDF: Unknown allocation descriptor type %#x\n", fIcbTagFlags));
     861            return VERR_ISO_FS_UNKNOWN_AD_TYPE;
     862    }
     863    if (cbAllocDescs >= cbOneDesc)
     864    {
     865        /*
     866         * Loop thru the allocation descriptors.
     867         */
     868        PRTFSISOEXTENT pCurExtent = NULL;
     869        union
     870        {
     871            uint8_t const  *pb;
     872            PCUDFSHORTAD    pShort;
     873            PCUDFLONGAD     pLong;
     874            PCUDFEXTAD      pExt;
     875        } uPtr;
     876        uPtr.pb = pbAllocDescs;
     877        do
     878        {
     879            /* Extract the information we need from the descriptor. */
     880            uint32_t idxBlock;
     881            uint32_t idxPart;
     882            uint32_t cb;
     883            uint8_t  uType;
     884            switch (fIcbTagFlags & UDF_ICB_FLAGS_AD_TYPE_MASK)
     885            {
     886                case UDF_ICB_FLAGS_AD_TYPE_SHORT:
     887                    uType    = uPtr.pShort->uType;
     888                    cb       = uPtr.pShort->cb;
     889                    idxBlock = uPtr.pShort->off;
     890                    idxPart  = idxDefaultPart;
     891                    cbAllocDescs -= sizeof(*uPtr.pShort);
     892                    uPtr.pShort++;
     893                    break;
     894                case UDF_ICB_FLAGS_AD_TYPE_LONG:
     895                    uType    = uPtr.pLong->uType;
     896                    cb       = uPtr.pLong->cb;
     897                    idxBlock = uPtr.pLong->Location.off;
     898                    idxPart  = uPtr.pLong->Location.uPartitionNo;
     899                    cbAllocDescs -= sizeof(*uPtr.pLong);
     900                    uPtr.pLong++;
     901                    break;
     902                case UDF_ICB_FLAGS_AD_TYPE_EXTENDED:
     903                    if (   uPtr.pExt->cbInformation > cbAllocDescs
     904                        || uPtr.pExt->cbInformation < sizeof(*uPtr.pExt))
     905                        return VERR_ISOFS_BAD_EXTAD;
     906                    uType    = uPtr.pExt->uType;
     907                    cb       = uPtr.pExt->cb;
     908                    idxBlock = uPtr.pExt->Location.off;
     909                    idxPart  = uPtr.pExt->Location.uPartitionNo;
     910                    cbAllocDescs -= uPtr.pExt->cbInformation;
     911                    uPtr.pb += uPtr.pExt->cbInformation;
     912                    break;
     913                default:
     914                    AssertFailedReturn(VERR_IPE_NOT_REACHED_DEFAULT_CASE);
     915            }
     916
     917            /* Check if we can extend the current extent.  This is useful since
     918               the descriptors can typically only cover 1GB. */
     919            uint64_t const off = (uint64_t)idxBlock << pThis->Udf.VolInfo.cShiftBlock;
     920            if (   pCurExtent != NULL
     921                && (   pCurExtent->off != UINT64_MAX
     922                    ?     uType == UDF_AD_TYPE_RECORDED_AND_ALLOCATED
     923                       && pCurExtent->off + pCurExtent->cbExtent == off
     924                       && pCurExtent->idxPart == idxPart
     925                    :     uType != UDF_AD_TYPE_RECORDED_AND_ALLOCATED) )
     926                pCurExtent->cbExtent += cb;
     927            else
     928            {
     929                /* Allocate a new descriptor. */
     930                if (pCore->cExtents == 0)
     931                {
     932                    pCore->cExtents = 1;
     933                    pCurExtent = &pCore->FirstExtent;
     934                }
     935                else
     936                {
     937                    void *pvNew = RTMemRealloc(pCore->paExtents, pCore->cExtents * sizeof(pCore->paExtents[0]));
     938                    if (pvNew)
     939                        pCore->paExtents = (PRTFSISOEXTENT)pvNew;
     940                    else
     941                    {
     942                        RTMemFree(pCore->paExtents);
     943                        pCore->paExtents = NULL;
     944                        pCore->cExtents  = 0;
     945                        return VERR_NO_MEMORY;
     946                    }
     947                    pCurExtent = &pCore->paExtents[pCore->cExtents - 1];
     948                    pCore->cExtents++;
     949                }
     950
     951                /* Initialize it. */
     952                if (uType == UDF_AD_TYPE_RECORDED_AND_ALLOCATED)
     953                {
     954                    pCurExtent->off     = off;
     955                    pCurExtent->idxPart = idxPart;
     956                }
     957                else
     958                {
     959                    pCurExtent->off     = UINT64_MAX;
     960                    pCurExtent->idxPart = UINT32_MAX;
     961                }
     962                pCurExtent->cbExtent    = cb;
     963                pCurExtent->uReserved   = 0;
     964            }
     965        } while (cbAllocDescs >= cbOneDesc);
     966
     967        if (cbAllocDescs > 0)
     968            LogRelMax(45,("ISO/UDF: Warning! %u bytes left in allocation descriptor: %.*Rhxs\n", cbAllocDescs, cbAllocDescs, uPtr.pb));
     969    }
     970    else
     971    {
     972        /*
     973         * Zero descriptors
     974         */
     975        pCore->cExtents = 0;
     976        pCore->FirstExtent.off      = UINT64_MAX;
     977        pCore->FirstExtent.cbExtent = 0;
     978        pCore->FirstExtent.idxPart  = UINT32_MAX;
     979
     980        if (cbAllocDescs > 0)
     981            LogRelMax(45, ("ISO/UDF: Warning! Allocation descriptor area is shorted than one descriptor: %#u vs %#u: %.*Rhxs\n",
     982                           cbAllocDescs, cbOneDesc, cbAllocDescs, pbAllocDescs));
     983    }
     984    return VINF_SUCCESS;
     985}
     986
     987
     988static int rtFsIsoCore_InitFromUdfIcbFileEntry(PRTFSISOCORE pCore, PCUDFFILEENTRY pFileEntry, uint32_t idxDefaultPart,
     989                                               uint32_t *pcProcessed, PRTFSISOVOL pThis)
     990{
     991    /*
     992     * Basic sanity checking of what we use.
     993     */
     994    if (     RT_OFFSETOF(UDFFILEENTRY, abExtAttribs) + pFileEntry->cbExtAttribs + pFileEntry->cbAllocDescs
     995           > pThis->Udf.VolInfo.cbBlock
     996        || (pFileEntry->cbExtAttribs & 3) != 0
     997        || pFileEntry->cbExtAttribs >= pThis->Udf.VolInfo.cbBlock
     998        || (pFileEntry->cbAllocDescs & 3) != 0
     999        || pFileEntry->cbAllocDescs >= pThis->Udf.VolInfo.cbBlock)
     1000    {
     1001        LogRelMax(45, ("ISO/UDF: File entry (ICB) is bad size values: cbAllocDesc=%#x cbExtAttribs=%#x (cbBlock=%#x)\n",
     1002                       pFileEntry->cbAllocDescs, pFileEntry->cbExtAttribs, pThis->Udf.VolInfo.cbBlock));
     1003        return VERR_ISOFS_BAD_FILE_ENTRY;
     1004    }
     1005
     1006    /*
     1007     * Process the file size and extract allocation information.
     1008     */
     1009    pCore->cbObject = pFileEntry->cbData;
     1010    int rc = rtFsIsoCore_InitExtentsUdfIcbEntry(pCore,
     1011                                                &pFileEntry->abExtAttribs[pFileEntry->cbExtAttribs],
     1012                                                pFileEntry->cbAllocDescs,
     1013                                                pFileEntry->IcbTag.fFlags,
     1014                                                idxDefaultPart,
     1015                                                  ((uint64_t)pFileEntry->Tag.offTag << pThis->Udf.VolInfo.cShiftBlock)
     1016                                                + RT_OFFSETOF(UDFFILEENTRY, abExtAttribs) + pFileEntry->cbExtAttribs,
     1017                                                pThis);
     1018    if (RT_FAILURE(rc))
     1019    {
     1020        return rc;
     1021    }
     1022
     1023
     1024
     1025    /*
     1026     * We're good.
     1027     */
     1028    *pcProcessed += 1;
     1029    return VINF_SUCCESS;
     1030}
     1031
     1032static int rtFsIsoCore_InitFromUdfIcbRecursive(PRTFSISOCORE pCore, UDFLONGAD AllocDesc, uint8_t *pbBuf, uint32_t cNestings,
     1033                                               uint32_t *pcProcessed, uint32_t *pcIndirections, PRTFSISOVOL pThis)
     1034{
     1035    if (cNestings >= 8)
     1036        return VERR_ISOFS_TOO_DEEP_ICB_RECURSION;
     1037
     1038    for (;;)
     1039    {
     1040        if (*pcIndirections >= 32)
     1041            return VERR_ISOFS_TOO_MANY_ICB_INDIRECTIONS;
     1042
     1043        /*
     1044         * Check the basic validity of the allocation descriptor.
     1045         */
     1046        if (   AllocDesc.uType == UDF_AD_TYPE_RECORDED_AND_ALLOCATED
     1047            && AllocDesc.cb >= sizeof(UDFICBTAG) )
     1048        { /* likely */ }
     1049        else if (AllocDesc.uType != UDF_AD_TYPE_RECORDED_AND_ALLOCATED)
     1050        {
     1051            Log(("ISO/UDF: ICB has alloc type %d!\n", AllocDesc.uType));
     1052            return VINF_SUCCESS;
     1053        }
     1054        else
     1055        {
     1056            LogRelMax(45, ("ISO/UDF: ICB is too small: %u bytes\n", AllocDesc.cb));
     1057            return AllocDesc.cb == 0 ? VINF_SUCCESS : VERR_ISOFS_ICB_TOO_SMALL;
     1058        }
     1059
     1060        /*
     1061         * Process it block by block.
     1062         */
     1063        uint32_t cBlocks = (AllocDesc.cb + pThis->Udf.VolInfo.cbBlock - 1) >> pThis->Udf.VolInfo.cShiftBlock;
     1064        for (uint32_t idxBlock = 0; ; idxBlock++)
     1065        {
     1066            /*
     1067             * Read a block
     1068             */
     1069            size_t cbToRead = RT_MIN(pThis->Udf.VolInfo.cbBlock, AllocDesc.cb);
     1070            int rc = rtFsIsoVolUdfVpRead(pThis, AllocDesc.Location.uPartitionNo, AllocDesc.Location.off + idxBlock, 0,
     1071                                         pbBuf, cbToRead);
     1072            if (RT_FAILURE(rc))
     1073                return rc;
     1074            if (cbToRead < pThis->Udf.VolInfo.cbBlock)
     1075                RT_BZERO(&pbBuf[cbToRead], pThis->Udf.VolInfo.cbBlock - cbToRead);
     1076
     1077            /*
     1078             * Verify the TAG.
     1079             */
     1080            PUDFICBHDR pHdr = (PUDFICBHDR)pbBuf;
     1081            rc = rtFsIsoVolValidateUdfDescTagAndCrc(&pHdr->Tag, pThis->Udf.VolInfo.cbBlock, UINT16_MAX,
     1082                                                    AllocDesc.Location.off + idxBlock, NULL);
     1083            if (RT_FAILURE(rc))
     1084                return rc;
     1085
     1086            /*
     1087             * Do specific processing.
     1088             */
     1089            if (pHdr->Tag.idTag == UDF_TAG_ID_FILE_ENTRY)
     1090            {
     1091                Log2(("ISO/UDF: ICB: File entry\n"));
     1092                rc = rtFsIsoCore_InitFromUdfIcbFileEntry(pCore, (PCUDFFILEENTRY)pHdr, AllocDesc.Location.uPartitionNo,
     1093                                                         pcProcessed, pThis);
     1094            }
     1095            else if (pHdr->Tag.idTag == UDF_TAG_ID_EXTENDED_FILE_ENTRY)
     1096            {
     1097                Log2(("ISO/UDF: ICB: Extended file entry\n"));
     1098                //UDFEXFILEENTRY
     1099                //*pcProcessed += 1;
     1100            }
     1101            else if (pHdr->Tag.idTag == UDF_TAG_ID_INDIRECT_ENTRY)
     1102            {
     1103                PUDFINDIRECTENTRY pIndir = (PUDFINDIRECTENTRY)pHdr;
     1104                *pcIndirections += 1;
     1105                if (pIndir->IndirectIcb.cb != 0)
     1106                {
     1107                    if (idxBlock + 1 == cBlocks)
     1108                    {
     1109                        AllocDesc = pIndir->IndirectIcb;
     1110                        Log2(("ISO/UDF: ICB: Indirect entry - looping: %x:%#010RX32 LB %#x; uType=%d\n",
     1111                              AllocDesc.Location.uPartitionNo, AllocDesc.Location.off, AllocDesc.cb, AllocDesc.uType));
     1112                        break;
     1113                    }
     1114                    Log2(("ISO/UDF: ICB: Indirect entry - recursing: %x:%#010RX32 LB %#x; uType=%d\n",
     1115                          pIndir->IndirectIcb.Location.uPartitionNo, pIndir->IndirectIcb.Location.off,
     1116                          pIndir->IndirectIcb.cb, pIndir->IndirectIcb.uType));
     1117                    rc = rtFsIsoCore_InitFromUdfIcbRecursive(pCore, pIndir->IndirectIcb, pbBuf, cNestings,
     1118                                                             pcProcessed, pcIndirections, pThis);
     1119                }
     1120                else
     1121                    Log(("ISO/UDF: zero length indirect entry\n"));
     1122            }
     1123            else if (pHdr->Tag.idTag == UDF_TAG_ID_TERMINAL_ENTRY)
     1124            {
     1125                Log2(("ISO/UDF: Terminal ICB entry\n"));
     1126                return VINF_SUCCESS;
     1127            }
     1128            else if (pHdr->Tag.idTag == UDF_TAG_ID_UNALLOCATED_SPACE_ENTRY)
     1129            {
     1130                Log2(("ISO/UDF: Unallocated space entry: skipping\n"));
     1131                /* Ignore since we don't do writing (UDFUNALLOCATEDSPACEENTRY) */
     1132            }
     1133            else
     1134            {
     1135                LogRelMax(90, ("ISO/UDF: Unknown ICB type %#x\n", pHdr->Tag.idTag));
     1136                return VERR_ISOFS_UNSUPPORTED_ICB;
     1137            }
     1138            if (RT_FAILURE(rc))
     1139                return rc;
     1140
     1141            /*
     1142             * Advance.
     1143             */
     1144            if (idxBlock + 1 >= cBlocks)
     1145                return VINF_SUCCESS;
     1146        }
     1147
     1148        /* If we get here, we've jumped thru an indirect entry. */
     1149    }
     1150
     1151    /* never reached */
     1152}
     1153
     1154
    7841155
    7851156static int rtFsIsoCore_InitFromUdfIcbAndFileIdDesc(PRTFSISOCORE pCore, PCUDFLONGAD pAllocDesc,
    7861157                                                   PCUDFFILEIDDESC pFileIdDesc, PRTFSISOVOL pThis)
    7871158{
    788 #if 1
    789     RT_NOREF(pCore, pAllocDesc, pFileIdDesc, pThis);
    790 #else
    791     /*
    792      * Allocate a temporary buffer.
    793      */
     1159RT_NOREF(pFileIdDesc);
    7941160    if (pAllocDesc->cb > _64K)
    7951161        return VERR_ISOFS_DIR_ICB_TOO_BIG;
     
    7971163        return VERR_ISOFS_DIR_ICB_TOO_SMALL;
    7981164
    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 
    862     return VINF_SUCCESS;
     1165    /*
     1166     * Allocate a temporary buffer, one logical block in size.
     1167     */
     1168    uint8_t * const pbBuf = (uint8_t *)RTMemTmpAlloc(pThis->Udf.VolInfo.cbBlock);
     1169    if (pbBuf)
     1170    {
     1171        uint32_t cProcessed = 0;
     1172        uint32_t cIndirections = 0;
     1173        int rc = rtFsIsoCore_InitFromUdfIcbRecursive(pCore, *pAllocDesc, pbBuf, 0, &cProcessed, &cIndirections, pThis);
     1174        RTMemTmpFree(pbBuf);
     1175        if (RT_SUCCESS(rc))
     1176        {
     1177            if (cProcessed > 0)
     1178                return VINF_SUCCESS;
     1179            rc = VERR_ISOFS_NO_DIRECT_ICB_ENTRIES;
     1180        }
     1181        return rc;
     1182    }
     1183    return VERR_NO_TMP_MEMORY;
    8631184}
    8641185
     
    10001321            if (cbToRead > cbFileLeft)
    10011322                cbToRead = (size_t)cbFileLeft;
    1002             rc = RTVfsFileReadAt(pShared->Core.pVol->hVfsBacking, pShared->Core.FirstExtent.offDisk + off, pbDst, cbToRead, NULL);
     1323            rc = RTVfsFileReadAt(pShared->Core.pVol->hVfsBacking, pShared->Core.FirstExtent.off + off, pbDst, cbToRead, NULL);
    10031324            if (RT_SUCCESS(rc))
    10041325            {
     
    12611582        {
    12621583            LogFlow(("rtFsIsoFile_New9660: cbObject=%#RX64 First Extent: off=%#RX64 cb=%#RX64\n",
    1263                      pShared->Core.cbObject, pShared->Core.FirstExtent.offDisk, pShared->Core.FirstExtent.cbExtent));
     1584                     pShared->Core.cbObject, pShared->Core.FirstExtent.off, pShared->Core.FirstExtent.cbExtent));
    12641585            pNewFile->offFile = 0;
    12651586            pNewFile->pShared = pShared;
     
    15331854            }
    15341855
    1535             *poffDirRec = pThis->Core.FirstExtent.offDisk + offEntryInDir;
     1856            *poffDirRec = pThis->Core.FirstExtent.off + offEntryInDir;
    15361857            *ppDirRec   = pDirRec;
    15371858            *pfMode     = pDirRec->fFileFlags & ISO9660_FILE_FLAGS_DIRECTORY
     
    20442365            RT_ZERO(TmpObj);
    20452366            rtFsIsoCore_InitFrom9660DirRec(&TmpObj, pDirRec, 1 /* cDirRecs - see below why 1 */,
    2046                                            pThis->offDir + pShared->Core.FirstExtent.offDisk, uVersion, pShared->Core.pVol);
     2367                                           pThis->offDir + pShared->Core.FirstExtent.off, uVersion, pShared->Core.pVol);
    20472368            int rc = rtFsIsoCore_QueryInfo(&TmpObj, &pDirEntry->Info, enmAddAttr);
    20482369
     
    22722593            if (pShared->pbDir)
    22732594            {
    2274                 rc = RTVfsFileReadAt(pThis->hVfsBacking, pShared->Core.FirstExtent.offDisk, pShared->pbDir, pShared->cbDir, NULL);
     2595                rc = RTVfsFileReadAt(pThis->hVfsBacking, pShared->Core.FirstExtent.off, pShared->pbDir, pShared->cbDir, NULL);
    22752596                if (RT_SUCCESS(rc))
    22762597                {
     
    22892610                }
    22902611            }
     2612            else
     2613                rc = VERR_NO_MEMORY;
    22912614        }
    22922615        RTMemFree(pShared);
     
    23262649            {
    23272650                pShared->cbDir = (uint32_t)pShared->Core.cbObject;
    2328                 pShared->pbDir = (uint8_t *)RTMemAllocZ(RT_ALIGN_32(pShared->cbDir, 512));
     2651                pShared->pbDir = (uint8_t *)RTMemAllocZ(RT_MIN(RT_ALIGN_32(pShared->cbDir, 512), 512));
    23292652                if (pShared->pbDir)
    23302653                {
    2331                     rc = RTVfsFileReadAt(pThis->hVfsBacking, pShared->Core.FirstExtent.offDisk, pShared->pbDir, pShared->cbDir, NULL);
     2654                    rc = RTVfsFileReadAt(pThis->hVfsBacking, pShared->Core.FirstExtent.off, pShared->pbDir, pShared->cbDir, NULL);
    23322655                    if (RT_SUCCESS(rc))
    23332656                    {
     
    23462669                    }
    23472670                }
     2671                else
     2672                    rc = VERR_NO_MEMORY;
    23482673            }
    23492674        }
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette