Skip to contentSkip to conversation

libgphoto2 calls hotplug script with wrong variables

DISCUSSION Moshe Yudkowsky 2 participants 4 messages Dec 5, 2005 – Dec 6, 2005

lore
Share & tools
lore
#0 lore raw

I can fix this myself, but I'm curious to know if anyone else has fixed it, if it needs a bug report, or if something is very wrong with the way my system works.

My udev directory has a file called "libgphoto2.rules" -- I didn't put it there, but I don't know which package did (from the changelog, I suspect it was libgphoto2 package using a utility called "print-udev-rules").

In any case, when I plug in a USB camera, the file will use manufacturer and product code to find RUN+="/etc/hotplug/usb/libgphoto2".

Here's some problems:

(1a) I keep on reading on this list that /etc/hotplug is supposed to be deprecated, and yet here's /etc/hotplug that looks pretty official.

(1b) I also keep reading about HAL, but it isn't installed on my machine accoring to dpkg. Should it be? If it is supposed to be, why isn't in installed -- which script should have installed it?

(2) The script libgphoto2 doesn't work. The goal of libgphoto2 is to set the device created by hotplug (later udev) so that anyone in group $CAMERA can use it, but that doesn't happen, and here's why.

The script uses the environment variable $DEVICE. Now, that's interesting, because the udev man page doesn't mention this variable in the ENVIRONMENT section of the page at all, and it makes me wonder just what variables are available to anything I run as a RUN+= script. Not documented?

Problem:

The $DEVICE isn't equivalent to $DEVPATH. For example,

DEVICE is "/proc/bus/usb/002/010"
while
DEVPATH is "/devices/pci0000:00/0000:00:10.1/usb2/2-1/2-1:1.0".

Neither of these is any good when I want to configure the port that's been created; what I need is the USB bus device path so I can set group permissions. E.g., what I need is

/dev/bus/usb/002/010

No dobut I will find the correct magic combination, but if anyone has already solved this problem, please let me know.

Signature · 14 lines
  Moshe Yudkowsky
  work: http://www.Disaggregate.com
  book: http://www.PebbleAndAvalanche.com


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#1 lore raw
Quoted 4 lines · Moshe Yudkowsky

My udev directory has a file called "libgphoto2.rules" -- I didn't put it there, but I don't know which package did (from the changelog, I suspect it was libgphoto2 package using a utility called "print-udev-rules").

Right. So this is off topic for this mailing list.

Quoted 2 lines

(1a) I keep on reading on this list that /etc/hotplug is supposed to be deprecated, and yet here's /etc/hotplug that looks pretty official.

Blame the people who do not want to stop supporting old-style hotplug and 2.4 kernels in Debian. Anyway, this is not important.

Quoted 3 lines

(1b) I also keep reading about HAL, but it isn't installed on my machine accoring to dpkg. Should it be? If it is supposed to be, why isn't in installed -- which script should have installed it?

Because libgphoto does not actually use it.

Quoted 3 lines

(2) The script libgphoto2 doesn't work. The goal of libgphoto2 is to set the device created by hotplug (later udev) so that anyone in group $CAMERA can use it, but that doesn't happen, and here's why.

The script works fine, but updates the /prob/bus/usb/ file. You also need an udev rule to set GROUP for the SUBSYSTEM="usb_device" event which creates the /dev/bus/usb/ device.

Signature · 13 lines
ciao,
Marco


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#2 lore raw
In reply to Moshe Yudkowsky

Thanks to Marco for his replies. I have a couple of additional question, and a question that weren't answered.

Quoted 5 lines
Quoted 2 lines

(1a) I keep on reading on this list that /etc/hotplug is supposed to be deprecated, and yet here's /etc/hotplug that looks pretty official.

Blame the people who do not want to stop supporting old-style hotplug and 2.4 kernels in Debian. Anyway, this is not important.

/etc/hotplug was a convinient place to put scripts associated with hotplug events. Is there a "best practice" location for scripts (e.g., RUN scripts or PROGRAM scripts) when using udev?

Quoted 7 lines
Quoted 3 lines

(2) The script libgphoto2 doesn't work. The goal of libgphoto2 is to set the device created by hotplug (later udev) so that anyone in group $CAMERA can use it, but that doesn't happen, and here's why.

The script works fine, but updates the /prob/bus/usb/ file. You also need an udev rule to set GROUP for the SUBSYSTEM="usb_device" event which creates the /dev/bus/usb/ device.

Well, yes, the script modifies /proc -- which is the wrong file. I should have been more precise.

Thanks for the tip on SUBSYTEM -- I was not aware that this was the entity that created the /dev/bus/usb device. That makes it very easy to create the correct permissions using group with no need for a script.

For the sake of clarity, I always like to include the complete text of the fix if possible, so here it is. The solution is to modify the "libgphoto2.rules" file. For the Canon S110, to pick an example, the entry should read:

SUBSYSTEM="usb_device", SYSFS{idVendor}="04a9",
SYSFS{idProduct}="3051", GROUP="camera"

Note that there's no need for any RUN script to set the group.

Here's the unanswered question and a new question:

* Is there a current list of what's available to the environment of scripts? I see that libgphoto2 used $DEVICE, and $DEVICE doesn't seem to be mentioned on the udev man page as being in the environment spawned by RUN.

* Where can I find, other than by asking on this list or reading through the code, information about how other subsystems work with udev and what they do? /dev/hotplug.log, for example, contains a lot of nice info, and I see that one stanza has the information:

Quoted 6 lines

HOTPLUG_TIME='Mon Dec 5 17:36:47 CST 2005' PHYSDEVPATH=/devices/pci0000:00/0000:00:10.1/usb2/2-1 SUBSYSTEM=usb_device
OLDPWD=/
DEVPATH=/class/usb_device/usbdev2.20
MINOR7

Quoted 8 lines

ACTION=remove
UDEV_LOG=7
MAJOR9
UDEVD_EVENT=1
DEVNAME=/dev/bus/usb/002/020
PHYSDEVDRIVER=usb
PHYSDEVBUS=usb
SEQNUM33

Is this the best way to find out which SUBSYSTEM to look for -- by finding the SUBSYSTEM stanza that has the DEVNAME attached to it? Yes, I realize if I were a guru I'd know this stuff, but it's sure not obvious to me. Yet.

Regards,
Moshe

Signature · 14 lines
  Moshe Yudkowsky
  work: http://www.Disaggregate.com
  book: http://www.PebbleAndAvalanche.com


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#3 lore raw
In reply to Moshe Yudkowsky
Quoted 3 lines · Moshe Yudkowsky

/etc/hotplug was a convinient place to put scripts associated with hotplug events. Is there a "best practice" location for scripts (e.g., RUN scripts or PROGRAM scripts) when using udev?

/lib/udev/.

Quoted 2 lines

* Is there a current list of what's available to the environment of scripts? I see that libgphoto2 used $DEVICE, and $DEVICE doesn't seem to

There is something on linux-hotplug.sourceforge.net, but it's incomplete and half-wrong.

Signature · 13 lines
ciao,
Marco


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_idv37&alloc_id865&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel