Index: /trunk/include/iprt/fsisomaker.h
===================================================================
--- /trunk/include/iprt/fsisomaker.h	(revision 93117)
+++ /trunk/include/iprt/fsisomaker.h	(revision 93118)
@@ -129,4 +129,22 @@
  */
 RTDECL(int) RTFsIsoMakerSetJolietRockRidgeLevel(RTFSISOMAKER hIsoMaker, uint8_t uLevel);
+
+/**
+ * Gets the rock ridge support level (on the primary ISO-9660 namespace).
+ *
+ * @returns 0 if disabled, 1 just enabled, 2 if enabled with ER tag, and
+ *          UINT8_MAX if the handle is invalid.
+ * @param   hIsoMaker           The ISO maker handle.
+ */
+RTDECL(uint8_t) RTFsIsoMakerGetRockRidgeLevel(RTFSISOMAKER hIsoMaker);
+
+/**
+ * Gets the rock ridge support level on the joliet namespace (experimental).
+ *
+ * @returns 0 if disabled, 1 just enabled, 2 if enabled with ER tag, and
+ *          UINT8_MAX if the handle is invalid.
+ * @param   hIsoMaker           The ISO maker handle.
+ */
+RTDECL(uint8_t) RTFsIsoMakerGetJolietRockRidgeLevel(RTFSISOMAKER hIsoMaker);
 
 /**
@@ -257,4 +275,12 @@
 
 /**
+ * Gets currently populated namespaces.
+ *
+ * @returns Set of namespaces (RTFSISOMAKER_NAMESPACE_XXX), UINT32_MAX on error.
+ * @param   hIsoMaker           The ISO maker handle.
+ */
+RTDECL(uint32_t) RTFsIsoMakerGetPopulatedNamespaces(RTFSISOMAKER hIsoMaker);
+
+/**
  * Resolves a path into a object ID.
  *
Index: /trunk/include/iprt/mangling.h
===================================================================
--- /trunk/include/iprt/mangling.h	(revision 93117)
+++ /trunk/include/iprt/mangling.h	(revision 93118)
@@ -1039,5 +1039,8 @@
 # define RTFsIsoMakerBootCatSetSectionHeaderEntry       RT_MANGLER(RTFsIsoMakerBootCatSetSectionHeaderEntry)
 # define RTFsIsoMakerQueryObjIdxForBootCatalog          RT_MANGLER(RTFsIsoMakerQueryObjIdxForBootCatalog)
+# define RTFsIsoMakerGetPopulatedNamespaces             RT_MANGLER(RTFsIsoMakerGetPopulatedNamespaces)
 # define RTFsIsoMakerGetIso9660Level                    RT_MANGLER(RTFsIsoMakerGetIso9660Level)
+# define RTFsIsoMakerGetRockRidgeLevel                  RT_MANGLER(RTFsIsoMakerGetRockRidgeLevel)
+# define RTFsIsoMakerGetJolietRockRidgeLevel            RT_MANGLER(RTFsIsoMakerGetJolietRockRidgeLevel)
 # define RTFsIsoMakerSetImagePadding                    RT_MANGLER(RTFsIsoMakerSetImagePadding)
 # define RTFsIsoMakerSetIso9660Level                    RT_MANGLER(RTFsIsoMakerSetIso9660Level)
Index: /trunk/src/VBox/Runtime/common/fs/isomaker.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/fs/isomaker.cpp	(revision 93117)
+++ /trunk/src/VBox/Runtime/common/fs/isomaker.cpp	(revision 93118)
@@ -271,5 +271,6 @@
     /** Total number of name nodes in the namespace. */
     uint32_t                cNames;
-    /** Total number of directories in the namespace. */
+    /** Total number of directories in the namespace.
+     * @note Appears to be unused.  */
     uint32_t                cDirs;
     /** The namespace selector (RTFSISOMAKER_NAMESPACE_XXX). */
@@ -1280,4 +1281,34 @@
 
 /**
+ * Gets the rock ridge support level (on the primary ISO-9660 namespace).
+ *
+ * @returns 0 if disabled, 1 just enabled, 2 if enabled with ER tag, and
+ *          UINT8_MAX if the handle is invalid.
+ * @param   hIsoMaker           The ISO maker handle.
+ */
+RTDECL(uint8_t) RTFsIsoMakerGetRockRidgeLevel(RTFSISOMAKER hIsoMaker)
+{
+    PRTFSISOMAKERINT pThis = hIsoMaker;
+    RTFSISOMAKER_ASSERT_VALID_HANDLE_RET_EX(pThis, UINT8_MAX);
+    return pThis->PrimaryIso.uRockRidgeLevel;
+}
+
+
+/**
+ * Gets the rock ridge support level on the joliet namespace (experimental).
+ *
+ * @returns 0 if disabled, 1 just enabled, 2 if enabled with ER tag, and
+ *          UINT8_MAX if the handle is invalid.
+ * @param   hIsoMaker           The ISO maker handle.
+ */
+RTDECL(uint8_t) RTFsIsoMakerGetJolietRockRidgeLevel(RTFSISOMAKER hIsoMaker)
+{
+    PRTFSISOMAKERINT pThis = hIsoMaker;
+    RTFSISOMAKER_ASSERT_VALID_HANDLE_RET_EX(pThis, UINT8_MAX);
+    return pThis->Joliet.uRockRidgeLevel;
+}
+
+
+/**
  * Changes the file attribute (mode, owner, group) inherit style (from source).
  *
@@ -2626,4 +2657,27 @@
 
 
+/**
+ * Gets currently populated namespaces.
+ *
+ * @returns Set of namespaces (RTFSISOMAKER_NAMESPACE_XXX), UINT32_MAX on error.
+ * @param   hIsoMaker           The ISO maker handle.
+ */
+RTDECL(uint32_t) RTFsIsoMakerGetPopulatedNamespaces(RTFSISOMAKER hIsoMaker)
+{
+    PRTFSISOMAKERINT pThis = hIsoMaker;
+    RTFSISOMAKER_ASSERT_VALID_HANDLE_RET_EX(pThis, UINT32_MAX);
+
+    uint32_t fRet = 0;
+    if (pThis->PrimaryIso.cNames > 0)
+        fRet |= RTFSISOMAKER_NAMESPACE_ISO_9660;
+    if (pThis->Joliet.cNames     > 0)
+        fRet |= RTFSISOMAKER_NAMESPACE_JOLIET;
+    if (pThis->Udf.cNames        > 0)
+        fRet |= RTFSISOMAKER_NAMESPACE_UDF;
+    if (pThis->Hfs.cNames        > 0)
+        fRet |= RTFSISOMAKER_NAMESPACE_HFS;
+
+    return fRet;
+}
 
 
@@ -5486,6 +5540,15 @@
         return rc;
     AssertReturn(pThis->cObjects > 0, VERR_NO_DATA);
+
+    /* The primary ISO-9660 namespace must be explicitly disabled (for now),
+       so we return VERR_NO_DATA if no root dir. */
     AssertReturn(pThis->PrimaryIso.pRoot || pThis->PrimaryIso.uLevel == 0, VERR_NO_DATA);
-    AssertReturn(pThis->Joliet.pRoot     || pThis->Joliet.uLevel     == 0, VERR_NO_DATA);
+
+    /* Automatically disable the joliet namespace if it is empty (no root dir). */
+    if (!pThis->Joliet.pRoot && pThis->Joliet.uLevel > 0)
+    {
+        pThis->Joliet.uLevel = 0;
+        pThis->cVolumeDescriptors--;
+    }
 
     rc = rtFsIsoMakerFinalizePrepVolumeDescriptors(pThis);
Index: /trunk/src/VBox/Runtime/common/fs/isomakercmd-man.xml
===================================================================
--- /trunk/src/VBox/Runtime/common/fs/isomakercmd-man.xml	(revision 93117)
+++ /trunk/src/VBox/Runtime/common/fs/isomakercmd-man.xml	(revision 93118)
@@ -146,5 +146,5 @@
 
         <varlistentry>
-          <term><option>--name-setup <replaceable>spec</replaceable></option></term>
+          <term><option>--name-setup=<replaceable>spec</replaceable></option></term>
           <listitem><para>Configures active namespaces and how file specifications are to be
               interpreted.  The specification is a comma separated list.  Each element in the list is
@@ -175,4 +175,14 @@
 
         <varlistentry>
+          <term><option>--name-setup-from-import</option></term>
+          <listitem><para>This is for use following one or more <option>--import-iso</option>
+              operations and will pick a configuration matching the imported content as best we can.
+              If the imported ISOs only had a iso9660 namespace, the joliet, udf and hfs namespaces
+              will be removed.  This is useful when adding additional files to the ISO and will
+              prevent guest from picking a namespace without the imported ISO content when mounting it.
+          </para></listitem>
+        </varlistentry>
+
+        <varlistentry>
           <term><option>--push-iso=<replaceable>iso-file</replaceable></option></term>
           <term><option>--push-iso-no-joliet=<replaceable>iso-file</replaceable></option></term>
Index: /trunk/src/VBox/Runtime/common/fs/isomakercmd.cpp
===================================================================
--- /trunk/src/VBox/Runtime/common/fs/isomakercmd.cpp	(revision 93117)
+++ /trunk/src/VBox/Runtime/common/fs/isomakercmd.cpp	(revision 93118)
@@ -100,4 +100,5 @@
     RTFSISOMAKERCMD_OPT_RANDOM_ORDER_VERIFICATION,
     RTFSISOMAKERCMD_OPT_NAME_SETUP,
+    RTFSISOMAKERCMD_OPT_NAME_SETUP_FROM_IMPORT,
 
     RTFSISOMAKERCMD_OPT_ROCK_RIDGE,
@@ -463,4 +464,5 @@
      */
     { "--name-setup",                   RTFSISOMAKERCMD_OPT_NAME_SETUP,                     RTGETOPT_REQ_STRING  },
+    { "--name-setup-from-import",       RTFSISOMAKERCMD_OPT_NAME_SETUP_FROM_IMPORT,         RTGETOPT_REQ_NOTHING },
     { "--import-iso",                   RTFSISOMAKERCMD_OPT_IMPORT_ISO,                     RTGETOPT_REQ_STRING  },
     { "--push-iso",                     RTFSISOMAKERCMD_OPT_PUSH_ISO,                       RTGETOPT_REQ_STRING  },
@@ -1419,4 +1421,61 @@
 
 /**
+ * Handles the --name-setup-from-import option.
+ *
+ * @returns IPRT status code.
+ * @param   pOpts               The ISO maker command instance.
+ */
+static int rtFsIsoMakerCmdOptNameSetupFromImport(PRTFSISOMAKERCMDOPTS pOpts)
+{
+    /*
+     * Figure out what's on the ISO.
+     */
+    uint32_t fNamespaces = RTFsIsoMakerGetPopulatedNamespaces(pOpts->hIsoMaker);
+    AssertReturn(fNamespaces != UINT32_MAX, VERR_INVALID_HANDLE);
+    if (fNamespaces != 0)
+    {
+        if (   (fNamespaces & RTFSISOMAKER_NAMESPACE_ISO_9660)
+            && RTFsIsoMakerGetRockRidgeLevel(pOpts->hIsoMaker) > 0)
+            fNamespaces |= RTFSISOMAKERCMDNAME_PRIMARY_ISO_ROCK_RIDGE;
+
+        if (   (fNamespaces & RTFSISOMAKER_NAMESPACE_JOLIET)
+            && RTFsIsoMakerGetJolietRockRidgeLevel(pOpts->hIsoMaker) > 0)
+            fNamespaces |= RTFSISOMAKERCMDNAME_JOLIET_ROCK_RIDGE;
+
+        /*
+         * The TRANS.TBL files cannot be disabled at present and the importer
+         * doesn't check whether they are there or not, so carry them on from
+         * the previous setup.
+         */
+        uint32_t fOld = 0;
+        uint32_t i    = pOpts->cNameSpecifiers;
+        while (i-- > 0)
+            fOld |= pOpts->afNameSpecifiers[0];
+        if (fNamespaces & RTFSISOMAKER_NAMESPACE_ISO_9660)
+            fNamespaces |= fOld & RTFSISOMAKERCMDNAME_PRIMARY_ISO_TRANS_TBL;
+        if (fNamespaces & RTFSISOMAKER_NAMESPACE_JOLIET)
+            fNamespaces |= fOld & RTFSISOMAKERCMDNAME_PRIMARY_ISO_TRANS_TBL;
+        if (fNamespaces & RTFSISOMAKER_NAMESPACE_UDF)
+            fNamespaces |= fOld & RTFSISOMAKERCMDNAME_UDF_TRANS_TBL;
+        if (fNamespaces & RTFSISOMAKER_NAMESPACE_HFS)
+            fNamespaces |= fOld & RTFSISOMAKERCMDNAME_HFS_TRANS_TBL;
+
+        /*
+         * Apply the new configuration.
+         */
+        pOpts->cNameSpecifiers     = 1;
+        pOpts->afNameSpecifiers[0] = fNamespaces;
+        pOpts->fDstNamespaces      = fNamespaces & RTFSISOMAKERCMDNAME_MAJOR_MASK;
+
+        char szTmp[128];
+        rtFsIsoMakerPrintf(pOpts, "info: --name-setup-from-import determined: --name-setup=%s\n",
+                           rtFsIsoMakerCmdNameSpecifiersToString(fNamespaces, szTmp, sizeof(szTmp)));
+        return VINF_SUCCESS;
+    }
+    return rtFsIsoMakerCmdErrorRc(pOpts, VERR_DRIVE_IS_EMPTY, "--name-setup-from-import used on an empty ISO");
+}
+
+
+/**
  * Checks if we should use the source stack or the regular file system for
  * opening a source.
@@ -3187,4 +3246,8 @@
                 break;
 
+            case RTFSISOMAKERCMD_OPT_NAME_SETUP_FROM_IMPORT:
+                rc = rtFsIsoMakerCmdOptNameSetupFromImport(pOpts);
+                break;
+
             case RTFSISOMAKERCMD_OPT_PUSH_ISO:
                 rc = rtFsIsoMakerCmdOptPushIso(pOpts, ValueUnion.psz, "--push-iso", 0);
