VirtualBox

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


Ignore:
Timestamp:
Jun 14, 2017 9:25:14 PM (7 years ago)
Author:
vboxsync
Message:

IPRT: More ISO maker code. (path table fixes)

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

Legend:

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

    r67412 r67413  
    8787
    8888
    89 /** Calculates the path table record size given the name length. */
     89/** Calculates the path table record size given the name length.
     90 * @note  The root directory length is 1 (name byte is 0x00), we make sure this
     91 *        is the case in rtFsIsoMakerNormalizeNameForNamespace. */
    9092#define RTFSISOMAKER_CALC_PATHREC_SIZE(a_cbNameInDirRec) \
    91     ( RT_UOFFSETOF(ISO9660PATHREC, achDirId[(a_cbNameInDirRec)]) + ((a_cbNameInDirRec) & 1) )
     93    ( RT_UOFFSETOF(ISO9660PATHREC, achDirId[(a_cbNameInDirRec) + ((a_cbNameInDirRec) & 1)]) )
    9294
    9395
     
    16401642        /*
    16411643         * Root special case.
     1644         *
     1645         * For ISO-9660 and joliet, we enter it with a length of 1 byte.  The
     1646         * value byte value is zero.  The path tables we generate won't be
     1647         * accepted by windows unless we do this.
    16421648         */
    16431649        *pszDst      = '\0';
    16441650        *pcchDst     = 0;
    1645         *pcbInDirRec = 0;
     1651        *pcbInDirRec = pNamespace->fNamespace & (RTFSISOMAKER_NAMESPACE_ISO_9660 | RTFSISOMAKER_NAMESPACE_JOLIET) ? 1 : 0;
    16461652        AssertReturn(!pParent, VERR_INTERNAL_ERROR_3);
    16471653        return VINF_SUCCESS;
     
    17601766    if (RT_SUCCESS(rc))
    17611767    {
     1768        Assert(cbNameInDirRec > 0);
     1769
    17621770        size_t cbName = sizeof(RTFSISOMAKERNAME)
    17631771                      + cchName + 1
     
    29032911
    29042912    int      rc;
    2905     uint16_t idPathTable = 0;
     2913    uint16_t idPathTable = 1;
    29062914    uint32_t cbPathTable = 0;
    29072915    if (pNamespace->pRoot)
     
    33823390    pPrimary->cbPathTable.be            = RT_H2BE_U32(pThis->PrimaryIsoDirs.cbPathTable);
    33833391    pPrimary->cbPathTable.le            = RT_H2LE_U32(pThis->PrimaryIsoDirs.cbPathTable);
    3384     pPrimary->offTypeLPathTable         = RT_H2LE_U32(pThis->PrimaryIsoDirs.offPathTableL);
    3385     pPrimary->offTypeMPathTable         = RT_H2BE_U32(pThis->PrimaryIsoDirs.offPathTableM);
     3392    pPrimary->offTypeLPathTable         = RT_H2LE_U32(pThis->PrimaryIsoDirs.offPathTableL / RTFSISOMAKER_SECTOR_SIZE);
     3393    pPrimary->offTypeMPathTable         = RT_H2BE_U32(pThis->PrimaryIsoDirs.offPathTableM / RTFSISOMAKER_SECTOR_SIZE);
    33863394    pPrimary->RootDir.DirRec.cbDirRec           = sizeof(pPrimary->RootDir);
    33873395    pPrimary->RootDir.DirRec.cExtAttrBlocks     = 0;
     
    34083416        pJoliet->cbPathTable.be             = RT_H2BE_U32(pThis->JolietDirs.cbPathTable);
    34093417        pJoliet->cbPathTable.le             = RT_H2LE_U32(pThis->JolietDirs.cbPathTable);
    3410         pJoliet->offTypeLPathTable          = RT_H2LE_U32(pThis->JolietDirs.offPathTableL);
    3411         pJoliet->offTypeMPathTable          = RT_H2BE_U32(pThis->JolietDirs.offPathTableM);
     3418        pJoliet->offTypeLPathTable          = RT_H2LE_U32(pThis->JolietDirs.offPathTableL / RTFSISOMAKER_SECTOR_SIZE);
     3419        pJoliet->offTypeMPathTable          = RT_H2BE_U32(pThis->JolietDirs.offPathTableM / RTFSISOMAKER_SECTOR_SIZE);
    34123420        pJoliet->RootDir.DirRec.cbDirRec           = sizeof(pJoliet->RootDir);
    34133421        pJoliet->RootDir.DirRec.cExtAttrBlocks     = 0;
     
    37833791    {
    37843792        pPathRec->offExtent   = RT_H2LE_U32(pName->pDir->offDir / RTFSISOMAKER_SECTOR_SIZE);
    3785         pPathRec->idParentRec = RT_H2LE_U16(pName->pParent ? pName->pParent->pDir->idPathTable : 0);
     3793        pPathRec->idParentRec = RT_H2LE_U16(pName->pParent ? pName->pParent->pDir->idPathTable : 1);
    37863794    }
    37873795    else
    37883796    {
    37893797        pPathRec->offExtent   = RT_H2BE_U32(pName->pDir->offDir / RTFSISOMAKER_SECTOR_SIZE);
    3790         pPathRec->idParentRec = RT_H2BE_U16(pName->pParent ? pName->pParent->pDir->idPathTable : 0);
     3798        pPathRec->idParentRec = RT_H2BE_U16(pName->pParent ? pName->pParent->pDir->idPathTable : 1);
    37913799    }
    37923800    if (!fUnicode)
     
    38033811        int rc = RTStrToUtf16BigEx(pName->szName, RTSTR_MAX, &pwszTmp, pName->cbNameInDirRec / sizeof(RTUTF16) + 1, &cwcResult);
    38043812        AssertRC(rc);
    3805         Assert(cwcResult * sizeof(RTUTF16) == pName->cbNameInDirRec);
     3813        Assert(   cwcResult * sizeof(RTUTF16) == pName->cbNameInDirRec
     3814               || (!pName->pParent && cwcResult == 0 && pName->cbNameInDirRec == 1) );
     3815
    38063816    }
    38073817    return RTFSISOMAKER_CALC_PATHREC_SIZE(pName->cbNameInDirRec);
     
    39853995        int rc = RTStrToUtf16BigEx(pName->szName, RTSTR_MAX, &pwszTmp, RT_ELEMENTS(wszTmp), &cwcResult);
    39863996        AssertRC(rc);
    3987         Assert(cwcResult * sizeof(RTUTF16) == pName->cbNameInDirRec);
     3997        Assert(   cwcResult * sizeof(RTUTF16) == pName->cbNameInDirRec
     3998               || (!pName->pParent && cwcResult == 0 && pName->cbNameInDirRec == 1) );
    39883999        memcpy(&pDirRec->achFileId[0], pwszTmp, pName->cbNameInDirRec);
    39894000        pDirRec->achFileId[pName->cbNameInDirRec] = '\0';
  • trunk/src/VBox/Runtime/common/fs/isomakercmd.cpp

    r67399 r67413  
    9393    RTFSISOMAKERCMD_OPT_RANDOM_OUTPUT_BUFFER_SIZE,
    9494    RTFSISOMAKERCMD_OPT_NAME_SETUP,
     95    RTFSISOMAKERCMD_OPT_NO_JOLIET,
    9596
    9697    /*
     
    309310    { "--output-buffer-size",           RTFSISOMAKERCMD_OPT_OUTPUT_BUFFER_SIZE,             RTGETOPT_REQ_UINT32  },
    310311    { "--random-output-buffer-size",    RTFSISOMAKERCMD_OPT_RANDOM_OUTPUT_BUFFER_SIZE,      RTGETOPT_REQ_NOTHING },
    311     { "--name-setup",                   RTFSISOMAKERCMD_OPT_NAME_SETUP,                     RTGETOPT_REQ_STRING },
     312    { "--name-setup",                   RTFSISOMAKERCMD_OPT_NAME_SETUP,                     RTGETOPT_REQ_STRING  },
     313    { "--no-joliet",                    RTFSISOMAKERCMD_OPT_NO_JOLIET,                      RTGETOPT_REQ_NOTHING },
    312314
    313315
     
    11971199                rc = rtFsIsoMakerCmdOptNameSetup(&Opts, ValueUnion.psz);
    11981200                break;
     1201            case RTFSISOMAKERCMD_OPT_NO_JOLIET:
     1202                rc = RTFsIsoMakerSetJolietUcs2Level(Opts.hIsoMaker, 0);
     1203                if (RT_FAILURE(rc))
     1204                    rc = rtFsIsoMakerCmdErrorRc(&Opts, rc, "Failed to disable joliet: %Rrc", rc);
     1205                break;
    11991206
    12001207
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