VirtualBox

Changeset 16068 in vbox for trunk/src


Ignore:
Timestamp:
Jan 20, 2009 8:31:56 AM (16 years ago)
Author:
vboxsync
Message:

Main: next attempt to get USB enumeration working on RHEL5

Location:
trunk/src/VBox/Main
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/vbox-dbus.h

    r16006 r16068  
    6969
    7070#define DBUS_ERROR_NO_MEMORY                  "org.freedesktop.DBus.Error.NoMemory"
     71#define DBUS_TYPE_INVALID       ((int) '\0')
    7172#define DBUS_TYPE_STRING        ((int) 's')
    7273#define DBUS_TYPE_ARRAY         ((int) 'a')
  • trunk/src/VBox/Main/linux/HostHardwareLinux.cpp

    r16044 r16068  
    7777#ifdef VBOX_WITH_DBUS
    7878/* These must be extern to be usable in the RTMemAutoPtr template */
    79 extern void halShutdown (DBusConnection *pConnection);
    80 extern void halShutdownPrivate (DBusConnection *pConnection);
    81 
    82 static int halInit(RTMemAutoPtr <DBusConnection, halShutdown> *pConnection);
    83 static int halInitPrivate(RTMemAutoPtr <DBusConnection, halShutdownPrivate> *pConnection);
     79extern void VBoxHalShutdown (DBusConnection *pConnection);
     80extern void VBoxHalShutdownPrivate (DBusConnection *pConnection);
     81
     82static int halInit(RTMemAutoPtr <DBusConnection, VBoxHalShutdown> *pConnection);
     83static int halInitPrivate(RTMemAutoPtr <DBusConnection, VBoxHalShutdownPrivate> *pConnection);
    8484static int halFindDeviceStringMatch (DBusConnection *pConnection,
    8585                                     const char *pszKey, const char *pszValue,
    8686                                     RTMemAutoPtr <DBusMessage, VBoxDBusMessageUnref> *pMessage);
     87static bool dbusMessageIsNonEmptyArray(DBusMessage *pMessage);
    8788static int halGetPropertyStrings (DBusConnection *pConnection,
    8889                                  const char *pszUdi, size_t cKeys,
     
    212213#if defined RT_OS_LINUX && defined VBOX_WITH_DBUS
    213214    /** The connection to DBus */
    214     RTMemAutoPtr <DBusConnection, halShutdownPrivate> mConnection;
     215    RTMemAutoPtr <DBusConnection, VBoxHalShutdownPrivate> mConnection;
    215216    /** Semaphore which is set when a device is hotplugged and reset when
    216217     * it is read. */
     
    553554 */
    554555/* static */
    555 int halInit (RTMemAutoPtr <DBusConnection, halShutdown> *pConnection)
     556int halInit (RTMemAutoPtr <DBusConnection, VBoxHalShutdown> *pConnection)
    556557{
    557558    AssertReturn(VALID_PTR (pConnection), VERR_INVALID_POINTER);
     
    601602 */
    602603/* static */
    603 int halInitPrivate (RTMemAutoPtr <DBusConnection, halShutdownPrivate> *pConnection)
     604int halInitPrivate (RTMemAutoPtr <DBusConnection, VBoxHalShutdownPrivate> *pConnection)
    604605{
    605606    AssertReturn(VALID_PTR (pConnection), VERR_INVALID_POINTER);
     
    643644 */
    644645/* static */
    645 void halShutdown (DBusConnection *pConnection)
     646void VBoxHalShutdown (DBusConnection *pConnection)
    646647{
    647648    AssertReturnVoid(VALID_PTR (pConnection));
     
    665666 */
    666667/* static */
    667 void halShutdownPrivate (DBusConnection *pConnection)
     668void VBoxHalShutdownPrivate (DBusConnection *pConnection)
    668669{
    669670    AssertReturnVoid(VALID_PTR (pConnection));
     
    733734    dbusError.FlowLog();
    734735    return rc;
     736}
     737
     738/**
     739 * Checks whether a message is a non-empty array or something else.
     740 * @returns true if it is, false otherwise.
     741 */
     742/* static */
     743bool dbusMessageIsNonEmptyArray(DBusMessage *pMessage)
     744{
     745    bool fSuccess = true;
     746    DBusMessageIter iterArray, iterItems;
     747    dbus_message_iter_init (pMessage, &iterArray);
     748    if (dbus_message_iter_get_arg_type (&iterArray) != DBUS_TYPE_ARRAY)
     749        fSuccess = false;
     750    if (fSuccess)
     751        dbus_message_iter_recurse (&iterArray, &iterItems);
     752    if (fSuccess && dbus_message_iter_get_arg_type (&iterItems) == DBUS_TYPE_INVALID)
     753        fSuccess = false;
     754    return fSuccess;
    735755}
    736756
     
    852872
    853873    RTMemAutoPtr <DBusMessage, VBoxDBusMessageUnref> message, replyFind, replyGet;
    854     RTMemAutoPtr <DBusConnection, halShutdown> dbusConnection;
     874    RTMemAutoPtr <DBusConnection, VBoxHalShutdown> dbusConnection;
    855875    DBusMessageIter iterFind, iterUdis;
    856876
     
    929949
    930950    RTMemAutoPtr <DBusMessage, VBoxDBusMessageUnref> message, replyFind, replyGet;
    931     RTMemAutoPtr <DBusConnection, halShutdown> dbusConnection;
     951    RTMemAutoPtr <DBusConnection, VBoxHalShutdown> dbusConnection;
    932952    DBusMessageIter iterFind, iterUdis;
    933953
     
    939959        rc = halFindDeviceStringMatch (dbusConnection.get(), "info.subsystem",
    940960                                       "usb_device", &replyFind);
    941         if (RT_SUCCESS(rc) && !replyFind)  /* "Old" syntax. */
     961        if (RT_SUCCESS(rc) && !dbusMessageIsNonEmptyArray (replyFind.get()))  /* "Old" syntax. */
    942962            rc = halFindDeviceStringMatch (dbusConnection.get(),
    943963                                           "linux.subsystem", "usb_device",
     
    10141034
    10151035    RTMemAutoPtr <DBusMessage, VBoxDBusMessageUnref> message, replyFind, replyGet;
    1016     RTMemAutoPtr <DBusConnection, halShutdown> dbusConnection;
     1036    RTMemAutoPtr <DBusConnection, VBoxHalShutdown> dbusConnection;
    10171037    DBusMessageIter iterFind, iterUdis;
    10181038
     
    10431063        const char *pszUdi;
    10441064        dbus_message_iter_get_basic (&iterUdis, &pszUdi);
    1045         static const char *papszKeys[] = { "linux.sysfs_path", "info.subsystem" };
     1065        static const char *papszKeys[] = { "linux.sysfs_path", "info.subsystem",
     1066                                           "linux.subsystem" };
    10461067        char *papszValues[RT_ELEMENTS (papszKeys)];
    10471068        rc = halGetPropertyStrings (dbusConnection.get(), pszUdi, RT_ELEMENTS (papszKeys),
    10481069                                    papszKeys, papszValues, &replyGet);
    10491070        std::string description;
    1050         const char *pszSysfsPath = papszValues[0], *pszSubsystem = papszValues[1];
     1071        const char *pszSysfsPath = papszValues[0], *pszInfoSubsystem = papszValues[1],
     1072                   *pszLinuxSubsystem = papszValues[2];
    10511073        if (!replyGet)
    10521074            halSuccess = false;
     
    10541076            halSuccess = false;
    10551077        if (   halSuccess && RT_SUCCESS (rc)
    1056             && RTStrCmp (pszSubsystem, "usb_device") != 0)  /* Children of buses can also be devices. */
     1078            && RTStrCmp (pszInfoSubsystem, "usb_device") != 0  /* Children of buses can also be devices. */
     1079            && RTStrCmp (pszLinuxSubsystem, "usb_device") != 0)
    10571080            pList->push_back (pszSysfsPath);
    10581081    }
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