VirtualBox

Changeset 67511 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Jun 20, 2017 2:30:30 PM (7 years ago)
Author:
vboxsync
Message:

IPRT: ISO maker updates (import related).

Location:
trunk/src/VBox/Runtime/common/fs
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/fs/isomakercmd.cpp

    r67502 r67511  
    13971397static int rtFsIsoMakerCmdOptImportIso(PRTFSISOMAKERCMDOPTS pOpts, const char *pszIsoSpec)
    13981398{
    1399     uint32_t        offError = UINT32_MAX;
    1400     RTERRINFOSTATIC ErrInfo;
    1401     int rc = RTFsIsoMakerImport(pOpts->hIsoMaker, pszIsoSpec, 0 /*fFlags*/, &offError, RTErrInfoInitStatic(&ErrInfo));
     1399    RTFSISOMAKERIMPORTRESULTS   Results;
     1400    RTERRINFOSTATIC             ErrInfo;
     1401    int rc = RTFsIsoMakerImport(pOpts->hIsoMaker, pszIsoSpec, 0 /*fFlags*/, &Results, RTErrInfoInitStatic(&ErrInfo));
     1402
     1403    pOpts->cItemsAdded += Results.cAddedFiles;
     1404    pOpts->cItemsAdded += Results.cAddedDirs;
     1405    pOpts->cItemsAdded += Results.cBootCatEntries;
     1406    pOpts->cItemsAdded += Results.cbSysArea != 0 ? 1 : 0;
     1407
     1408    rtFsIsoMakerPrintf(pOpts, "ISO imported statistics for '%s'\n", pszIsoSpec);
     1409    rtFsIsoMakerPrintf(pOpts, "    cAddedNames:         %'14RU32\n", Results.cAddedNames);
     1410    rtFsIsoMakerPrintf(pOpts, "    cAddedDirs:          %'14RU32\n", Results.cAddedDirs);
     1411    rtFsIsoMakerPrintf(pOpts, "    cbAddedDataBlocks:   %'14RU64 bytes\n", Results.cbAddedDataBlocks);
     1412    rtFsIsoMakerPrintf(pOpts, "    cAddedFiles:         %'14RU32\n", Results.cAddedFiles);
     1413    if (Results.cBootCatEntries == UINT32_MAX)
     1414        rtFsIsoMakerPrintf(pOpts, "    cBootCatEntries:               none\n");
     1415    else
     1416        rtFsIsoMakerPrintf(pOpts, "    cBootCatEntries:     %'14RU32\n", Results.cBootCatEntries);
     1417    rtFsIsoMakerPrintf(pOpts, "    cbSysArea:           %'14RU32\n", Results.cbSysArea);
     1418    rtFsIsoMakerPrintf(pOpts, "    cErrors:             %'14RU32\n", Results.cErrors);
     1419
    14021420    if (RT_SUCCESS(rc))
    14031421        return rc;
    1404     if (offError != UINT32_MAX)
    1405         return rtFsIsoMakerCmdChainError(pOpts, "RTFsIsoMakerImport", pszIsoSpec, rc, offError, &ErrInfo.Core);
     1422    if (Results.offError != UINT32_MAX)
     1423        return rtFsIsoMakerCmdChainError(pOpts, "RTFsIsoMakerImport", pszIsoSpec, rc, Results.offError, &ErrInfo.Core);
    14061424    if (RTErrInfoIsSet(&ErrInfo.Core))
    14071425        return rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTFsIsoMakerImport failed: %Rrc - %s", rc, ErrInfo.Core.pszMsg);
  • trunk/src/VBox/Runtime/common/fs/isomakerimport.cpp

    r67503 r67511  
    129129    /** Set if we've already seen a joliet volume descriptor. */
    130130    bool                    fSeenJoliet;
     131
     132    /** Pointer to the import results structure (output). */
     133    PRTFSISOMAKERIMPORTRESULTS pResults;
    131134
    132135    /** Sector buffer for volume descriptors and such. */
     
    204207#define VERR_ISOMK_IMPORT_TOO_DEEP_DIR_TREE             (-24921)
    205208
     209/** Import ISO contains a bad directory record. */
    206210#define VERR_ISOMK_IMPORT_BAD_DIR_REC                   (-24922)
     211/** Import ISO directory record with a mismatching volume sequence number. */
    207212#define VERR_ISOMK_IMPORT_DIR_REC_VOLUME_SEQ_NO         (-24923)
     213/** Import ISO directory with an extent that is out of bounds. */
    208214#define VERR_ISOMK_IMPORT_DIR_REC_EXTENT_OUT_OF_BOUNDS  (-24924)
     215/** Import ISO directory with a bad record length. */
    209216#define VERR_ISOMK_IMPORT_BAD_DIR_REC_LENGTH            (-24925)
     217/** Import ISO directory with a bad name length. */
    210218#define VERR_ISOMK_IMPORT_DOT_DIR_REC_BAD_NAME_LENGTH   (-24926)
     219/** Import ISO directory with a bad name. */
    211220#define VERR_ISOMK_IMPORT_DOT_DIR_REC_BAD_NAME          (-24927)
    212221
     
    224233static int rtFsIsoImpErrorV(PRTFSISOMKIMPORTER pThis, int rc, const char *pszFormat, va_list va)
    225234{
     235    va_list vaCopy;
     236    va_copy(vaCopy, va);
     237    LogRel(("RTFsIsoMkImport error %Rrc: %N\n", rc, pszFormat, &vaCopy));
     238    va_end(vaCopy);
     239
    226240    if (RT_SUCCESS(pThis->rc))
    227241    {
     
    229243        rc = RTErrInfoSetV(pThis->pErrInfo, rc, pszFormat, va);
    230244    }
     245
     246    pThis->pResults->cErrors++;
    231247    return rc;
    232248}
     
    380396        return rc;
    381397
     398    cbChunk -= pDirRec->cbDirRec;
    382399    pDirRec  = (PCISO9660DIRREC)((uintptr_t)pDirRec + pDirRec->cbDirRec);
    383     cbChunk -= pDirRec->cbDirRec;
    384400
    385401    /*
    386402     * Work our way thru all the directory records.
    387403     */
    388     Log3(("rtFsIsoImportProcessIso9660TreeWorker: Starting at @%#RX64 LB %#zx\n", off - cbChunk, cbChunk));
     404    Log3(("rtFsIsoImportProcessIso9660TreeWorker: Starting at @%#RX64 LB %#RX32 (out of %#RX32) in %#x\n",
     405          off - cbChunk, cbChunk, cbChunk + cbDir, idxDir));
    389406    while (cbChunk > 0)
    390407    {
     
    405422                return rtFsIsoImpError(pThis, rc, "Error reading %#RX32 bytes at %#RX64 (dir): %Rrc", off, cbToRead);
    406423
    407             Log3(("rtFsIsoImportProcessIso9660TreeWorker: Read %#zx more bytes @%#RX64, now got @%#RX64 LB %#zx\n",
     424            Log3(("rtFsIsoImportProcessIso9660TreeWorker: Read %#zx more bytes @%#RX64, now got @%#RX64 LB %#RX32\n",
    408425                  cbToRead, off, off - cbChunk, cbChunk + cbToRead));
    409426            off     += cbToRead;
     
    427444                    continue;
    428445                }
    429                 Log3(("rtFsIsoImportProcessIso9660TreeWorker: cbDirRec=0 --> jumped to @%#RX64 LB %#zx\n", off - cbChunk, cbChunk));
     446                Log3(("rtFsIsoImportProcessIso9660TreeWorker: cbDirRec=0 --> jumped %#RX32 to @%#RX64 LB %#RX32\n",
     447                      cbSkip, off - cbChunk, cbChunk));
    430448            }
    431449            /* ASSUMES we're working in multiples of sectors! */
     
    440458                    return rtFsIsoImpError(pThis, rc, "Error reading %#RX32 bytes at %#RX64 (dir): %Rrc", off, cbToRead);
    441459
    442                 Log3(("rtFsIsoImportProcessIso9660TreeWorker: cbDirRec=0 --> Read %#zx more bytes @%#RX64, now got @%#RX64 LB %#zx\n",
     460                Log3(("rtFsIsoImportProcessIso9660TreeWorker: cbDirRec=0 --> Read %#zx more bytes @%#RX64, now got @%#RX64 LB %#RX32\n",
    443461                      cbToRead, off, off - cbChunk, cbChunk + cbToRead));
    444462                off     += cbToRead;
     
    456474                                    - pDirRec->bFileIdLength - !(pDirRec->bFileIdLength & 1);
    457475        uint8_t const * const pbSys = (uint8_t const *)&pDirRec->achFileId[pDirRec->bFileIdLength + !(pDirRec->bFileIdLength & 1)];
    458         Log3(("pDirRec=%p @%#010RX64 cb=%#04x ff=%#04x off=%#010RX32 cb=%#010RX32 cbSys=%#x id=%.*Rhxs\n",
    459               pDirRec, off - cbChunk, pDirRec->cbDirRec, pDirRec->fFileFlags, ISO9660_GET_ENDIAN(&pDirRec->offExtent),
    460               ISO9660_GET_ENDIAN(&pDirRec->cbData), cbSys, pDirRec->bFileIdLength, pDirRec->achFileId));
     476        Log3(("pDirRec=&abBuf[%#07zx]: @%#010RX64 cb=%#04x ff=%#04x off=%#010RX32 cb=%#010RX32 cbSys=%#x id=%.*Rhxs\n",
     477              (uintptr_t)pDirRec - (uintptr_t)&pThis->abBuf[0], off - cbChunk, pDirRec->cbDirRec, pDirRec->fFileFlags,
     478              ISO9660_GET_ENDIAN(&pDirRec->offExtent), ISO9660_GET_ENDIAN(&pDirRec->cbData), cbSys,
     479              pDirRec->bFileIdLength, pDirRec->achFileId));
    461480        rc = rtFsIsoImportValidateDirRec(pThis, pDirRec, cbChunk);
    462481        if (RT_FAILURE(rc))
     
    496515                    pThis->szNameBuf[cchName - offName] = '\0';
    497516            }
    498             Log3(("  name='%s'\n", pThis->szNameBuf));
     517            Log3(("  --> name='%s'\n", pThis->szNameBuf));
    499518
    500519            /** @todo rock ridge. */
     
    509528            uint32_t                idxObj      = UINT32_MAX;
    510529            if (pDirRec->fFileFlags & ISO9660_FILE_FLAGS_DIRECTORY)
     530            {
    511531                rc = RTFsIsoMakerAddUnnamedDir(pThis->hIsoMaker, &idxObj);
     532                Log3(("  --> added directory #%#x'\n", idxObj));
     533                if (RT_SUCCESS(rc))
     534                    pThis->pResults->cAddedDirs++;
     535            }
    512536            else
    513537            {
     
    525549                pBlock2File = (PRTFSISOMKIMPBLOCK2FILE)RTAvlU32Get(&pThis->Block2FileRoot, ISO9660_GET_ENDIAN(&pDirRec->offExtent));
    526550                if (!pBlock2File)
     551                {
    527552                    rc = RTFsIsoMakerAddUnnamedFileWithCommonSrc(pThis->hIsoMaker, pThis->idxSrcFile,
    528                                                                  ISO9660_GET_ENDIAN(&pDirRec->offExtent) * ISO9660_SECTOR_SIZE,
     553                                                                 ISO9660_GET_ENDIAN(&pDirRec->offExtent) * (uint64_t)ISO9660_SECTOR_SIZE,
    529554                                                                 ISO9660_GET_ENDIAN(&pDirRec->cbData), NULL /*pObjInfo*/, &idxObj);
     555                    Log3(("  --> added new file #%#x\n", idxObj));
     556                    if (RT_SUCCESS(rc))
     557                    {
     558                        pThis->pResults->cAddedFiles++;
     559                        pThis->pResults->cbAddedDataBlocks += RT_ALIGN_32(ISO9660_GET_ENDIAN(&pDirRec->cbData), ISO9660_SECTOR_SIZE);
     560                    }
     561                }
    530562                else
    531563                {
    532564                    idxObj = pBlock2File->idxObj;
     565                    Log3(("  --> existing file #%#x'\n", idxObj));
    533566                    rc = VINF_SUCCESS;
    534567                }
     
    541574                if (RT_SUCCESS(rc))
    542575                {
     576                    pThis->pResults->cAddedNames++;
     577
    543578                    /*
    544579                     * Remember the data location if this is a file, if it's a
     
    625660        if (!pNext)
    626661            break;
     662        idxDir      = pNext->idxObj;
     663        offDirBlock = pNext->offDirBlock;
     664        cbDir       = pNext->cbDir;
    627665        cDepth      = pNext->cDepth;
    628         cbDir       = pNext->cbDir;
    629         offDirBlock = pNext->offDirBlock;
    630666        RTMemFree(pNext);
    631667    }
     
    891927 */
    892928RTDECL(int) RTFsIsoMakerImport(RTFSISOMAKER hIsoMaker, const char *pszIso, uint32_t fFlags,
    893                                uint32_t *poffError, PRTERRINFO pErrInfo)
     929                               PRTFSISOMAKERIMPORTRESULTS pResults, PRTERRINFO pErrInfo)
    894930{
    895931    /*
    896932     * Validate input.
    897933     */
     934    AssertPtrReturn(pResults, VERR_INVALID_POINTER);
     935    pResults->cAddedNames       = 0;
     936    pResults->cAddedDirs        = 0;
     937    pResults->cbAddedDataBlocks = 0;
     938    pResults->cAddedFiles       = 0;
     939    pResults->cBootCatEntries   = UINT32_MAX;
     940    pResults->cbSysArea         = 0;
     941    pResults->cErrors           = 0;
     942    pResults->offError          = UINT32_MAX;
    898943    AssertReturn(!(fFlags & ~RTFSISOMK_IMPORT_F_VALID_MASK), VERR_INVALID_FLAGS);
    899944
     
    902947     */
    903948    RTVFSFILE hSrcFile;
    904     int rc = RTVfsChainOpenFile(pszIso, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE, &hSrcFile, poffError, pErrInfo);
     949    int rc = RTVfsChainOpenFile(pszIso, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE,
     950                                &hSrcFile, &pResults->offError, pErrInfo);
    905951    if (RT_FAILURE(rc))
    906952        return rc;
     953    pResults->offError = UINT32_MAX;
     954
    907955
    908956    /*
     
    924972        //pThis->idPrimaryVol   = 0;
    925973        //pThis->fSeenJoliet    = false;
     974        pThis->pResults         = pResults;
    926975
    927976        /*
     
    948997                uint32_t iElTorito        = UINT32_MAX;
    949998                uint32_t iVolDesc         = 0;
    950                 for (;; iVolDesc++)
     999                for (;;)
    9511000                {
    9521001                    switch (pThis->uSectorBuf.VolDescHdr.bDescType)
     
    9941043                     * Read the next volume descriptor and check the signature.
    9951044                     */
     1045                    iVolDesc++;
    9961046                    if (iVolDesc >= 32)
    9971047                    {
     
    10361086                        if (!ASMMemIsAllU8(pThis->abBuf, _32K, 0))
    10371087                        {
     1088                            /* Drop zero sectors from the end. */
     1089                            uint32_t cbSysArea = _32K;
     1090                            while (   cbSysArea >= ISO9660_SECTOR_SIZE
     1091                                   && ASMMemIsAllU8(&pThis->abBuf[cbSysArea - ISO9660_SECTOR_SIZE], ISO9660_SECTOR_SIZE, 0))
     1092                                cbSysArea -= ISO9660_SECTOR_SIZE;
     1093
    10381094                            /** @todo HFS */
    1039                             rc = RTFsIsoMakerSetSysAreaContent(hIsoMaker, pThis->abBuf, _32K, 0);
     1095                            pThis->pResults->cbSysArea = cbSysArea;
     1096                            rc = RTFsIsoMakerSetSysAreaContent(hIsoMaker, pThis->abBuf, cbSysArea, 0);
    10401097                            if (RT_FAILURE(rc))
    10411098                                rtFsIsoImpError(pThis, rc, "RTFsIsoMakerSetSysAreaContent failed: %Rrc", rc);
Note: See TracChangeset for help on using the changeset viewer.

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