VirtualBox

Changeset 93118 in vbox for trunk/src/VBox/Runtime/common/fs


Ignore:
Timestamp:
Jan 4, 2022 1:41:47 AM (3 years ago)
Author:
vboxsync
Message:

IPRT/RTIsoMaker: Added an --name-setup-from-import option to better handle importing old ISOs without joliet present. We get into trouble when adding our files to the ISO in both primary iso and joliet space, since the guest might be inclined to show the joliet view (which is missing the files from the imported ISO).

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

Legend:

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

    r93115 r93118  
    271271    /** Total number of name nodes in the namespace. */
    272272    uint32_t                cNames;
    273     /** Total number of directories in the namespace. */
     273    /** Total number of directories in the namespace.
     274     * @note Appears to be unused.  */
    274275    uint32_t                cDirs;
    275276    /** The namespace selector (RTFSISOMAKER_NAMESPACE_XXX). */
     
    12801281
    12811282/**
     1283 * Gets the rock ridge support level (on the primary ISO-9660 namespace).
     1284 *
     1285 * @returns 0 if disabled, 1 just enabled, 2 if enabled with ER tag, and
     1286 *          UINT8_MAX if the handle is invalid.
     1287 * @param   hIsoMaker           The ISO maker handle.
     1288 */
     1289RTDECL(uint8_t) RTFsIsoMakerGetRockRidgeLevel(RTFSISOMAKER hIsoMaker)
     1290{
     1291    PRTFSISOMAKERINT pThis = hIsoMaker;
     1292    RTFSISOMAKER_ASSERT_VALID_HANDLE_RET_EX(pThis, UINT8_MAX);
     1293    return pThis->PrimaryIso.uRockRidgeLevel;
     1294}
     1295
     1296
     1297/**
     1298 * Gets the rock ridge support level on the joliet namespace (experimental).
     1299 *
     1300 * @returns 0 if disabled, 1 just enabled, 2 if enabled with ER tag, and
     1301 *          UINT8_MAX if the handle is invalid.
     1302 * @param   hIsoMaker           The ISO maker handle.
     1303 */
     1304RTDECL(uint8_t) RTFsIsoMakerGetJolietRockRidgeLevel(RTFSISOMAKER hIsoMaker)
     1305{
     1306    PRTFSISOMAKERINT pThis = hIsoMaker;
     1307    RTFSISOMAKER_ASSERT_VALID_HANDLE_RET_EX(pThis, UINT8_MAX);
     1308    return pThis->Joliet.uRockRidgeLevel;
     1309}
     1310
     1311
     1312/**
    12821313 * Changes the file attribute (mode, owner, group) inherit style (from source).
    12831314 *
     
    26262657
    26272658
     2659/**
     2660 * Gets currently populated namespaces.
     2661 *
     2662 * @returns Set of namespaces (RTFSISOMAKER_NAMESPACE_XXX), UINT32_MAX on error.
     2663 * @param   hIsoMaker           The ISO maker handle.
     2664 */
     2665RTDECL(uint32_t) RTFsIsoMakerGetPopulatedNamespaces(RTFSISOMAKER hIsoMaker)
     2666{
     2667    PRTFSISOMAKERINT pThis = hIsoMaker;
     2668    RTFSISOMAKER_ASSERT_VALID_HANDLE_RET_EX(pThis, UINT32_MAX);
     2669
     2670    uint32_t fRet = 0;
     2671    if (pThis->PrimaryIso.cNames > 0)
     2672        fRet |= RTFSISOMAKER_NAMESPACE_ISO_9660;
     2673    if (pThis->Joliet.cNames     > 0)
     2674        fRet |= RTFSISOMAKER_NAMESPACE_JOLIET;
     2675    if (pThis->Udf.cNames        > 0)
     2676        fRet |= RTFSISOMAKER_NAMESPACE_UDF;
     2677    if (pThis->Hfs.cNames        > 0)
     2678        fRet |= RTFSISOMAKER_NAMESPACE_HFS;
     2679
     2680    return fRet;
     2681}
    26282682
    26292683
     
    54865540        return rc;
    54875541    AssertReturn(pThis->cObjects > 0, VERR_NO_DATA);
     5542
     5543    /* The primary ISO-9660 namespace must be explicitly disabled (for now),
     5544       so we return VERR_NO_DATA if no root dir. */
    54885545    AssertReturn(pThis->PrimaryIso.pRoot || pThis->PrimaryIso.uLevel == 0, VERR_NO_DATA);
    5489     AssertReturn(pThis->Joliet.pRoot     || pThis->Joliet.uLevel     == 0, VERR_NO_DATA);
     5546
     5547    /* Automatically disable the joliet namespace if it is empty (no root dir). */
     5548    if (!pThis->Joliet.pRoot && pThis->Joliet.uLevel > 0)
     5549    {
     5550        pThis->Joliet.uLevel = 0;
     5551        pThis->cVolumeDescriptors--;
     5552    }
    54905553
    54915554    rc = rtFsIsoMakerFinalizePrepVolumeDescriptors(pThis);
  • trunk/src/VBox/Runtime/common/fs/isomakercmd-man.xml

    r82972 r93118  
    146146
    147147        <varlistentry>
    148           <term><option>--name-setup <replaceable>spec</replaceable></option></term>
     148          <term><option>--name-setup=<replaceable>spec</replaceable></option></term>
    149149          <listitem><para>Configures active namespaces and how file specifications are to be
    150150              interpreted.  The specification is a comma separated list.  Each element in the list is
     
    175175
    176176        <varlistentry>
     177          <term><option>--name-setup-from-import</option></term>
     178          <listitem><para>This is for use following one or more <option>--import-iso</option>
     179              operations and will pick a configuration matching the imported content as best we can.
     180              If the imported ISOs only had a iso9660 namespace, the joliet, udf and hfs namespaces
     181              will be removed.  This is useful when adding additional files to the ISO and will
     182              prevent guest from picking a namespace without the imported ISO content when mounting it.
     183          </para></listitem>
     184        </varlistentry>
     185
     186        <varlistentry>
    177187          <term><option>--push-iso=<replaceable>iso-file</replaceable></option></term>
    178188          <term><option>--push-iso-no-joliet=<replaceable>iso-file</replaceable></option></term>
  • trunk/src/VBox/Runtime/common/fs/isomakercmd.cpp

    r93115 r93118  
    100100    RTFSISOMAKERCMD_OPT_RANDOM_ORDER_VERIFICATION,
    101101    RTFSISOMAKERCMD_OPT_NAME_SETUP,
     102    RTFSISOMAKERCMD_OPT_NAME_SETUP_FROM_IMPORT,
    102103
    103104    RTFSISOMAKERCMD_OPT_ROCK_RIDGE,
     
    463464     */
    464465    { "--name-setup",                   RTFSISOMAKERCMD_OPT_NAME_SETUP,                     RTGETOPT_REQ_STRING  },
     466    { "--name-setup-from-import",       RTFSISOMAKERCMD_OPT_NAME_SETUP_FROM_IMPORT,         RTGETOPT_REQ_NOTHING },
    465467    { "--import-iso",                   RTFSISOMAKERCMD_OPT_IMPORT_ISO,                     RTGETOPT_REQ_STRING  },
    466468    { "--push-iso",                     RTFSISOMAKERCMD_OPT_PUSH_ISO,                       RTGETOPT_REQ_STRING  },
     
    14191421
    14201422/**
     1423 * Handles the --name-setup-from-import option.
     1424 *
     1425 * @returns IPRT status code.
     1426 * @param   pOpts               The ISO maker command instance.
     1427 */
     1428static int rtFsIsoMakerCmdOptNameSetupFromImport(PRTFSISOMAKERCMDOPTS pOpts)
     1429{
     1430    /*
     1431     * Figure out what's on the ISO.
     1432     */
     1433    uint32_t fNamespaces = RTFsIsoMakerGetPopulatedNamespaces(pOpts->hIsoMaker);
     1434    AssertReturn(fNamespaces != UINT32_MAX, VERR_INVALID_HANDLE);
     1435    if (fNamespaces != 0)
     1436    {
     1437        if (   (fNamespaces & RTFSISOMAKER_NAMESPACE_ISO_9660)
     1438            && RTFsIsoMakerGetRockRidgeLevel(pOpts->hIsoMaker) > 0)
     1439            fNamespaces |= RTFSISOMAKERCMDNAME_PRIMARY_ISO_ROCK_RIDGE;
     1440
     1441        if (   (fNamespaces & RTFSISOMAKER_NAMESPACE_JOLIET)
     1442            && RTFsIsoMakerGetJolietRockRidgeLevel(pOpts->hIsoMaker) > 0)
     1443            fNamespaces |= RTFSISOMAKERCMDNAME_JOLIET_ROCK_RIDGE;
     1444
     1445        /*
     1446         * The TRANS.TBL files cannot be disabled at present and the importer
     1447         * doesn't check whether they are there or not, so carry them on from
     1448         * the previous setup.
     1449         */
     1450        uint32_t fOld = 0;
     1451        uint32_t i    = pOpts->cNameSpecifiers;
     1452        while (i-- > 0)
     1453            fOld |= pOpts->afNameSpecifiers[0];
     1454        if (fNamespaces & RTFSISOMAKER_NAMESPACE_ISO_9660)
     1455            fNamespaces |= fOld & RTFSISOMAKERCMDNAME_PRIMARY_ISO_TRANS_TBL;
     1456        if (fNamespaces & RTFSISOMAKER_NAMESPACE_JOLIET)
     1457            fNamespaces |= fOld & RTFSISOMAKERCMDNAME_PRIMARY_ISO_TRANS_TBL;
     1458        if (fNamespaces & RTFSISOMAKER_NAMESPACE_UDF)
     1459            fNamespaces |= fOld & RTFSISOMAKERCMDNAME_UDF_TRANS_TBL;
     1460        if (fNamespaces & RTFSISOMAKER_NAMESPACE_HFS)
     1461            fNamespaces |= fOld & RTFSISOMAKERCMDNAME_HFS_TRANS_TBL;
     1462
     1463        /*
     1464         * Apply the new configuration.
     1465         */
     1466        pOpts->cNameSpecifiers     = 1;
     1467        pOpts->afNameSpecifiers[0] = fNamespaces;
     1468        pOpts->fDstNamespaces      = fNamespaces & RTFSISOMAKERCMDNAME_MAJOR_MASK;
     1469
     1470        char szTmp[128];
     1471        rtFsIsoMakerPrintf(pOpts, "info: --name-setup-from-import determined: --name-setup=%s\n",
     1472                           rtFsIsoMakerCmdNameSpecifiersToString(fNamespaces, szTmp, sizeof(szTmp)));
     1473        return VINF_SUCCESS;
     1474    }
     1475    return rtFsIsoMakerCmdErrorRc(pOpts, VERR_DRIVE_IS_EMPTY, "--name-setup-from-import used on an empty ISO");
     1476}
     1477
     1478
     1479/**
    14211480 * Checks if we should use the source stack or the regular file system for
    14221481 * opening a source.
     
    31873246                break;
    31883247
     3248            case RTFSISOMAKERCMD_OPT_NAME_SETUP_FROM_IMPORT:
     3249                rc = rtFsIsoMakerCmdOptNameSetupFromImport(pOpts);
     3250                break;
     3251
    31893252            case RTFSISOMAKERCMD_OPT_PUSH_ISO:
    31903253                rc = rtFsIsoMakerCmdOptPushIso(pOpts, ValueUnion.psz, "--push-iso", 0);
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