VirtualBox

Ignore:
Timestamp:
Jun 16, 2017 2:31:28 PM (8 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
116176
Message:

IPRT: More ISO maker code (booting related).

File:
1 edited

Legend:

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

    r67437 r67445  
    285285    } u;
    286286} RTFSISOMKCMDELTORITOENTRY;
     287/** Pointer to an el torito boot entry. */
     288typedef RTFSISOMKCMDELTORITOENTRY *PRTFSISOMKCMDELTORITOENTRY;
    287289
    288290/**
     
    13351337                if (idxObj != UINT32_MAX)
    13361338                {
    1337                     int rc = RTFsIsoMakerObjRemove(pOpts->hIsoMaker, idxObj);
     1339                    rc = RTFsIsoMakerObjRemove(pOpts->hIsoMaker, idxObj);
    13381340                    if (RT_FAILURE(rc))
    13391341                        return rtFsIsoMakerCmdErrorRc(pOpts, rc, "Failed to remove '%s': %Rrc", pszSpec, rc);
     
    13541356        uint32_t        offError;
    13551357        RTERRINFOSTATIC ErrInfo;
    1356         int rc = RTVfsChainQueryInfo(pszSrc, &ObjInfo, RTFSOBJATTRADD_UNIX,
    1357                                      RTPATH_F_FOLLOW_LINK, &offError, RTErrInfoInitStatic(&ErrInfo));
     1358        rc = RTVfsChainQueryInfo(pszSrc, &ObjInfo, RTFSOBJATTRADD_UNIX,
     1359                                 RTPATH_F_FOLLOW_LINK, &offError, RTErrInfoInitStatic(&ErrInfo));
    13581360        if (RT_FAILURE(rc))
    13591361            return rtFsIsoMakerCmdChainError(pOpts, "RTVfsChainQueryInfo", pszSrc, rc, offError, &ErrInfo.Core);
     
    17471749     * Locate and configure the boot images first.
    17481750     */
    1749     for (uint32_t idxBootCat = 1; idxBootCat < pOpts->cBootCatEntries; idxBootCat++)
    1750         if (   pOpts->aBootCatEntries[idxBootCat].enmType == RTFSISOMKCMDELTORITOENTRY::kEntryType_Default
    1751             || pOpts->aBootCatEntries[idxBootCat].enmType == RTFSISOMKCMDELTORITOENTRY::kEntryType_Section)
     1751    int rc;
     1752    PRTFSISOMKCMDELTORITOENTRY pBootCatEntry = &pOpts->aBootCatEntries[1];
     1753    for (uint32_t idxBootCat = 1; idxBootCat < pOpts->cBootCatEntries; idxBootCat++, pBootCatEntry++)
     1754        if (   pBootCatEntry->enmType == RTFSISOMKCMDELTORITOENTRY::kEntryType_Default
     1755            || pBootCatEntry->enmType == RTFSISOMKCMDELTORITOENTRY::kEntryType_Section)
    17521756        {
    17531757            /* Make sure we've got a boot image. */
    1754             uint32_t idxImageObj = pOpts->aBootCatEntries[idxBootCat].u.Section.idxImageObj;
     1758            uint32_t idxImageObj = pBootCatEntry->u.Section.idxImageObj;
    17551759            if (idxImageObj == UINT32_MAX)
    17561760            {
    1757                 const char *pszBootImage = pOpts->aBootCatEntries[idxBootCat].u.Section.pszImageNameInIso;
     1761                const char *pszBootImage = pBootCatEntry->u.Section.pszImageNameInIso;
    17581762                if (pszBootImage == NULL)
    17591763                    return rtFsIsoMakerCmdSyntaxError(pOpts, "No image name given for boot catalog entry #%u", idxBootCat);
     
    17631767                    return rtFsIsoMakerCmdSyntaxError(pOpts, "Unable to locate image for boot catalog entry #%u: %s",
    17641768                                                      idxBootCat, pszBootImage);
    1765                 pOpts->aBootCatEntries[idxBootCat].u.Section.idxImageObj = idxImageObj;
     1769                pBootCatEntry->u.Section.idxImageObj = idxImageObj;
    17661770            }
    17671771
    17681772            /* Enable patching it? */
    1769             if (pOpts->aBootCatEntries[idxBootCat].u.Section.fInsertBootInfoTable)
     1773            if (pBootCatEntry->u.Section.fInsertBootInfoTable)
    17701774            {
    1771                 int rc = RTFsIsoMakerObjEnableBootInfoTablePatching(pOpts->hIsoMaker, idxImageObj, true);
     1775                rc = RTFsIsoMakerObjEnableBootInfoTablePatching(pOpts->hIsoMaker, idxImageObj, true);
    17721776                if (RT_FAILURE(rc))
    17731777                    return rtFsIsoMakerCmdErrorRc(pOpts, rc,
     
    17771781
    17781782            /* Figure out the floppy type given the object size. */
    1779             if (pOpts->aBootCatEntries[idxBootCat].u.Section.bBootMediaType == ISO9660_ELTORITO_BOOT_MEDIA_TYPE_MASK)
     1783            if (pBootCatEntry->u.Section.bBootMediaType == ISO9660_ELTORITO_BOOT_MEDIA_TYPE_MASK)
    17801784            {
    17811785                uint64_t cbImage;
    1782                 int rc = RTFsIsoMakerObjQueryDataSize(pOpts->hIsoMaker, idxImageObj, &cbImage);
     1786                rc = RTFsIsoMakerObjQueryDataSize(pOpts->hIsoMaker, idxImageObj, &cbImage);
    17831787                if (RT_FAILURE(rc))
    17841788                    return rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTFsIsoMakerObjGetDataSize failed on entry #%u: %Rrc\n",
    17851789                                                  idxBootCat, rc);
    17861790                if (cbImage == 1228800)
    1787                     pOpts->aBootCatEntries[idxBootCat].u.Section.bBootMediaType = ISO9660_ELTORITO_BOOT_MEDIA_TYPE_FLOPPY_1_2_MB;
     1791                    pBootCatEntry->u.Section.bBootMediaType = ISO9660_ELTORITO_BOOT_MEDIA_TYPE_FLOPPY_1_2_MB;
    17881792                else if (cbImage <= 1474560)
    1789                     pOpts->aBootCatEntries[idxBootCat].u.Section.bBootMediaType = ISO9660_ELTORITO_BOOT_MEDIA_TYPE_FLOPPY_1_44_MB;
     1793                    pBootCatEntry->u.Section.bBootMediaType = ISO9660_ELTORITO_BOOT_MEDIA_TYPE_FLOPPY_1_44_MB;
    17901794                else if (cbImage <= 2949120)
    1791                     pOpts->aBootCatEntries[idxBootCat].u.Section.bBootMediaType = ISO9660_ELTORITO_BOOT_MEDIA_TYPE_FLOPPY_2_88_MB;
     1795                    pBootCatEntry->u.Section.bBootMediaType = ISO9660_ELTORITO_BOOT_MEDIA_TYPE_FLOPPY_2_88_MB;
    17921796                else
    1793                     pOpts->aBootCatEntries[idxBootCat].u.Section.bBootMediaType = ISO9660_ELTORITO_BOOT_MEDIA_TYPE_HARD_DISK;
     1797                    pBootCatEntry->u.Section.bBootMediaType = ISO9660_ELTORITO_BOOT_MEDIA_TYPE_HARD_DISK;
    17941798            }
    17951799        }
     
    17981802     * Add the boot catalog entries.
    17991803     */
    1800 
     1804    pBootCatEntry = &pOpts->aBootCatEntries[0];
     1805    for (uint32_t idxBootCat = 0; idxBootCat < pOpts->cBootCatEntries; idxBootCat++, pBootCatEntry++)
     1806        switch (pBootCatEntry->enmType)
     1807        {
     1808            case RTFSISOMKCMDELTORITOENTRY::kEntryType_Validation:
     1809                Assert(idxBootCat == 0);
     1810                rc = RTFsIsoMakerBootCatSetValidationEntry(pOpts->hIsoMaker, pBootCatEntry->u.Validation.idPlatform,
     1811                                                           pBootCatEntry->u.Validation.pszString);
     1812                if (RT_FAILURE(rc))
     1813                    return rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTFsIsoMakerBootCatSetValidationEntry failed: %Rrc\n", rc);
     1814                break;
     1815
     1816            case RTFSISOMKCMDELTORITOENTRY::kEntryType_Default:
     1817            case RTFSISOMKCMDELTORITOENTRY::kEntryType_Section:
     1818                Assert(pBootCatEntry->enmType == RTFSISOMKCMDELTORITOENTRY::kEntryType_Default ? idxBootCat == 1 : idxBootCat > 2);
     1819                rc = RTFsIsoMakerBootCatSetSectionEntry(pOpts->hIsoMaker, idxBootCat,
     1820                                                        pBootCatEntry->u.Section.idxImageObj,
     1821                                                        pBootCatEntry->u.Section.bBootMediaType,
     1822                                                        pBootCatEntry->u.Section.bSystemType,
     1823                                                        pBootCatEntry->u.Section.fBootable,
     1824                                                        pBootCatEntry->u.Section.uLoadSeg,
     1825                                                        pBootCatEntry->u.Section.cSectorsToLoad);
     1826                if (RT_FAILURE(rc))
     1827                    return rtFsIsoMakerCmdErrorRc(pOpts, rc, "RTFsIsoMakerBootCatSetSectionEntry failed on entry #%u: %Rrc\n",
     1828                                                  idxBootCat, rc);
     1829                break;
     1830
     1831            case RTFSISOMKCMDELTORITOENTRY::kEntryType_SectionHeader:
     1832            {
     1833                uint32_t cEntries = 1;
     1834                while (   idxBootCat + cEntries < pOpts->cBootCatEntries
     1835                       && pBootCatEntry[cEntries].enmType != RTFSISOMKCMDELTORITOENTRY::kEntryType_SectionHeader)
     1836                    cEntries++;
     1837                cEntries--;
     1838
     1839                Assert(idxBootCat > 1);
     1840                rc = RTFsIsoMakerBootCatSetSectionHeaderEntry(pOpts->hIsoMaker, idxBootCat, cEntries,
     1841                                                              pBootCatEntry->u.SectionHeader.idPlatform,
     1842                                                              pBootCatEntry->u.SectionHeader.pszString);
     1843                if (RT_FAILURE(rc))
     1844                    return rtFsIsoMakerCmdErrorRc(pOpts, rc,
     1845                                                  "RTFsIsoMakerBootCatSetSectionHeaderEntry failed on entry #%u: %Rrc\n",
     1846                                                  idxBootCat, rc);
     1847                break;
     1848            }
     1849
     1850            default:
     1851                AssertFailedReturn(VERR_INTERNAL_ERROR_3);
     1852        }
    18011853
    18021854    return VINF_SUCCESS;
     
    20022054            rc = rtFsIsoMakerCmdErrorRc(&Opts, VERR_INVALID_PARAMETER, "No output file specified (--output <file>)");
    20032055    }
     2056
     2057    /*
     2058     * Final actions.
     2059     */
     2060    if (RT_SUCCESS(rc))
     2061        rc = rtFsIsoMakerCmdOptEltoritoCommitBootCatalog(&Opts);
    20042062    if (RT_SUCCESS(rc))
    20052063    {
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