VirtualBox

Changeset 1354 in vbox for trunk


Ignore:
Timestamp:
Mar 9, 2007 9:39:20 AM (18 years ago)
Author:
vboxsync
Message:

Make it possible to move shared libs from /opt/VirtualBox-xxx to /usr/lib as required for Mandriva packages. Make it possible to move runtime modules to /usr/lib/virtualbox.

Location:
trunk/src/VBox/VMM
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/PDMDevice.cpp

    r838 r1354  
    573573    {
    574574        /* make filename */
    575         char *pszFilename = pdmR3FileR3("VBoxDD");
     575        char *pszFilename = pdmR3FileR3("VBoxDD", /*fShared=*/true);
    576576        if (!pszFilename)
    577577            return VERR_NO_TMP_MEMORY;
     
    582582
    583583        /* make filename */
    584         pszFilename = pdmR3FileR3("VBoxDD2");
     584        pszFilename = pdmR3FileR3("VBoxDD2", /*fShared=*/true);
    585585        if (!pszFilename)
    586586            return VERR_NO_TMP_MEMORY;
  • trunk/src/VBox/VMM/PDMDriver.cpp

    r914 r1354  
    204204    {
    205205        /* make filename */
    206         char *pszFilename = pdmR3FileR3("VBoxDD");
     206        char *pszFilename = pdmR3FileR3("VBoxDD", /*fShared=*/true);
    207207        if (!pszFilename)
    208208            return VERR_NO_TMP_MEMORY;
  • trunk/src/VBox/VMM/PDMInternal.h

    r526 r1354  
    724724int         pdmR3LdrInit(PVM pVM);
    725725void        pdmR3LdrTerm(PVM pVM);
    726 char *      pdmR3FileR3(const char *pszFile);
     726char *      pdmR3FileR3(const char *pszFile, bool fShared=false);
    727727int         pdmR3LoadR3(PVM pVM, const char *pszFilename, const char *pszName);
    728728
  • trunk/src/VBox/VMM/PDMLdr.cpp

    r1308 r1354  
    6767static char *   pdmR3FileGC(const char *pszFile);
    6868static char *   pdmR3FileR0(const char *pszFile);
    69 static char *   pdmR3File(const char *pszFile, const char *pszDefaultExt);
     69static char *   pdmR3File(const char *pszFile, const char *pszDefaultExt, bool fShared);
    7070static DECLCALLBACK(int) pdmR3QueryModFromEIPEnumSymbols(RTLDRMOD hLdrMod, const char *pszSymbol, unsigned uSymbol, RTUINTPTR Value, void *pvUser);
    7171
     
    834834 * @todo    We'll have this elsewhere than in the root later!
    835835 */
    836 char *pdmR3FileR3(const char *pszFile)
    837 {
    838     return pdmR3File(pszFile, NULL);
     836char *pdmR3FileR3(const char *pszFile, bool fShared)
     837{
     838    return pdmR3File(pszFile, NULL, fShared);
    839839}
    840840
     
    851851char * pdmR3FileR0(const char *pszFile)
    852852{
    853     return pdmR3File(pszFile, NULL);
     853    return pdmR3File(pszFile, NULL, /*fShared=*/false);
    854854}
    855855
     
    866866char * pdmR3FileGC(const char *pszFile)
    867867{
    868     return pdmR3File(pszFile, NULL);
    869 }
    870 
     868    return pdmR3File(pszFile, NULL, /*fShared=*/false);
     869}
     870
     871/**
     872 * Worker for pdmR3File().
     873 *
     874 * @returns Pointer to temporary memory containing the filename.
     875 *          Caller must free this using RTMemTmpFree().
     876 * @returns NULL on failure.
     877 * @param   pszDir        Directory part
     878 * @param   pszFile       File name part
     879 * @param   pszDefaultExt Extension part
     880 */
     881static char * pdmR3FileConstruct(const char *pszDir, const char *pszFile, const char *pszDefaultExt)
     882{
     883    /*
     884     * Allocate temp memory for return buffer.
     885     */
     886    unsigned cchDir  = strlen(pszDir);
     887    unsigned cchFile = strlen(pszFile);
     888    unsigned cchDefaultExt;
     889
     890    /*
     891     * Default extention?
     892     */
     893    if (!pszDefaultExt || strchr(pszFile, '.'))
     894        cchDefaultExt = 0;
     895    else
     896        cchDefaultExt = strlen(pszDefaultExt);
     897
     898    unsigned cchPath = cchDir + 1 + cchFile + cchDefaultExt + 1;
     899    if (cchPath > RTPATH_MAX)
     900    {
     901        AssertMsgFailed("Path too long!\n");
     902        return NULL;
     903    }
     904
     905    char *pszRet = (char *)RTMemTmpAlloc(cchDir + 1 + cchFile + cchDefaultExt + 1);
     906    if (!pszRet)
     907    {
     908        AssertMsgFailed(("Out of temporary memory!\n"));
     909        return NULL;
     910    }
     911
     912    /*
     913     * Construct the filename.
     914     */
     915    memcpy(pszRet, pszDir, cchDir);
     916    pszRet[cchDir++] = '/';            /* this works everywhere */
     917    memcpy(pszRet + cchDir, pszFile, cchFile + 1);
     918    if (cchDefaultExt)
     919        memcpy(pszRet + cchDir + cchFile, pszDefaultExt, cchDefaultExt + 1);
     920
     921    return pszRet;
     922}
    871923
    872924/**
     
    878930 * @param   pszFile         File name (no path).
    879931 * @param   pszDefaultExt   The default extention, NULL if none.
     932 * @param   fShared         If true, search in the shared directory (/usr/lib on Unix), else
     933 *                          search in the private directory (/usr/lib/virtualbox on Unix).
     934 *                          Ignored if VBOX_PATH_SHARED_LIBS is not defined.
    880935 * @todo    We'll have this elsewhere than in the root later!
    881  */
    882 static char * pdmR3File(const char *pszFile, const char *pszDefaultExt)
    883 {
    884     /*
    885      * Default extention?
    886      */
    887     unsigned cchDefaultExt;
    888     if (!pszDefaultExt || strchr(pszFile, '.'))
    889         cchDefaultExt = 0;
    890     else
    891         cchDefaultExt = strlen(pszDefaultExt);
    892 
    893     /*
    894      * Query program path.
    895      */
    896     unsigned    cchFile = strlen(pszFile);
    897     char        szPath[RTPATH_MAX];
    898     int rc = RTPathProgram(szPath, sizeof(szPath) - cchFile - cchDefaultExt - 1);
     936 * @todo    Remove the fShared hack again once we don't need to link against VBoxDD anymore!
     937 */
     938static char * pdmR3File(const char *pszFile, const char *pszDefaultExt, bool fShared)
     939{
     940    char    *pszRet;
     941
     942#ifdef VBOX_PATH_PRIVATE_LIBS
     943
     944    /*
     945     * Unix: Search in /usr/lib/virtualbox
     946     */
     947    pszRet = pdmR3FileConstruct(
     948# ifdef VBOX_PATH_SHARED_LIBS
     949                                fShared ? VBOX_PATH_SHARED_LIBS : VBOX_PATH_PRIVATE_LIBS,
     950# else
     951                                VBOX_PATH_PRIVATE_LIBS,
     952# endif
     953                                pszFile, pszDefaultExt);
     954
     955#else
     956
     957    NOREF(fShared);
     958
     959    /*
     960     * Default: Search in the program path.
     961     */
     962    char     szPath[RTPATH_MAX];
     963    int rc = RTPathProgram(szPath, sizeof(szPath));
    899964    if (!VBOX_SUCCESS(rc))
    900965    {
     
    903968    }
    904969
    905     /*
    906      * Allocate temp memory for return buffer.
    907      */
    908     unsigned cch = strlen(szPath);
    909     char *pszRet = (char *)RTMemTmpAlloc(cch + 1 + cchFile + cchDefaultExt + 1);
    910     if (!pszRet)
    911     {
    912         AssertMsgFailed(("Out of temporary memory!\n"));
    913         return NULL;
    914     }
    915 
    916     /*
    917      * Construct the filename.
    918      */
    919     memcpy(pszRet, szPath, cch);
    920     pszRet[cch++] = '/';            /* this works everywhere */
    921     memcpy(pszRet + cch, pszFile, cchFile + 1);
    922     if (cchDefaultExt)
    923         memcpy(pszRet + cch + cchFile, pszDefaultExt, cchDefaultExt + 1);
     970    pszRet = pdmR3FileConstruct(szPath, pszFile, pszDefaultExt);
     971
     972#endif
     973
    924974    return pszRet;
    925975}
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