udev LABEL not working: sysfs_path_is_file: stat() failed
[I am not subscribed to linux-kernel, please Cc: me on replies.]
I'm having a problem getting udev to honour my LABEL lines in /etc/udev/udev.rules. At the top of this I've got:
LABEL, BUS="usb", SYSFS_vendor="Fujifilm", SYSFS_model="FinePix 1400Zoom", NAME="camera"
Which as far as I understand it should create a /dev/camera when I plug in my USB camera... Except all I ever get is /dev/sdb and /dev/sdb1, no matter what combinations of SYSFS_* I try.
The most relevant lines I could find look like this:
Dec 22 00:47:17 descent udev[4383]: do_label: look for device attribute 'model' Dec 22 00:47:17 descent udev[4383]: sysfs_path_is_file: stat() failed
However if I manually look at /sys/block/sdb/device it's all there:
descent scott% cd /sys/block/sdb/device
descent device% ls
block@ detach_state model power/ rescan scsi_level vendor delete device_blocked online queue_depth rev type
descent device% cat vendor
Fujifilm
descent device% cat model
FinePix 1400Zoom
I'm using udev-009 and hotplug-0.0.20031013-2 on a Debian machine running Linux 2.6.0. I've attached a copy of my udev.conf, udev.rules and the log output from both the kernel when attaching the device and udev when compiled with DEBUG on.
Scott
Signature · 2 lines
Have you ever, ever felt like this? Had strange things happen? Are you going round the twist?
# udev.conf # The main config file for udev # # This file can be used to override some of udev's default values # for where it looks for files, and where it places device nodes.
# udev_root - where in the filesystem to place the device nodes udev_root="/udev/"
# udev_db - The name and location of the udev database. udev_db="/udev/.udev.tdb"
# udev_rules - The name and location of the udev rules file udev_rules="/etc/udev/udev.rules"
# udev_permissions - The name and location of the udev permission file udev_permissions="/etc/udev/udev.permissions"
# default_mode - set the default mode for all nodes that have no # explicit match in the permissions file default_mode="0600"
# There are a number of modifiers that are allowed to be used in
# a number of the different fields. They provide the following subsitutions: # %n - the "kernel number" of the device. # for example, 'sda3' has a "kernel number" of '3' # %M - the kernel major number for the device # %m - the kernel minor number for the device # %b - the bus id for the device # %c - the return value for the CALLOUT program (note, this doesn't work within # the PROGRAM field for the obvious reason.) # %D - use the devfs style disk name for this device. # For partitions, this will result in 'part%n' # If this is not a partition, it will result in 'disk' #
# My camera
LABEL, BUS="usb", SYSFS_vendor="Fujifilm", SYSFS_model="FinePix 1400Zoom", NAME="camera"
# ide block devices NUMBER, BUS="ide", ID="0.0", NAME="ide/host0/bus0/target0/lun0/%D", SYMLINK="hda%n" NUMBER, BUS="ide", ID="0.1", NAME="ide/host0/bus0/target1/lun0/%D", SYMLINK="hdb%n" NUMBER, BUS="ide", ID="1.0", NAME="ide/host0/bus1/target0/lun0/%D", SYMLINK="hdc%n" NUMBER, BUS="ide", ID="1.1", NAME="ide/host0/bus1/target1/lun0/%D", SYMLINK="hdd%n"
# md block devices REPLACE, KERNEL="md[0-9]*", NAME="md/%n", SYMLINK="md%n"
# tty devices REPLACE, KERNEL="tty[0-9]*", NAME="vc/%n" REPLACE, KERNEL="ttyS[0-9]*", NAME="tts/%n" REPLACE, KERNEL="ttyUSB[0-9]*", NAME="tts/USB%n"
# vc devices REPLACE, KERNEL="vcs", NAME="vcc/0" REPLACE, KERNEL="vcs[0-9]*", NAME="vcc/%n" REPLACE, KERNEL="vcsa", NAME="vcc/a0" REPLACE, KERNEL="vcsa[0-9]*", NAME="vcc/a%n"
# v4l devices REPLACE, KERNEL="video[0-9]*", NAME="v4l/video%n" REPLACE, KERNEL="radio[0-9]*", NAME="v4l/radio%n" REPLACE, KERNEL="vbi[0-9]*", NAME="v4l/vbi%n" REPLACE, KERNEL="vtx[0-9]*", NAME="v4l/vtx%n"
Dec 22 00:47:17 descent kernel: hub 1-2:1.0: new USB device on port 3, assigned address 17 Dec 22 00:47:17 descent usb.agent[4341]: ... no modules for USB product 4cb/100/1000 Dec 22 00:47:17 descent kernel: scsi12 : SCSI emulation for USB Mass Storage devices Dec 22 00:47:17 descent kernel: Vendor: Fujifilm Model: FinePix 1400Zoom Rev: 1000 Dec 22 00:47:17 descent kernel: Type: Direct-Access ANSI SCSI revision: 02 Dec 22 00:47:17 descent scsi.agent[4368]: how to add device type= at /devices/pci0000:00/0000:00:02.2/usb1/1-2/1-2.3/1-2.3:1.0/host12/12:0:0:0 ?? Dec 22 00:47:17 descent kernel: SCSI device sdb: 128000 512-byte hdwr sectors (66 MB) Dec 22 00:47:17 descent kernel: sdb: Write Protect is off Dec 22 00:47:17 descent kernel: sdb: sdb1 Dec 22 00:47:17 descent kernel: Attached scsi removable disk sdb at scsi12, channel 0, id 0, lun 0 Dec 22 00:47:17 descent kernel: Attached scsi generic sg1 at scsi12, channel 0, id 0, lun 0, type 0 Dec 22 00:47:17 descent udev[4358]: main: version 009 Dec 22 00:47:17 descent udev[4358]: main: looking at '/devices/pci0000:00/0000:00:02.2/usb1/1-2/1-2.3/1-2.3:1.0' Dec 22 00:47:17 descent udev[4358]: main: not a block or class device Dec 22 00:47:17 descent udev[4366]: main: version 009 Dec 22 00:47:17 descent udev[4366]: main: looking at '/class/scsi_host/host12' Dec 22 00:47:17 descent udev[4366]: get_dirs: sysfs_path='/sys' Dec 22 00:47:17 descent udev[4366]: parse_config_file: reading '/etc/udev/udev.conf' as config file Dec 22 00:47:17 descent udev[4366]: namedev_init_rules: reading '/etc/udev/udev.rules' as rules file Dec 22 00:47:17 descent udev[4366]: namedev_init_permissions: reading '/etc/udev/udev.permissions' as permissions file Dec 22 00:47:17 descent udev[4366]: sleep_for_dev: looking for '/sys/class/scsi_host/host12/dev' Dec 22 00:47:17 descent udev[4377]: main: version 009 Dec 22 00:47:17 descent udev[4377]: main: looking at '/devices/pci0000:00/0000:00:02.2/usb1/1-2/1-2.3/1-2.3:1.0/host12/12:0:0:0' Dec 22 00:47:17 descent udev[4377]: main: not a block or class device Dec 22 00:47:17 descent kernel: sdb: Mode Sense: 00 32 02 00 Dec 22 00:47:17 descent udev[4383]: main: version 009 Dec 22 00:47:17 descent udev[4383]: main: looking at '/block/sdb' Dec 22 00:47:17 descent udev[4383]: get_dirs: sysfs_path='/sys' Dec 22 00:47:17 descent udev[4383]: parse_config_file: reading '/etc/udev/udev.conf' as config file Dec 22 00:47:17 descent udev[4383]: namedev_init_rules: reading '/etc/udev/udev.rules' as rules file Dec 22 00:47:17 descent udev[4383]: namedev_init_permissions: reading '/etc/udev/udev.permissions' as permissions file Dec 22 00:47:17 descent udev[4383]: sleep_for_dev: looking for '/sys/block/sdb/dev' Dec 22 00:47:17 descent udev[4383]: get_class_dev: looking at '/sys/block/sdb' Dec 22 00:47:17 descent udev[4383]: get_class_dev: class_dev->name='sdb' Dec 22 00:47:17 descent udev[4383]: get_major_minor: dev='8:16 ' Dec 22 00:47:17 descent udev[4383]: get_major_minor: found major=8, minor=16 Dec 22 00:47:17 descent udev[4383]: namedev_name_device: looking at block device Dec 22 00:47:17 descent udev[4383]: namedev_name_device: class_dev->name = 'sdb' Dec 22 00:47:17 descent udev[4383]: build_kernel_number: kernel_number='' Dec 22 00:47:17 descent udev[4383]: do_label: look for device attribute 'model' Dec 22 00:47:17 descent udev[4383]: sysfs_path_is_file: stat() failed Dec 22 00:47:17 descent udev[4383]: do_replace: compare name 'md[0-9]*' with 'sdb' Dec 22 00:47:17 descent udev[4383]: do_replace: compare name 'tty[0-9]*' with 'sdb' Dec 22 00:47:17 descent udev[4383]: do_replace: compare name 'ttyS[0-9]*' with 'sdb' Dec 22 00:47:17 descent udev[4383]: do_replace: compare name 'ttyUSB[0-9]*' with 'sdb' Dec 22 00:47:17 descent udev[4383]: do_replace: compare name 'vcs' with 'sdb' Dec 22 00:47:17 descent udev[4383]: do_replace: compare name 'vcs[0-9]*' with 'sdb' Dec 22 00:47:17 descent udev[4383]: do_replace: compare name 'vcsa' with 'sdb' Dec 22 00:47:17 descent udev[4383]: do_replace: compare name 'vcsa[0-9]*' with 'sdb' Dec 22 00:47:17 descent udev[4383]: do_replace: compare name 'video[0-9]*' with 'sdb' Dec 22 00:47:17 descent udev[4383]: do_replace: compare name 'radio[0-9]*' with 'sdb' Dec 22 00:47:17 descent udev[4383]: do_replace: compare name 'vbi[0-9]*' with 'sdb' Dec 22 00:47:17 descent udev[4383]: do_replace: compare name 'vtx[0-9]*' with 'sdb' Dec 22 00:47:17 descent udev[4383]: namedev_name_device: name, 'sdb' is going to have owner='root', group='disk', mode = 0660 Dec 22 00:47:17 descent udev[4383]: udev_add_device: name='sdb' Dec 22 00:47:17 descent udev[4383]: create_node: mknod(/udev/sdb, 060660, 8, 16)Dec 22 00:47:17 descent udev[4383]: create_node: chmod(/udev/sdb, 060660) Dec 22 00:47:17 descent udev[4383]: create_node: chown(/udev/sdb, 0, 6) Dec 22 00:47:17 descent udev[4389]: main: version 009 Dec 22 00:47:17 descent udev[4389]: main: looking at '/block/sdb/sdb1' Dec 22 00:47:17 descent udev[4389]: get_dirs: sysfs_path='/sys' Dec 22 00:47:17 descent udev[4389]: parse_config_file: reading '/etc/udev/udev.conf' as config file Dec 22 00:47:17 descent udev[4389]: namedev_init_rules: reading '/etc/udev/udev.rules' as rules file Dec 22 00:47:17 descent udev[4389]: namedev_init_permissions: reading '/etc/udev/udev.permissions' as permissions file Dec 22 00:47:17 descent udev[4389]: sleep_for_dev: looking for '/sys/block/sdb/sdb1/dev' Dec 22 00:47:17 descent udev[4389]: get_class_dev: looking at '/sys/block/sdb/sdb1' Dec 22 00:47:17 descent udev[4389]: get_class_dev: class_dev->name='sdb1' Dec 22 00:47:17 descent udev[4389]: get_major_minor: dev='8:17 ' Dec 22 00:47:17 descent udev[4389]: get_major_minor: found major=8, minor=17 Dec 22 00:47:17 descent udev[4389]: namedev_name_device: looking at block deviceDec 22 00:47:17 descent udev[4389]: namedev_name_device: really is a partition Dec 22 00:47:17 descent udev[4389]: namedev_name_device: class_dev_parent->name='sdb' Dec 22 00:47:17 descent udev[4389]: sysfs_path_is_link: stat() failed Dec 22 00:47:17 descent last message repeated 6 times Dec 22 00:47:17 descent udev[4389]: namedev_name_device: sysfs_device->path='/sys/devices/pci0000:00/0000:00:02.2/usb1/1-2/1-2.3/1-2.3:1.0/host12/12:0:0:0' Dec 22 00:47:17 descent udev[4389]: namedev_name_device: sysfs_device->bus_id='12:0:0:0' Dec 22 00:47:17 descent udev[4389]: namedev_name_device: sysfs_device->bus='unknown' Dec 22 00:47:17 descent udev[4389]: build_kernel_number: kernel_number='1' Dec 22 00:47:17 descent udev[4389]: do_label: dev->bus='usb' sysfs_device->bus='unknown' Dec 22 00:47:17 descent udev[4389]: do_number: dev->bus='ide' sysfs_device->bus='unknown' Dec 22 00:47:17 descent last message repeated 3 times Dec 22 00:47:17 descent udev[4389]: do_replace: compare name 'md[0-9]*' with 'sdb1' Dec 22 00:47:17 descent udev[4389]: do_replace: compare name 'tty[0-9]*' with 'sdb1' Dec 22 00:47:17 descent udev[4389]: do_replace: compare name 'ttyS[0-9]*' with 'sdb1' Dec 22 00:47:17 descent udev[4389]: do_replace: compare name 'ttyUSB[0-9]*' with 'sdb1' Dec 22 00:47:17 descent udev[4389]: do_replace: compare name 'vcs' with 'sdb1' Dec 22 00:47:17 descent udev[4389]: do_replace: compare name 'vcs[0-9]*' with 'sdb1' Dec 22 00:47:17 descent udev[4389]: do_replace: compare name 'vcsa' with 'sdb1' Dec 22 00:47:17 descent udev[4389]: do_replace: compare name 'vcsa[0-9]*' with 'sdb1' Dec 22 00:47:17 descent udev[4389]: do_replace: compare name 'video[0-9]*' with 'sdb1' Dec 22 00:47:17 descent udev[4389]: do_replace: compare name 'radio[0-9]*' with 'sdb1' Dec 22 00:47:17 descent udev[4389]: do_replace: compare name 'vbi[0-9]*' with 'sdb1' Dec 22 00:47:17 descent udev[4389]: do_replace: compare name 'vtx[0-9]*' with 'sdb1' Dec 22 00:47:17 descent udev[4389]: namedev_name_device: name, 'sdb1' is going to have owner='root', group='disk', mode = 0660 Dec 22 00:47:17 descent udev[4389]: udev_add_device: name='sdb1' Dec 22 00:47:17 descent udev[4389]: create_node: mknod(/udev/sdb1, 060660, 8, 17) Dec 22 00:47:17 descent udev[4389]: create_node: chmod(/udev/sdb1, 060660) Dec 22 00:47:17 descent udev[4389]: create_node: chown(/udev/sdb1, 0, 6) Dec 22 00:47:17 descent udev[4395]: main: version 009 Dec 22 00:47:17 descent udev[4395]: main: looking at '/class/scsi_device/12:0:0:0' Dec 22 00:47:17 descent udev[4395]: get_dirs: sysfs_path='/sys' Dec 22 00:47:17 descent udev[4395]: parse_config_file: reading '/etc/udev/udev.conf' as config file Dec 22 00:47:17 descent udev[4395]: namedev_init_rules: reading '/etc/udev/udev.rules' as rules file Dec 22 00:47:17 descent udev[4395]: namedev_init_permissions: reading '/etc/udev/udev.permissions' as permissions file Dec 22 00:47:17 descent udev[4395]: sleep_for_dev: looking for '/sys/class/scsi_device/12:0:0:0/dev' Dec 22 00:47:17 descent kernel: WARNING: USB Mass Storage data integrity not assured Dec 22 00:47:17 descent kernel: USB Mass Storage device found at 17 Dec 22 00:47:18 descent udev[4366]: sleep_for_dev: looking for '/sys/class/scsi_host/host12/dev' Dec 22 00:47:18 descent udev[4395]: sleep_for_dev: looking for '/sys/class/scsi_device/12:0:0:0/dev' Dec 22 00:47:19 descent udev[4397]: main: version 009 Dec 22 00:47:19 descent udev[4397]: main: looking at '/devices/pci0000:00/0000:00:02.2/usb1/1-2/1-2.3' Dec 22 00:47:19 descent udev[4397]: main: not a block or class device Dec 22 00:47:19 descent udev[4366]: sleep_for_dev: looking for '/sys/class/scsi_host/host12/dev' Dec 22 00:47:19 descent udev[4395]: sleep_for_dev: looking for '/sys/class/scsi_device/12:0:0:0/dev' Dec 22 00:47:20 descent udev[4366]: sleep_for_dev: looking for '/sys/class/scsi_host/host12/dev' Dec 22 00:47:20 descent udev[4395]: sleep_for_dev: looking for '/sys/class/scsi_device/12:0:0:0/dev' Dec 22 00:47:21 descent udev[4366]: sleep_for_dev: looking for '/sys/class/scsi_host/host12/dev' Dec 22 00:47:21 descent udev[4395]: sleep_for_dev: looking for '/sys/class/scsi_device/12:0:0:0/dev' Dec 22 00:47:22 descent udev[4366]: sleep_for_dev: looking for '/sys/class/scsi_host/host12/dev' Dec 22 00:47:22 descent udev[4395]: sleep_for_dev: looking for '/sys/class/scsi_device/12:0:0:0/dev' Dec 22 00:47:23 descent udev[4366]: sleep_for_dev: looking for '/sys/class/scsi_host/host12/dev' Dec 22 00:47:23 descent udev[4395]: sleep_for_dev: looking for '/sys/class/scsi_device/12:0:0:0/dev' Dec 22 00:47:24 descent udev[4366]: sleep_for_dev: looking for '/sys/class/scsi_host/host12/dev' Dec 22 00:47:24 descent udev[4395]: sleep_for_dev: looking for '/sys/class/scsi_device/12:0:0:0/dev' Dec 22 00:47:25 descent udev[4366]: sleep_for_dev: looking for '/sys/class/scsi_host/host12/dev' Dec 22 00:47:25 descent udev[4395]: sleep_for_dev: looking for '/sys/class/scsi_device/12:0:0:0/dev' Dec 22 00:47:26 descent udev[4366]: sleep_for_dev: looking for '/sys/class/scsi_host/host12/dev' Dec 22 00:47:26 descent udev[4395]: sleep_for_dev: looking for '/sys/class/scsi_device/12:0:0:0/dev'
Quoted 1 line · Scott James Remnant
[I am not subscribed to linux-kernel, please Cc: me on replies.]
The linux-hotplug-devel mailing list is best place for questions about udev, not lkml...
Quoted 4 lines
I'm having a problem getting udev to honour my LABEL lines in
/etc/udev/udev.rules. At the top of this I've got:LABEL, BUS="usb", SYSFS_vendor="Fujifilm", SYSFS_model="FinePix 1400Zoom", NAME="camera"
Try changing BUS="usb" to BUS="scsi". Also make sure that the model file doesn't contain any trailing spaces. That's a very common thing on usb devices.
And you are trying to match up 2 files, right now udev only supports 1, so the last one (model) is used. The vendor rule there is ignored.
There is also a problem with udev beating the kernel. It can easily get the hotplug event before the kernel has created the sysfs file. I'm currently working on fixing this in udev, should have it done by the next release. You can tell if you are seeing this race by just running the test.block script in the test directory in udev. If your device node is created properly with that script, but not when you plug the device in, you have that problem.
And people tried to tell us that the hotplug interface was slow without ever testing it out...
Hope this helps,
greg k-h
[I am not subscribed to linux-kernel or linux-hotplug-devel, please Cc:
me on replies.]
Quoted 12 lines · Greg KH
Quoted 1 line · Scott James Remnant
I'm having a problem getting udev to honour my LABEL lines
There is also a problem with udev beating the kernel. It can easily get the hotplug event before the kernel has created the sysfs file. I'm currently working on fixing this in udev, should have it done by the next release. You can tell if you are seeing this race by just running the test.block script in the test directory in udev. If your device node is created properly with that script, but not when you plug the device in, you have that problem.
Quoted 3 lines
And people tried to tell us that the hotplug interface was slow without ever testing it out...
It looks like this is what's happening, after tracing the code I added some stuff to print out everything in the sysfs directory at the time udev was running, and it is devoid of the vendor & model files which turn up shortly afterwards.
On the slower laptop, it works as expected.
One question though, it only ever seems to create a device for the actual usb-storage disk and not the partition. Is there some magic to create the partition device instead?
Scott
Signature · 2 lines
Have you ever, ever felt like this? Had strange things happen? Are you going round the twist?
Quoted 3 lines · Scott James Remnant
One question though, it only ever seems to create a device for the actual usb-storage disk and not the partition. Is there some magic to create the partition device instead?
Do you have a partition show up in /sys/block? If not, then udev will not create it. It works here for my usb-storage devices that have partitions on them.
thanks,
greg k-h
Quoted 9 lines · Greg KH
Quoted 3 lines · Scott James Remnant
One question though, it only ever seems to create a device for the actual usb-storage disk and not the partition. Is there some magic to create the partition device instead?
Do you have a partition show up in
/sys/block? If not, then udev will not create it. It works here for my usb-storage devices that have partitions on them.
Yes, /dev/block/sdb/sdb1 certainly does appear, as does /udev/sdb1 -- the LABEL rule only seems to match "sdb" though.
Scott
Signature · 2 lines
Have you ever, ever felt like this? Had strange things happen? Are you going round the twist?
Quoted 7 lines · Scott James Remnant
Quoted 5 lines · Greg KH
Quoted 3 lines · Scott James Remnant
One question though, it only ever seems to create a device for the actual usb-storage disk and not the partition. Is there some magic to create the partition device instead?
Quoted 6 lines
Quoted 4 lines
Do you have a partition show up in
/sys/block? If not, then udev will not create it. It works here for my usb-storage devices that have partitions on them.Yes,
/dev/block/sdb/sdb1certainly does appear, as does /udev/sdb1 -- the LABEL rule only seems to match "sdb" though.
That's odd, what is the rule? They should both match.
greg k-h
Quoted 8 lines · Greg KH
Quoted 7 lines · Scott James Remnant
Quoted 5 lines · Greg KH
Quoted 3 lines · Scott James Remnant
One question though, it only ever seems to create a device for the actual usb-storage disk and not the partition. Is there some magic to create the partition device instead?
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
Do you have a partition show up in
/sys/block? If not, then udev will not create it. It works here for my usb-storage devices that have partitions on them.Yes,
/dev/block/sdb/sdb1certainly does appear, as does /udev/sdb1 -- the LABEL rule only seems to match "sdb" though.That's odd, what is the rule? They should both match.
Had omitted the %n in the NAME, so only the disk was showing up. udev-011 fixes the original problem too, thanks.
Scott
Signature · 2 lines
Have you ever, ever felt like this? Had strange things happen? Are you going round the twist?