All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: udev: getting attributes from subdevice?
@ 2012-07-02 17:03 Kay Sievers
  0 siblings, 0 replies; 2+ messages in thread
From: Kay Sievers @ 2012-07-02 17:03 UTC (permalink / raw)
  To: linux-hotplug

On Sat, Jun 30, 2012 at 7:15 PM, Clemens Ladisch <clemens@ladisch.de> wrote:

> TEST="vendor_name", TEST!="model_name", WAIT_FOR="$kernel.0/model_name"
> TEST="vendor_name", TEST!="model_name", TEST="$kernel.0/model_name", \
>         OPTIONS="string_escape=replace", \
>         SYMLINK+="firewire/by-name/$attr{vendor_name} $attr{$kernel.0/model_name}"
>
> But this doesn't work, probably because $kernel is not substituted
> before $attr:
>
> $ ls -l /dev/firewire/by-name/
> lrwxrwxrwx 1 root root 9 2012-06-30 18:13 LaCie_ -> ../../fw2
>
> (It works if I use $attr{fw2.0/model_name}, but that isn't generic enough.)
>
> Do I have to write a separate tool for extracting the name?

There is no direct support for accessing child devices, because it is
too racy and the child devices usually do not even exist at the time
the event for the parent device is handled.

Special care in the kernel need to be taken to make all that possible,
like we do for example for disks and partitions.

Aside from that, why this usually does not work well, the format char
replacement is just one pass from the left to the right, so that order
would not work.

Kay

^ permalink raw reply	[flat|nested] 2+ messages in thread

* udev: getting attributes from subdevice?
@ 2012-06-30 17:15 Clemens Ladisch
  0 siblings, 0 replies; 2+ messages in thread
From: Clemens Ladisch @ 2012-06-30 17:15 UTC (permalink / raw)
  To: linux-hotplug

Hi,

I thought it would be useful to have persistent names for FireWire
devices:

########################################################################
ACTION="remove", GOTO="persistent_firewire_end"
SUBSYSTEM!="firewire", GOTO="persistent_firewire_end"

TEST="guid", SYMLINK+="firewire/by-id/guid-$attr{guid}"

TEST="vendor_name", TEST="model_name", \
	OPTIONS="string_escape=replace", \
	SYMLINK+="firewire/by-name/$attr{vendor_name} $attr{model_name}"

LABEL="persistent_firewire_end"
########################################################################

And these rules appear to work:

$ cat /sys/bus/firewire/devices/fw0/{vendor_name,model_name}
Linux Firewire
Juju
$ ls -l /dev/firewire/by-name/
lrwxrwxrwx 1 root root 9 2012-06-30 18:13 Linux_Firewire_Juju -> ../../fw0

However, there are devices where, due to some strange rules in the
FireWire specifications, some attributes end up belonging to a subdevice:

$ cat /sys/bus/firewire/devices/fw2/{vendor_name,model_name}
LaCie
cat: /sys/bus/firewire/devices/fw2/model_name: No such file or directory
$ cat /sys/bus/firewire/devices/fw2/fw2.0/model_name
Hard Drive Quadra

Okay, let's add some rules to handle this:

TEST="vendor_name", TEST!="model_name", WAIT_FOR="$kernel.0/model_name"
TEST="vendor_name", TEST!="model_name", TEST="$kernel.0/model_name", \
	OPTIONS="string_escape=replace", \
	SYMLINK+="firewire/by-name/$attr{vendor_name} $attr{$kernel.0/model_name}"

But this doesn't work, probably because $kernel is not substituted
before $attr:

$ ls -l /dev/firewire/by-name/
lrwxrwxrwx 1 root root 9 2012-06-30 18:13 LaCie_ -> ../../fw2

(It works if I use $attr{fw2.0/model_name}, but that isn't generic enough.)

Do I have to write a separate tool for extracting the name?


Regards,
Clemens

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-07-02 17:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-02 17:03 udev: getting attributes from subdevice? Kay Sievers
  -- strict thread matches above, loose matches on Subject: below --
2012-06-30 17:15 Clemens Ladisch

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.