Skip to contentSkip to conversation

general hotplug/udev questions

DISCUSSION rich turner 5 participants 15 messages Aug 18, 2005 – Aug 24, 2005

lore
Share & tools
lore
#0 lore raw

i am looking at the way suse 9.3 is using hotplug and udev to load network device modules, and want to know if this is specific to suse or if hotplug/udev is using this method and will be used by other distributions going forward.

keep in mind that i am not using the initrd (which is initramfs) that suse distributes, or their mkinitrd to create it. i have a process that creates an initrd (old-school, not initramfs), which works on any distribution (2.4 and 2.6 kernels).

my problem is that my network modules are not being loaded when the system boots. on all previous distibutions it was a matter of adding the network devices as an alias in /etc/modprobe.conf and then the network startup scripts would handle loading the module when the device was brought up:
alias eth0 sis900

what i am seeing on suse 9.3 is that in their initrd (initramfs) they are using klibc and are echoing /sbin/hotplug.sh
to /proc/sys/kernel/hotplug. this is the contents of /sbin/hotplug.sh:

#!/bin/sh
#

# /sbin/hotplug.sh
# $Id: hotplug.sh,v 1.1 2005/01/20 10:38:11 hare Exp $
#
# Simple hotplug script for initramfs
# Records all events if requested and starts up udev
#
# Records all events if requested
if [ -d /events -a -x /sbin/hotplugeventrecorder ] ; then
    /sbin/hotplugeventrecorder $1 2>/dev/null
fi
AGENT=/sbin/udev
if [ -x $AGENT ]; then
    exec $AGENT $@
    echo "couldn't exec $AGENT"
fi
exit 1

they will then copy all entries that are created in /events to /lib/klibc/events and mount it up using tmpfs so they can access them when exiting the initrd.

then within their boot.coldplug init script, they take those events and load the modules.

because my linuxrc does not create events or mount /lib/klibc/events in the initrd, then boot.coldplug does not load the network modules.

i realize i can load the network modules in the initrd and everything would be golden, but that is not the purpose of the initrd. in my opinion we already do to much in the initrd because the distributions dont do enough (or do it correctly) in their init scripts. we try to keep the initrd's purpose to do only enough to mount the root filesystem.

it is important that our process remain generic across all distributions because we need to support many other distributions.

does anyone have an opinion as to whether suse's current method will become the standard?

it appears that udevstart.static creates events but /sbin/udevstart does not. why is that?

is /sbin/hotplugevenrecorder an executable being distributed by suse or is it something that will be coming in the maintained udev?

even though we use udevstart in the initrd, is there any real purpose to echoing something (/sbin/udev, /sbin/udevsend, /bin/true) out to /proc/sys/kernel/hotplug while in the initrd?

it is my experience that udev only handles devices that you would expect to find in /dev. how could it have any effect on network interfaces? is this a product of hotplug or udev?

i apologize for the long message, but i do appreciate any feedback.

rich turner

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
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 2 lines · rich turner

because my linuxrc does not create events or mount /lib/klibc/events in the initrd, then boot.coldplug does not load the network modules.

That is correct.

Quoted 6 lines

i realize i can load the network modules in the initrd and everything would be golden, but that is not the purpose of the initrd. in my opinion we already do to much in the initrd because the distributions dont do enough (or do it correctly) in their init scripts. we try to keep the initrd's purpose to do only enough to mount the root filesystem.

Sorry, but that's not the way we are all moving toward. With initramfs and kinit we are pushing more and more of the early boot stuff into a initramfs/initrd image to get it out of the kernel itself.

Quoted 2 lines

it is important that our process remain generic across all distributions because we need to support many other distributions.

I wish you the best of luck. Providing custom kernel images for different distros, while ignoring how they do their initrd/initramfs boot sequence seems like a futile way to go. Not to mention breaking your customer's service contracts with their distro :)

Quoted 2 lines

does anyone have an opinion as to whether suse's current method will become the standard?

Is there ever a "standard" for Linux? :)

Seriously, I think something like this will become more common as it solves a lot of problems people have with early boot processes. Look at how Red Hat solves it (in a different way, but with the same results.)

Quoted 5 lines

it appears that udevstart.static creates events but /sbin/udevstart does not. why is that?

is /sbin/hotplugevenrecorder an executable being distributed by suse or is it something that will be coming in the maintained udev?

http://www.kernel.org/git/?p=linux/hotplug/udev.git;a=blob;hš3c3e197c6cf3972c0f9d910ac206aed3df66e7;hbŒ11a2f0ff27264513033691bb818262f009fe4e;f=udeveventrecorder.c
look like what you are looking for?

Quoted 3 lines

even though we use udevstart in the initrd, is there any real purpose to echoing something (/sbin/udev, /sbin/udevsend, /bin/true) out to /proc/sys/kernel/hotplug while in the initrd?

Depends on how you want to catch hotplug events.

Note, a lot of this has changed recently in suse's kernel. Take a look at opensuse beta 2 for examples of this.

Quoted 3 lines

it is my experience that udev only handles devices that you would expect to find in /dev. how could it have any effect on network interfaces? is this a product of hotplug or udev?

Both. udev can handle network devices just fine, has for years.

thanks,

greg k-h

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
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 rich turner
Quoted 5 lines · Greg KH
Quoted 2 lines · rich turner

because my linuxrc does not create events or mount /lib/klibc/events in the initrd, then boot.coldplug does not load the network modules.

That is correct.

If the bootup sequence does not find the directory with the events to replay, it should fall back to the traditional "coldplug" with scanning the buses and loading modules. Maybe that's not working in your setup.

Quoted 11 lines
Quoted 6 lines

i realize i can load the network modules in the initrd and everything would be golden, but that is not the purpose of the initrd. in my opinion we already do to much in the initrd because the distributions dont do enough (or do it correctly) in their init scripts. we try to keep the initrd's purpose to do only enough to mount the root filesystem.

Sorry, but that's not the way we are all moving toward. With initramfs and kinit we are pushing more and more of the early boot stuff into a initramfs/initrd image to get it out of the kernel itself.

Quoted 7 lines
Quoted 2 lines

it is important that our process remain generic across all distributions because we need to support many other distributions.

I wish you the best of luck. Providing custom kernel images for different distros, while ignoring how they do their initrd/initramfs boot sequence seems like a futile way to go. Not to mention breaking your customer's service contracts with their distro :)

My best wishes too. All the arch's SUSE supports is strange enough. And looking at the distro's udev packages gives me the impression, that this will be a tough road for you. :)

Quoted 8 lines
Quoted 2 lines

does anyone have an opinion as to whether suse's current method will become the standard?

Is there ever a "standard" for Linux? :)

Seriously, I think something like this will become more common as it solves a lot of problems people have with early boot processes. Look at how Red Hat solves it (in a different way, but with the same results.)

SUSE's current "event replay from initramfs" works nice so far and is a generic way to solve the boot sequencing problems. One other option may be to crawl /sys and submit the events to udevd instead of getting it from initramfs. That would also work with every kernel, not only with a special prepared initramfs. We will need to test if this option works "good enough" - for now it only sounds like a nice alternative.

Quoted 2 lines
Quoted 2 lines

it appears that udevstart.static creates events but /sbin/udevstart does not. why is that?

There should be no difference. The openSUSE package has only one single patch to keep the udev rules in the udev daemon instead of parsing the rules with every event. This patch is available on the hotplug list.

Quoted 5 lines
Quoted 2 lines

is /sbin/hotplugevenrecorder an executable being distributed by suse or is it something that will be coming in the maintained udev?

http://www.kernel.org/git/?p=linux/hotplug/udev.git;a=blob;hš3c3e197c6cf3972c0f9d910ac206aed3df66e7;hbŒ11a2f0ff27264513033691bb818262f009fe4e;f=udeveventrecorder.c
look like what you are looking for?

We put for now everything SUSE uses in the upstream udev package. There is no documentation besides our package. If we find a better way to do it (smarter coldplug), we may replace this.

Quoted 5 lines
Quoted 3 lines

even though we use udevstart in the initrd, is there any real purpose to echoing something (/sbin/udev, /sbin/udevsend, /bin/true) out to /proc/sys/kernel/hotplug while in the initrd?

Depends on how you want to catch hotplug events.

Yeah, at least /bin/true does not make any sense. :)

Quoted 5 lines
Quoted 3 lines

it is my experience that udev only handles devices that you would expect to find in /dev. how could it have any effect on network interfaces? is this a product of hotplug or udev?

Both. udev can handle network devices just fine, has for years.

Yes, udev can rename network interfaces with the same rule logic, it can name a device node.

Kay

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
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 rich turner
Quoted 9 lines · Kay Sievers

SUSE's current "event replay from initramfs" works nice so far and is a generic way to solve the boot sequencing problems. One other option may be to crawl /sys and submit the events to udevd instead of getting it from initramfs. That would also work with every kernel, not only with a special prepared initramfs. We will need to test if this option works "good enough" - for now it only sounds like a nice alternative.

Do I understand correctly that the "crawl through sysfs" approach means bus-specific conversion between sysfs contents (e.g the fact that /sys/bus/usb/devices/1-1/idProduct contains "4002" here) and environment variables (in this case, PRODUCT=...)? I.e., is it just a reimplementation of old /etc/hotplug/*.rc scripts in C?

Signature · 12 lines
Alexander E. Patrakov


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#4 lore raw
In reply to rich turner
Quoted 5 lines · Alexander E. Patrakov

Do I understand correctly that the "crawl through sysfs" approach means bus-specific conversion between sysfs contents (e.g the fact that /sys/bus/usb/devices/1-1/idProduct contains "4002" here) and environment variables (in this case, PRODUCT=...)? I.e., is it just a reimplementation of old /etc/hotplug/*.rc scripts in C?

Yes. Actually I am testing this right now in shell (it's not obvious that they need to be converted in C).

Signature · 13 lines
ciao,
Marco


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#5 lore raw
In reply to rich turner
Quoted 11 lines · Alexander E. Patrakov
Quoted 9 lines · Kay Sievers

SUSE's current "event replay from initramfs" works nice so far and is a generic way to solve the boot sequencing problems. One other option may be to crawl /sys and submit the events to udevd instead of getting it from initramfs. That would also work with every kernel, not only with a special prepared initramfs. We will need to test if this option works "good enough" - for now it only sounds like a nice alternative.

Quoted 4 lines

Do I understand correctly that the "crawl through sysfs" approach means bus-specific conversion between sysfs contents (e.g the fact that /sys/bus/usb/devices/1-1/idProduct contains "4002" here) and environment variables (in this case, PRODUCT=...)?

Yes, but it's a world easier now that we have added the 'modalias' sysfs files so we don't have to reconstruct anything. All we care about at coldplug time is loading the modules and creating existing device nodes.

The hotplug events can usually be safely ignored.

Although some people don't feel the same way, so they "plug" the hotplug events and then replay them, which is probably the more correct thing to do.

Quoted 2 lines

I.e., is it just a reimplementation of old /etc/hotplug/*.rc scripts in C?

no.

thanks,

greg k-h

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#6 lore raw
In reply to rich turner
Quoted 10 lines · Greg KH
Quoted 6 lines · Alexander E. Patrakov

Do I understand correctly that the "crawl through sysfs" approach means bus-specific conversion between sysfs contents (e.g the fact that /sys/bus/usb/devices/1-1/idProduct contains "4002" here) and environment variables (in this case, PRODUCT=...)?

Quoted 5 lines

Yes, but it's a world easier now that we have added the 'modalias' sysfs files so we don't have to reconstruct anything. All we care about at coldplug time is loading the modules and creating existing device nodes.

Sorry, no. We should also care about providing some hook for packages like SANE and gPhoto2 to chown/chmod pseudofiles in /proc/bus/usb. This requires perfect reconstruction of at least $PRODUCT and $DEVICE.

Signature · 12 lines
Alexander E. Patrakov


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#7 lore raw
In reply to rich turner
Quoted 12 lines · Alexander E. Patrakov
Quoted 10 lines · Greg KH
Quoted 6 lines · Alexander E. Patrakov

Do I understand correctly that the "crawl through sysfs" approach means bus-specific conversion between sysfs contents (e.g the fact that /sys/bus/usb/devices/1-1/idProduct contains "4002" here) and environment variables (in this case, PRODUCT=...)?

Quoted 8 lines
Quoted 5 lines

Yes, but it's a world easier now that we have added the 'modalias' sysfs files so we don't have to reconstruct anything. All we care about at coldplug time is loading the modules and creating existing device nodes.

Sorry, no. We should also care about providing some hook for packages like SANE and gPhoto2 to chown/chmod pseudofiles in /proc/bus/usb. This requires perfect reconstruction of at least $PRODUCT and $DEVICE.

usbfs can go to nowhere. :)
We will get real nodes for libusb access managed by udev with kernel 2.6.14:

kay@pim:~> tree /sys/class/usb_device/
/sys/class/usb_device/

  |-- usbdev1.1
  |   |-- dev
  |   `-- device -> ../../../devices/pci0000:00/0000:00:1d.0/usb1
  |-- usbdev1.2
  |   |-- dev
  |   `-- device -> ../../../devices/pci0000:00/0000:00:1d.0/usb1/1-1
  |-- usbdev2.1
  |   |-- dev
  |   `-- device -> ../../../devices/pci0000:00/0000:00:1d.1/usb2
  |-- usbdev2.2
  |    |-- dev
  |   `-- device -> ../../../devices/pci0000:00/0000:00:1d.1/usb2/2-2
  | -- usbdev3.1
  |   |-- dev
  |   `-- device -> ../../../devices/pci0000:00/0000:00:1d.2/usb3
  |-- usbdev4.1
  |   |-- dev
  |   `-- device -> ../../../devices/pci0000:00/0000:00:1d.7/usb4
  `-- usbdev4.5
      |-- dev
      `-- device -> ../../../devices/pci0000:00/0000:00:1d.7/usb4/4-3

Kay

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#8 lore raw
In reply to rich turner
Quoted 3 lines · Greg KH

Yes, but it's a world easier now that we have added the 'modalias' sysfs files so we don't have to reconstruct anything. All we care about at coldplug time is loading the modules and creating existing device nodes.

I'm not sure. You can never know which parameters are used by user space drivers and similar scripts. So I'm taking the safe route of generating events which are as similar as possible to the real ones (for most bus types it's very easy).

Signature · 2 lines
ciao,
Marco
#9 lore raw
In reply to rich turner
Quoted 12 lines · Alexander E. Patrakov
Quoted 10 lines · Greg KH
Quoted 6 lines · Alexander E. Patrakov

Do I understand correctly that the "crawl through sysfs" approach means bus-specific conversion between sysfs contents (e.g the fact that /sys/bus/usb/devices/1-1/idProduct contains "4002" here) and environment variables (in this case, PRODUCT=...)?

Quoted 8 lines
Quoted 5 lines

Yes, but it's a world easier now that we have added the 'modalias' sysfs files so we don't have to reconstruct anything. All we care about at coldplug time is loading the modules and creating existing device nodes.

Sorry, no. We should also care about providing some hook for packages like SANE and gPhoto2 to chown/chmod pseudofiles in /proc/bus/usb. This requires perfect reconstruction of at least $PRODUCT and $DEVICE.

Like Kay said, /proc/bus/usb/???/ is now dead. We have sane device nodes for those usbfs files now that udev can manipulate the permissions for properly. Run the latest -mm trees to see this.

Kay, you have a libusb patch to support this, right? Care to share it?

thanks,

greg k-h

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#10 lore raw
In reply to rich turner
Quoted 22 lines · Greg KH
Quoted 12 lines · Alexander E. Patrakov
Quoted 10 lines · Greg KH
Quoted 6 lines · Alexander E. Patrakov

Do I understand correctly that the "crawl through sysfs" approach means bus-specific conversion between sysfs contents (e.g the fact that /sys/bus/usb/devices/1-1/idProduct contains "4002" here) and environment variables (in this case, PRODUCT=...)?

Quoted 8 lines
Quoted 5 lines

Yes, but it's a world easier now that we have added the 'modalias' sysfs files so we don't have to reconstruct anything. All we care about at coldplug time is loading the modules and creating existing device nodes.

Sorry, no. We should also care about providing some hook for packages like SANE and gPhoto2 to chown/chmod pseudofiles in /proc/bus/usb. This requires perfect reconstruction of at least $PRODUCT and $DEVICE.

Quoted 5 lines

Like Kay said, /proc/bus/usb/???/ is now dead. We have sane device nodes for those usbfs files now that udev can manipulate the permissions for properly. Run the latest -mm trees to see this.

Kay, you have a libusb patch to support this, right? Care to share it?

It requires this crazy udev rule:
SUBSYSTEM="usb_device", PROGRAM="/bin/sh -c 'X=%k X=$${X#usbdev} B=$${X%%%%.*} D=$${X#*.}; echo bus/usb/$$B/$$D'", SYMLINK+="%c"

and this patch to libusb, that falls back to the real nodes if usbfs is not mounted.

###
Patch against libusb, to prepare for the upcoming changes in
the Linux usb core, which will create real device nodes in /dev
with udev. The following rule:
SUBSYSTEM="usb_device", PROGRAM="/bin/sh -c 'X=%k X=$${X#usbdev} B=$${X%%%%.*} D=$${X#*.}; echo bus/usb/$$B/$$D'", SYMLINK="%c"

creates a similar structure in /dev as usbfs creates in /proc to be picked up by libusb.

I've removed the fallback to /sys/bus/usb cause this is completely wrong and can and will never work and /dev/usb is used differently and will also not provide access to the raw usb devices.

---

linux.c +2 -5
diff -u -r1.73 linux.c
@@ -636,11 +636,8 @@
     if (check_usb_vfs("/proc/bus/usb")) {
       strncpy(usb_path, "/proc/bus/usb", sizeof(usb_path) - 1);
       usb_path[sizeof(usb_path) - 1] = 0;
-    } else if (check_usb_vfs("/sys/bus/usb")) { /* 2.6 Kernel with sysfs */
-      strncpy(usb_path, "/sys/bus/usb", sizeof(usb_path) -1);
-      usb_path[sizeof(usb_path) - 1] = 0;
-    } else if (check_usb_vfs("/dev/usb")) {
-      strncpy(usb_path, "/dev/usb", sizeof(usb_path) - 1);
+    } else if (check_usb_vfs("/dev/bus/usb")) {
+      strncpy(usb_path, "/dev/bus/usb", sizeof(usb_path) -1);
       usb_path[sizeof(usb_path) - 1] = 0;
     } else
       usb_path[0] = 0;	/* No path, no USB support */

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#11 lore raw
In reply to rich turner
Quoted 23 lines · Kay Sievers
Quoted 22 lines · Greg KH
Quoted 20 lines · Alexander E. Patrakov
Quoted 10 lines · Greg KH
Quoted 6 lines · Alexander E. Patrakov

Do I understand correctly that the "crawl through sysfs" approach means bus-specific conversion between sysfs contents (e.g the fact that /sys/bus/usb/devices/1-1/idProduct contains "4002" here) and environment variables (in this case, PRODUCT=...)?

Quoted 5 lines

Yes, but it's a world easier now that we have added the 'modalias' sysfs files so we don't have to reconstruct anything. All we care about at coldplug time is loading the modules and creating existing device nodes.

Sorry, no. We should also care about providing some hook for packages like SANE and gPhoto2 to chown/chmod pseudofiles in /proc/bus/usb. This requires perfect reconstruction of at least $PRODUCT and $DEVICE.

Quoted 8 lines
Quoted 5 lines

Like Kay said, /proc/bus/usb/???/ is now dead. We have sane device nodes for those usbfs files now that udev can manipulate the permissions for properly. Run the latest -mm trees to see this.

Kay, you have a libusb patch to support this, right? Care to share it?

It requires this crazy udev rule:
SUBSYSTEM="usb_device", PROGRAM="/bin/sh -c 'X=%k X=$${X#usbdev} B=$${X%%%%.*} D=$${X#*.}; echo bus/usb/$$B/$$D'", SYMLINK+="%c"

Ugh. Is there any way we can change the kernel name of the class device to make this easier to handle? Hm, probably not, unless I get subclass devices working real soon...

And do we need/want to care about the leading 0's like usbfs had?

Quoted 23 lines

###
Patch against libusb, to prepare for the upcoming changes in
the Linux usb core, which will create real device nodes in /dev
with udev. The following rule:
SUBSYSTEM="usb_device", PROGRAM="/bin/sh -c 'X=%k X=$${X#usbdev} B=$${X%%%%.*} D=$${X#*.}; echo bus/usb/$$B/$$D'", SYMLINK="%c"

creates a similar structure in /dev as usbfs creates in /proc to be picked up by libusb.

I've removed the fallback to /sys/bus/usb cause this is completely wrong and can and will never work and /dev/usb is used differently and will also not provide access to the raw usb devices.

---

diff -u -r1.73 linux.c

linux.c +0 -0
@@ -636,11 +636,8 @@
     if (check_usb_vfs("/proc/bus/usb")) {
       strncpy(usb_path, "/proc/bus/usb", sizeof(usb_path) - 1);
       usb_path[sizeof(usb_path) - 1] = 0;

linux.c line 643

Quoted 10 lines
linux.c +2 -5
-    } else if (check_usb_vfs("/sys/bus/usb")) { /* 2.6 Kernel with sysfs */
-      strncpy(usb_path, "/sys/bus/usb", sizeof(usb_path) -1);
-      usb_path[sizeof(usb_path) - 1] = 0;
-    } else if (check_usb_vfs("/dev/usb")) {
-      strncpy(usb_path, "/dev/usb", sizeof(usb_path) - 1);
+    } else if (check_usb_vfs("/dev/bus/usb")) {
+      strncpy(usb_path, "/dev/bus/usb", sizeof(usb_path) -1);
       usb_path[sizeof(usb_path) - 1] = 0;
     } else
       usb_path[0] = 0;	/* No path, no USB support */

Hm, why was libusb checking for sysfs stuff in the first place? It couldn't do anything with those files, right?

thanks,

greg k-h

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#12 lore raw
In reply to rich turner
Quoted 28 lines · Greg KH
Quoted 27 lines · Kay Sievers
Quoted 26 lines · Greg KH
Quoted 12 lines · Alexander E. Patrakov
Quoted 10 lines · Greg KH
Quoted 6 lines · Alexander E. Patrakov

Do I understand correctly that the "crawl through sysfs" approach means bus-specific conversion between sysfs contents (e.g the fact that /sys/bus/usb/devices/1-1/idProduct contains "4002" here) and environment variables (in this case, PRODUCT=...)?

Quoted 8 lines
Quoted 5 lines

Yes, but it's a world easier now that we have added the 'modalias' sysfs files so we don't have to reconstruct anything. All we care about at coldplug time is loading the modules and creating existing device nodes.

Sorry, no. We should also care about providing some hook for packages like SANE and gPhoto2 to chown/chmod pseudofiles in /proc/bus/usb. This requires perfect reconstruction of at least $PRODUCT and $DEVICE.

Like Kay said, /proc/bus/usb/???/ is now dead. We have sane device nodes for those usbfs files now that udev can manipulate the permissions for properly. Run the latest -mm trees to see this.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Kay, you have a libusb patch to support this, right? Care to share it?

It requires this crazy udev rule:
SUBSYSTEM="usb_device", PROGRAM="/bin/sh -c 'X=%k X=$${X#usbdev} B=$${X%%%%.*} D=$${X#*.}; echo bus/usb/$$B/$$D'", SYMLINK+="%c"

Ugh. Is there any way we can change the kernel name of the class device to make this easier to handle? Hm, probably not, unless I get subclass devices working real soon...

Not that I know. We could add regex support to udev to solve that in-process. :)

Quoted 1 line

And do we need/want to care about the leading 0's like usbfs had?

Works fine without, but adding it with the shell should be easy, just makes the rule a bit longer. :)

Quoted 29 lines
Quoted 29 lines

###
Patch against libusb, to prepare for the upcoming changes in
the Linux usb core, which will create real device nodes in /dev
with udev. The following rule:
SUBSYSTEM="usb_device", PROGRAM="/bin/sh -c 'X=%k X=$${X#usbdev} B=$${X%%%%.*} D=$${X#*.}; echo bus/usb/$$B/$$D'", SYMLINK="%c"

creates a similar structure in /dev as usbfs creates in /proc to be picked up by libusb.

I've removed the fallback to /sys/bus/usb cause this is completely wrong and can and will never work and /dev/usb is used differently and will also not provide access to the raw usb devices.

---

diff -u -r1.73 linux.c

linux.c +1 -5
@@ -636,11 +636,8 @@
     if (check_usb_vfs("/proc/bus/usb")) {
       strncpy(usb_path, "/proc/bus/usb", sizeof(usb_path) - 1);
       usb_path[sizeof(usb_path) - 1] = 0;
-    } else if (check_usb_vfs("/sys/bus/usb")) { /* 2.6 Kernel with sysfs */
-      strncpy(usb_path, "/sys/bus/usb", sizeof(usb_path) -1);
-      usb_path[sizeof(usb_path) - 1] = 0;
-    } else if (check_usb_vfs("/dev/usb")) {
-      strncpy(usb_path, "/dev/usb", sizeof(usb_path) - 1);
+    } else if (check_usb_vfs("/dev/bus/usb")) {
Quoted 8 lines

linux.c line 643

Quoted 4 lines
linux.c +1 -0
+      strncpy(usb_path, "/dev/bus/usb", sizeof(usb_path) -1);
       usb_path[sizeof(usb_path) - 1] = 0;
     } else
       usb_path[0] = 0;	/* No path, no USB support */

Hm, why was libusb checking for sysfs stuff in the first place? It couldn't do anything with those files, right?

No, it doesn't make sense. Seems someone was a bit confused about sysfs and thought /proc/bus will move to /sys/bus :)

Kay

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#13 lore raw
In reply to rich turner
Quoted 11 lines · Kay Sievers
Quoted 7 lines · Greg KH

Like Kay said, /proc/bus/usb/???/ is now dead. We have sane device nodes for those usbfs files now that udev can manipulate the permissions for properly. Run the latest -mm trees to see this.

Kay, you have a libusb patch to support this, right? Care to share it?

Quoted 7 lines

It requires this crazy udev rule:
SUBSYSTEM="usb_device", PROGRAM="/bin/sh -c 'X=%k X=$${X#usbdev} B=$${X%%%%.*} D=$${X#*.}; echo bus/usb/$$B/$$D'", SYMLINK+="%c"

and this patch to libusb, that falls back to the real nodes if usbfs is not mounted.

<snip patch>

With this patch, I was able to scan some images without mounting usbfs (linux-2.6.13-rc6-mm1). Thanks!

Signature · 12 lines
Alexander E. Patrakov


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#14 lore raw
In reply to rich turner
Quoted 15 lines · Alexander E. Patrakov
Quoted 14 lines · Kay Sievers
Quoted 7 lines · Greg KH

Like Kay said, /proc/bus/usb/???/ is now dead. We have sane device nodes for
those usbfs files now that udev can manipulate the permissions for properly. Run the latest -mm trees to see this.

Kay, you have a libusb patch to support this, right? Care to share it?

It requires this crazy udev rule:
SUBSYSTEM="usb_device", PROGRAM="/bin/sh -c 'X=%k X=$${X#usbdev} B=$${X%%%%.*} D=$${X#*.}; echo bus/usb/$$B/$$D'", SYMLINK+="%c"

Quoted 5 lines
Quoted 2 lines

and this patch to libusb, that falls back to the real nodes if usbfs is not mounted.

With this patch, I was able to scan some images without mounting usbfs (linux-2.6.13-rc6-mm1). Thanks!

Nice! Many thanks for testing it.

Kay

-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel