Changeset 28779 in vbox for trunk/src/VBox/Main/linux
- Timestamp:
- Apr 26, 2010 8:18:24 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/linux/HostHardwareLinux.cpp
r28741 r28779 172 172 { 173 173 int rcIoCtl; 174 /** @todo The next line can produce a warning, as the ioctl request175 * field is defined as signed, but the Linux ioctl definition macros176 * produce unsigned constants. */177 174 rc = RTFileIoCtl(File, FDGETDRVTYP, pszName, 0, &rcIoCtl); 178 175 RTFileClose(File); … … 1591 1588 1592 1589 1590 #define USBDEVICE_MAJOR 189 1591 1592 /** Deduce the bus that a USB device is plugged into from the device node 1593 * number. See drivers/usb/core/hub.c:usb_new_device as of Linux 2.6.20. */ 1594 static unsigned usbBusFromDevNum(dev_t devNum) 1595 { 1596 AssertReturn(devNum, 0); 1597 AssertReturn(major(devNum) == USBDEVICE_MAJOR, 0); 1598 return (minor(devNum) >> 7) + 1; 1599 } 1600 1601 1602 /** Deduce the device number of a USB device on the bus from the device node 1603 * number. See drivers/usb/core/hub.c:usb_new_device as of Linux 2.6.20. */ 1604 static unsigned usbDeviceFromDevNum(dev_t devNum) 1605 { 1606 AssertReturn(devNum, 0); 1607 AssertReturn(major(devNum) == USBDEVICE_MAJOR, 0); 1608 return (minor(devNum) & 127) + 1; 1609 } 1610 1611 1593 1612 /** 1594 1613 * Tell whether a file in /sys/bus/usb/devices is a device rather than an … … 1607 1626 return true; 1608 1627 dev_t devnum = RTLinuxSysFsReadDevNumFile("%s/dev", pcszNode); 1628 /* Sanity test of our static helpers */ 1629 Assert(usbBusFromDevNum(makedev(USBDEVICE_MAJOR, 517)) == 5); 1630 Assert(usbDeviceFromDevNum(makedev(USBDEVICE_MAJOR, 517)) == 6); 1609 1631 AssertReturn (devnum, true); 1610 1632 char szDevPath[RTPATH_MAX]; … … 1613 1635 szDevPath, sizeof(szDevPath), 1614 1636 "/dev/bus/usb/%.3d/%.3d", 1615 RTLinuxSysFsReadIntFile(10, "%s/busnum", pcszNode),1616 RTLinuxSysFsReadIntFile(10, "%s/devnum", pcszNode));1637 usbBusFromDevNum(devnum), 1638 usbDeviceFromDevNum(devnum)); 1617 1639 if (cchDevPath < 0) 1618 1640 return true;
Note:
See TracChangeset
for help on using the changeset viewer.