Skip to contentSkip to conversation

Generic udev rule for PTP camera

DISCUSSION Frederic Peters 2 participants 2 messages Nov 16, 2006

lore
Share & tools
lore
#0 lore raw

Hello,

For a long time, since we totally switched from hotplug to udev, we have been unable in Debian to provide fallback support for unknown PTP cameras.

Hotplugging any known camera works perfectly but this require attentive maintenance of matching USB id and always lags behind constructors.

PTP camera devices define an interface which I thought could be matched by the following rule:

SYSFS{bInterfaceClass}="06", SYSFS{bInterfaceSubClass}="01", \
SYSFS{bInterfaceProtocol}="01", MODE="0660", GROUP="plugdev"

Unfortunately this doesn't work. Then Marcus Meissner from libgphoto2 suggested to use ENV{INTERFACE}="6/1/1" as matcher but I can't get it to work and Marco d'Itri (Debian udev maintainer) believe this not to be the correct solution anyway.

Since Marco doesn't have much time for the moment he suggested I asked the question here, so here it is: what would be the rule to use to set mode/group on /dev/bus/usb/... device when detecting this device by bInterface{Class/SubClass/Protocol} ?

For the record, I copied below the output of udevmonitor --env when plugging in a camera.

Thanks for your support,

Frederic

UEVENT[1163683152.644771] add@/devices/pci0000:00/0000:00:1d.7/usb1/1-2 ACTION­d
DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2 SUBSYSTEM=usb
SEQNUM08
PHYSDEVBUS=usb
PHYSDEVDRIVER=usb

UEVENT[1163683152.645218] add@/devices/pci0000:00/0000:00:1d.7/usb1/1-2/usbdev1.4_ep00 ACTION­d DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2/usbdev1.4_ep00 SUBSYSTEM=usb_endpoint
SEQNUM09
MAJORD2
MINOR=3

UDEV [1163683152.645698] add@/devices/pci0000:00/0000:00:1d.7/usb1/1-2 UDEV_LOG=3
ACTION­d
DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2 SUBSYSTEM=usb
SEQNUM08
PHYSDEVBUS=usb
PHYSDEVDRIVER=usb
UDEVD_EVENT=1
DRIVER=usb

UEVENT[1163683152.647503] add@/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0 ACTION­d
DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0 SUBSYSTEM=usb
SEQNUM10
PHYSDEVBUS=usb
DEVICE=/proc/bus/usb/001/004
PRODUCTJ9/30fd/2
TYPE=0/0/0
INTERFACE=6/1/1 MODALIAS=usb:v04A9p30FDd0002dc00dsc00dp00ic06isc01ip01

UEVENT[1163683152.647551] add@/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep81 ACTION­d DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep81 SUBSYSTEM=usb_endpoint
SEQNUM11
MAJORD2
MINOR=3

UEVENT[1163683152.647585] add@/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep02 ACTION­d DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep02 SUBSYSTEM=usb_endpoint
SEQNUM12
MAJORD2
MINOR=3

UEVENT[1163683152.647618] add@/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep83 ACTION­d DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep83 SUBSYSTEM=usb_endpoint
SEQNUM13
MAJORD2
MINOR=3

UEVENT[1163683152.647657] add@/class/usb_device/usbdev1.4 ACTION­d
DEVPATH=/class/usb_device/usbdev1.4 SUBSYSTEM=usb_device
SEQNUM14 PHYSDEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2 PHYSDEVBUS=usb
PHYSDEVDRIVER=usb
MAJOR9
MINOR=3

UDEV [1163683152.664824] add@/devices/pci0000:00/0000:00:1d.7/usb1/1-2/usbdev1.4_ep00 UDEV_LOG=3
ACTION­d DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2/usbdev1.4_ep00 SUBSYSTEM=usb_endpoint
SEQNUM09
MAJORD2
MINOR=3
UDEVD_EVENT=1
DEVNAME=/dev/usbdev1.4_ep00

UDEV [1163683152.665734] add@/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0 UDEV_LOG=3
ACTION­d
DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0 SUBSYSTEM=usb
SEQNUM10
PHYSDEVBUS=usb
DEVICE=/proc/bus/usb/001/004
PRODUCTJ9/30fd/2
TYPE=0/0/0
INTERFACE=6/1/1 MODALIAS=usb:v04A9p30FDd0002dc00dsc00dp00ic06isc01ip01 UDEVD_EVENT=1

UDEV [1163683152.698823] add@/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep81 UDEV_LOG=3
ACTION­d DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep81 SUBSYSTEM=usb_endpoint
SEQNUM11
MAJORD2
MINOR=3
UDEVD_EVENT=1
DEVNAME=/dev/usbdev1.4_ep81

UDEV [1163683152.700491] add@/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep02 UDEV_LOG=3
ACTION­d DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep02 SUBSYSTEM=usb_endpoint
SEQNUM12
MAJORD2
MINOR=3
UDEVD_EVENT=1
DEVNAME=/dev/usbdev1.4_ep02

UDEV [1163683152.701862] add@/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep83 UDEV_LOG=3
ACTION­d DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep83 SUBSYSTEM=usb_endpoint
SEQNUM13
MAJORD2
MINOR=3
UDEVD_EVENT=1
DEVNAME=/dev/usbdev1.4_ep83

UDEV [1163683152.715971] add@/class/usb_device/usbdev1.4 UDEV_LOG=3
ACTION­d
DEVPATH=/class/usb_device/usbdev1.4 SUBSYSTEM=usb_device
SEQNUM14 PHYSDEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2 PHYSDEVBUS=usb
PHYSDEVDRIVER=usb
MAJOR9
MINOR=3
UDEVD_EVENT=1
DEVNAME=/dev/bus/usb/001/004

UEVENT[1163683157.940219] remove@/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep81 ACTION=remove DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep81 SUBSYSTEM=usb_endpoint
SEQNUM15
MAJORD2
MINOR=3

UEVENT[1163683157.940251] remove@/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep02 ACTION=remove DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep02 SUBSYSTEM=usb_endpoint
SEQNUM16
MAJORD2
MINOR=3

UEVENT[1163683157.940278] remove@/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep83 ACTION=remove DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep83 SUBSYSTEM=usb_endpoint
SEQNUM17
MAJORD2
MINOR=3

UEVENT[1163683157.940285] add@/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep81 ACTION­d DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep81 SUBSYSTEM=usb_endpoint
SEQNUM18
MAJORD2
MINOR=3

UEVENT[1163683157.940292] add@/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep02 ACTION­d DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep02 SUBSYSTEM=usb_endpoint
SEQNUM19
MAJORD2
MINOR=3

UEVENT[1163683157.940298] add@/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep83 ACTION­d DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep83 SUBSYSTEM=usb_endpoint
SEQNUM20
MAJORD2
MINOR=3

UDEV [1163683157.953460] remove@/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep81 UDEV_LOG=3
ACTION=remove DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep81 SUBSYSTEM=usb_endpoint
SEQNUM15
MAJORD2
MINOR=3
UDEVD_EVENT=1
DEVNAME=/dev/usbdev1.4_ep81

UDEV [1163683157.954286] remove@/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep02 UDEV_LOG=3
ACTION=remove DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep02 SUBSYSTEM=usb_endpoint
SEQNUM16
MAJORD2
MINOR=3
UDEVD_EVENT=1
DEVNAME=/dev/usbdev1.4_ep02

UDEV [1163683157.954900] remove@/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep83 UDEV_LOG=3
ACTION=remove DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep83 SUBSYSTEM=usb_endpoint
SEQNUM17
MAJORD2
MINOR=3
UDEVD_EVENT=1
DEVNAME=/dev/usbdev1.4_ep83

UDEV [1163683157.957305] add@/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep81 UDEV_LOG=3
ACTION­d DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep81 SUBSYSTEM=usb_endpoint
SEQNUM18
MAJORD2
MINOR=3
UDEVD_EVENT=1
DEVNAME=/dev/usbdev1.4_ep81

UDEV [1163683157.958620] add@/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep02 UDEV_LOG=3
ACTION­d DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep02 SUBSYSTEM=usb_endpoint
SEQNUM19
MAJORD2
MINOR=3
UDEVD_EVENT=1
DEVNAME=/dev/usbdev1.4_ep02

UDEV [1163683157.959884] add@/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep83 UDEV_LOG=3
ACTION­d DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0/usbdev1.4_ep83 SUBSYSTEM=usb_endpoint
SEQNUM20
MAJORD2
MINOR=3
UDEVD_EVENT=1
DEVNAME=/dev/usbdev1.4_ep83

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CIDÞVDEV
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#1 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 10 lines · Frederic Peters

Hello,

For a long time, since we totally switched from hotplug to udev, we have been unable in Debian to provide fallback support for unknown PTP cameras.

Hotplugging any known camera works perfectly but this require attentive maintenance of matching USB id and always lags behind constructors.

Quoted 7 lines

PTP camera devices define an interface which I thought could be matched by the following rule:

SYSFS{bInterfaceClass}="06", SYSFS{bInterfaceSubClass}="01", \
SYSFS{bInterfaceProtocol}="01", MODE="0660", GROUP="plugdev"

Unfortunately this doesn't work.

I do not have PTP camera to test, but both /dev/bus/usb/... nodes I can create here point to sysfs device *above* interface. Which effectively means, that when you rule matches, there is no device to create; and when device is created your rule does not match (because those attributes do not exist on this level)

Quoted 5 lines

Then Marcus Meissner from libgphoto2
suggested to use ENV{INTERFACE}="6/1/1" as matcher but I can't get it to work and Marco d'Itri (Debian udev maintainer) believe this not to be the correct solution anyway.

I guess it fails for the same reason.

Quoted 8 lines

Since Marco doesn't have much time for the moment he suggested I asked the question here, so here it is: what would be the rule to use to set mode/group on /dev/bus/usb/... device when detecting this device by bInterface{Class/SubClass/Protocol} ?

For the record, I copied below the output of udevmonitor --env when plugging in a camera.

[...]

Quoted 13 lines

UEVENT[1163683152.647503] add@/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0 ACTION­d DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2/1-2:1.0 SUBSYSTEM=usb
SEQNUM10
PHYSDEVBUS=usb
DEVICE=/proc/bus/usb/001/004
PRODUCTJ9/30fd/2
TYPE=0/0/0
INTERFACE=6/1/1 MODALIAS=usb:v04A9p30FDd0002dc00dsc00dp00ic06isc01ip01

This is your interface

[...]

Quoted 12 lines

UEVENT[1163683152.647657] add@/class/usb_device/usbdev1.4 ACTION­d
DEVPATH=/class/usb_device/usbdev1.4 SUBSYSTEM=usb_device
SEQNUM14 PHYSDEVPATH=/devices/pci0000:00/0000:00:1d.7/usb1/1-2 PHYSDEVBUS=usb
PHYSDEVDRIVER=usb
MAJOR9
MINOR=3

And here is where your /dev/bus/usb/... node is created.

Something like this /could/ work:

SYSFS{bInterfaceClass}="06", SYSFS{bInterfaceSubClass}="01", \
SYSFS{bInterfaceProtocol}="01", RUN+="sh -c 'echo ${DEVPATH%/*}

Quoted 1 line
Quoted 1 line

/tmp/perms'"

SUBSYSTEM=udb_device, PROGRAM="grep -q $DEVPATH /tmp/perms", GROUP="plugdev" -----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFFXKZ7R6LMutpd94wRAugNAJ9RQn2eyPEc3YIjQ1xyQ5JYdTW91wCfXxnw OJ92KHJAs8C7CGjKTy5n9yM=qm4c
-----END PGP SIGNATURE-----

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CIDÞVDEV
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel