VirtualBox

Changeset 68318 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Aug 7, 2017 3:14:26 PM (7 years ago)
Author:
vboxsync
Message:

Unattended: detectIsoOS updates.

Location:
trunk/src/VBox
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageMisc.cpp

    r68258 r68318  
    13261326    CHECK_ERROR2_RET(hrc, a->virtualBox, CreateUnattendedInstaller(ptrUnattended.asOutParam()), RTEXITCODE_FAILURE);
    13271327    CHECK_ERROR2_RET(hrc, ptrUnattended, COMSETTER(IsoPath)(Bstr(szIsoPath).raw()), RTEXITCODE_FAILURE);
    1328     CHECK_ERROR2_RET(hrc, ptrUnattended, DetectIsoOS(), RTEXITCODE_FAILURE);
     1328    CHECK_ERROR2(hrc, ptrUnattended, DetectIsoOS());
     1329    RTEXITCODE rcExit = SUCCEEDED(hrc) ? RTEXITCODE_SUCCESS : RTEXITCODE_FAILURE;
    13291330
    13301331    /*
     
    13671368    }
    13681369
    1369     return RTEXITCODE_SUCCESS;
     1370    return rcExit;
    13701371}
    13711372
  • trunk/src/VBox/Main/include/UnattendedImpl.h

    r68239 r68318  
    203203
    204204    /**
    205      * Worker for reconfigureVM.
     205     * Worker for detectIsoOs().
     206     *
     207     * @returns COM status code.
     208     * @retval  S_OK if detected.
     209     * @retval  S_FALSE if not detected.
     210     *
     211     * @param   hVfsIso     The ISO file system handle.
     212     */
     213    HRESULT i_innerDetectIsoOS(RTVFS hVfsIso);
     214
     215    /**
     216     * Worker for reconfigureVM().
    206217     * The caller makes sure to close the session whatever happens.
    207218     */
  • trunk/src/VBox/Main/src-server/UnattendedImpl.cpp

    r68240 r68318  
    3333#include <iprt/ctype.h>
    3434#include <iprt/file.h>
     35#include <iprt/fsvfs.h>
     36#include <iprt/inifile.h>
    3537#include <iprt/locale.h>
    3638#include <iprt/path.h>
    3739
    3840using namespace std;
     41
     42/* XPCOM doesn't define S_FALSE. */
     43#ifndef S_FALSE
     44# define S_FALSE ((HRESULT)1)
     45#endif
    3946
    4047
     
    231238HRESULT Unattended::detectIsoOS()
    232239{
    233     AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     240    HRESULT       hrc;
     241    AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
     242
     243/** @todo once UDF is implemented properly and we've tested this code a lot
     244 *        more, replace E_NOTIMPL with E_FAIL. */
     245
     246
     247    /*
     248     * Open the ISO.
     249     */
     250    RTVFSFILE hVfsFileIso;
     251    int vrc = RTVfsFileOpenNormal(mStrIsoPath.c_str(), RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE, &hVfsFileIso);
     252    if (RT_FAILURE(vrc))
     253        return setErrorBoth(E_NOTIMPL, vrc, tr("Failed to open '%s' (%Rrc)"), mStrIsoPath.c_str(), vrc);
     254
     255    RTERRINFOSTATIC ErrInfo;
     256    RTVFS hVfsIso;
     257    vrc = RTFsIso9660VolOpen(hVfsFileIso, 0 /*fFlags*/, &hVfsIso, RTErrInfoInitStatic(&ErrInfo));
     258    if (RT_SUCCESS(vrc))
     259    {
     260        /*
     261         * Try do the detection.  Repeat for different file system variations (nojoliet, noudf).
     262         */
     263        hrc = i_innerDetectIsoOS(hVfsIso);
     264
     265        RTVfsRelease(hVfsIso);
     266        hrc = E_NOTIMPL;
     267    }
     268    else if (RTErrInfoIsSet(&ErrInfo.Core))
     269        hrc = setErrorBoth(E_NOTIMPL, vrc, tr("Failed to open '%s' as ISO FS (%Rrc) - %s"),
     270                           mStrIsoPath.c_str(), vrc, ErrInfo.Core.pszMsg);
     271    else
     272        hrc = setErrorBoth(E_NOTIMPL, vrc, tr("Failed to open '%s' as ISO FS (%Rrc)"), mStrIsoPath.c_str(), vrc);
     273    RTVfsFileRelease(hVfsFileIso);
    234274
    235275    /*
     
    303343
    304344    /** @todo implement actual detection logic. */
    305     return E_NOTIMPL;
    306 }
     345    return hrc;
     346}
     347
     348HRESULT Unattended::i_innerDetectIsoOS(RTVFS hVfsIso)
     349{
     350    union
     351    {
     352        char sz[4096];
     353    } uBuf;
     354
     355    // globalinstallorder.xml - vista beta2
     356    // sources/idwbinfo.txt   - ditto.
     357    // sources/lang.ini       - ditto.
     358
     359    VBOXOSTYPE enmOsType = VBOXOSTYPE_Unknown;
     360
     361    /*
     362     * Try look for the 'sources/idwbinfo.txt' file containing windows build info.
     363     * This file appeared with Vista beta 2 from what we can tell.  Before windows 10
     364     * it contains easily decodable branch names, after that things goes weird.
     365     */
     366    /** @todo This requires UDF reader support, since vista beta 2 and later seems
     367     *        all to use UDF rather than joliet.  Sigh. */
     368    RTVFSFILE hVfsFile;
     369    int vrc = RTVfsFileOpen(hVfsIso, "sources/idwbinfo.txt", RTFILE_O_READ | RTFILE_O_DENY_NONE | RTFILE_O_OPEN, &hVfsFile);
     370    if (RT_SUCCESS(vrc))
     371    {
     372        enmOsType = VBOXOSTYPE_WinNT_x64;
     373
     374        RTINIFILE hIniFile;
     375        vrc = RTIniFileCreateFromVfsFile(&hIniFile, hVfsFile, RTINIFILE_F_READONLY);
     376        RTVfsFileRelease(hVfsFile);
     377        if (RT_SUCCESS(vrc))
     378        {
     379            vrc = RTIniFileQueryValue(hIniFile, "BUILDINFO", "BuildArch", uBuf.sz, sizeof(uBuf), NULL);
     380            if (RT_SUCCESS(vrc))
     381            {
     382                LogRelFlow(("Unattended: sources/idwbinfo.txt: BuildArch=%s\n", uBuf.sz));
     383                if (   RTStrNICmp(uBuf.sz, RT_STR_TUPLE("amd64")) == 0
     384                    || RTStrNICmp(uBuf.sz, RT_STR_TUPLE("x64"))   == 0 /* just in case */ )
     385                    enmOsType = VBOXOSTYPE_WinNT_x64;
     386                else if (RTStrNICmp(uBuf.sz, RT_STR_TUPLE("x86")) == 0)
     387                    enmOsType = VBOXOSTYPE_WinNT;
     388                else
     389                {
     390                    LogRel(("Unattended: sources/idwbinfo.txt: Unknown: BuildArch=%s\n", uBuf.sz));
     391                    enmOsType = VBOXOSTYPE_WinNT_x64;
     392                }
     393            }
     394
     395            vrc = RTIniFileQueryValue(hIniFile, "BUILDINFO", "BuildBranch", uBuf.sz, sizeof(uBuf), NULL);
     396            if (RT_SUCCESS(vrc))
     397            {
     398                LogRelFlow(("Unattended: sources/idwbinfo.txt: BuildBranch=%s\n", uBuf.sz));
     399                if (   RTStrNICmp(uBuf.sz, RT_STR_TUPLE("vista")) == 0
     400                    || RTStrNICmp(uBuf.sz, RT_STR_TUPLE("winmain_beta")) == 0)
     401                    enmOsType = (VBOXOSTYPE)((enmOsType & VBOXOSTYPE_x64) | VBOXOSTYPE_WinVista);
     402                else if (RTStrNICmp(uBuf.sz, RT_STR_TUPLE("win7")) == 0)
     403                    enmOsType = (VBOXOSTYPE)((enmOsType & VBOXOSTYPE_x64) | VBOXOSTYPE_Win7);
     404                else if (   RTStrNICmp(uBuf.sz, RT_STR_TUPLE("winblue")) == 0
     405                         || RTStrNICmp(uBuf.sz, RT_STR_TUPLE("winmain_blue")) == 0
     406                         || RTStrNICmp(uBuf.sz, RT_STR_TUPLE("win81")) == 0 /* not seen, but just in case its out there */ )
     407                    enmOsType = (VBOXOSTYPE)((enmOsType & VBOXOSTYPE_x64) | VBOXOSTYPE_Win81);
     408                else if (   RTStrNICmp(uBuf.sz, RT_STR_TUPLE("win8")) == 0
     409                         || RTStrNICmp(uBuf.sz, RT_STR_TUPLE("winmain_win8")) == 0 )
     410                    enmOsType = (VBOXOSTYPE)((enmOsType & VBOXOSTYPE_x64) | VBOXOSTYPE_Win8);
     411                else
     412                    LogRel(("Unattended: sources/idwbinfo.txt: Unknown: BuildBranch=%s\n", uBuf.sz));
     413            }
     414            RTIniFileRelease(hIniFile);
     415        }
     416    }
     417
     418    /*
     419     *
     420     */
     421    if (   enmOsType != VBOXOSTYPE_Unknown
     422        && enmOsType != VBOXOSTYPE_Unknown_x64)
     423    {
     424        mStrDetectedOSTypeId = Global::OSTypeId(enmOsType);
     425    }
     426
     427    return S_FALSE;
     428}
     429
    307430
    308431HRESULT Unattended::prepare()
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