Menu

#1474 Updated regex still fails to match on some systems

1.1.10
closed
None
1
2015-12-06
2015-11-20
No

In commit https://sourceforge.net/p/libmtp/code/ci/8004ca4a1675e5964abb6c6f27a8c4ab4ef706d3/ the sysfs regex was updated to match against some systems which have embedded hubs. However it appears incomplete, as it wouldn't match devices connected to chained hubs further down. For example on my host:

jordan:~/reference/libmtp-1.1.9/util$ lsusb -t
/: Bus 04.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/3p, 480M
| Port 1: Dev 2, If 0, Class=Hub, Driver=hub/8p, 480M
|
Port 5: Dev 5, If 0, Class=Vendor Specific Class, Driver=cp210x, 12M
| Port 6: Dev 4, If 0, Class=Human Interface Device, Driver=usbhid, 1.5M
/: Bus 03.Port 1: Dev 1, Class=root_hub, Driver=ehci-pci/3p, 480M
|
Port 1: Dev 2, If 0, Class=Hub, Driver=hub/6p, 480M
| Port 2: Dev 3, If 0, Class=Hub, Driver=hub/4p, 480M
|
Port 1: Dev 16, If 0, Class=Vendor Specific Class, Driver=, 480M
| Port 1: Dev 16, If 1, Class=Vendor Specific Class, Driver=usbfs, 480M
|
Port 1: Dev 16, If 2, Class=Vendor Specific Class, Driver=usbfs, 480M

Which maps to:
/sys/devices/pci0000:00/0000:00:1a.0/usb3/3-1/3-1.2/3-1.2.1

And the regex would check against: 3-1.2.1:1.2

Which would fail as the '?' operator only matches zero or one time. And in my case I have another hub, adding a second entry. This should be the asterix (zero or many) operator, as each chained hub would add another entry of the (.[0-9]) form.

ret = regcomp(&r, "^[0-9]+-[0-9]+(\\.[0-9])*\\:[0-9]+\\.[0-9]+$", REGEXTENDED | REGNOSUB);

Discussion

  • Marcus Meissner

    Marcus Meissner - 2015-12-06

    I have applied your change to this line.

     
  • Marcus Meissner

    Marcus Meissner - 2015-12-06
    • status: open --> closed
    • assigned_to: Marcus Meissner
     

Anonymous
Anonymous

Add attachments
Cancel