VirtualBox

Changeset 99631 in vbox


Ignore:
Timestamp:
May 5, 2023 12:17:43 PM (19 months ago)
Author:
vboxsync
Message:

Guest / Host: Added vbghDisplayServerTryLoadLib() that can handle try loading different versions of a specific library. Needed for newer Ubuntus to properly detect Wayland. bugref:10427

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/GuestHost/DisplayServerType.cpp

    r99627 r99631  
    6565
    6666/**
     67 * Tries to load a (system) library via a set of different names / versions.
     68 *
     69 * @returns VBox status code.
     70 * @returns VERR_NOT_FOUND if the library was not found.
     71 *
     72 * @param   apszLibs            Array of library (version) names to search for.
     73 *                              Descending order (e.g. "libfoo.so", "libfoo.so.2", "libfoo.so.2.6").
     74 * @param   cLibs               Number of library names in \a apszLibs.
     75 * @param   phLdrMod            Where to return the library handle on success.
     76 */
     77static int vbghDisplayServerTryLoadLib(const char **apszLibs, size_t cLibs, PRTLDRMOD phLdrMod)
     78{
     79    for (size_t i = 0; i < cLibs; i++)
     80    {
     81        int rc2 = RTLdrLoadSystem(apszLibs[i], /* fNoUnload = */ true, phLdrMod);
     82        if (RT_SUCCESS(rc2))
     83            return VINF_SUCCESS;
     84    }
     85
     86    return VERR_NOT_FOUND;
     87}
     88
     89/**
    6790 * Tries to detect the desktop display server type the process is running in.
    6891 *
     
    84107    bool     fHasWayland    = false;
    85108    RTLDRMOD hWaylandClient = NIL_RTLDRMOD;
    86     int rc = RTLdrLoadSystem("libwayland-client.so", /* fNoUnload = */ true, &hWaylandClient);
     109
     110    /* Array of libwayland-client.so versions to search for.
     111     * Descending precedence. */
     112    const char* aLibsWayland[] =
     113    {
     114        "libwayland-client.so",
     115        "libwayland-client.so.0" /* Needed for Ubuntu */
     116    };
     117
     118    int rc = vbghDisplayServerTryLoadLib(aLibsWayland, RT_ELEMENTS(aLibsWayland), &hWaylandClient);
    87119    if (RT_SUCCESS(rc))
    88120    {
     
    106138    }
    107139
     140    /* Array of libX11.so versions to search for.
     141     * Descending precedence. */
     142    const char* aLibsX11[] =
     143    {
     144        "libX11.so"
     145    };
     146
    108147    /* Also try to connect to the default X11 display to determine if Xserver is running: */
    109148    bool     fHasX = false;
    110149    RTLDRMOD hX11  = NIL_RTLDRMOD;
    111     rc = RTLdrLoadSystem("libX11.so", /* fNoUnload = */ true, &hX11);
     150    rc = vbghDisplayServerTryLoadLib(aLibsX11, RT_ELEMENTS(aLibsX11), &hX11);
    112151    if (RT_SUCCESS(rc))
    113152    {
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