* Problem in udev with %e device numbering
@ 2005-01-29 17:53 Michael Gutmann
2005-01-29 19:53 ` Kay Sievers
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Michael Gutmann @ 2005-01-29 17:53 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 1754 bytes --]
Hi,
device numbering with %e breaks with NAME{all_partitions} when using
usb-devices that attach more than one virtual scsi-disk. I've got a
multi-card-reader that announces itself as four scsi-drives, even if
no card is plugged in. Partitions certainly can be found only when a
card is put into the card reader. Unfortunately they are only found if
something tries to use the card, f.e. fdisk.
So I have to use NAME(all_partitions}. No problem so far, but I want to
use symbolic names instead of sd?. But if I use SYMLINK="cardreader%e"
f.e. there are only links to sd[abcd] and not to the partitions.
The only way I see is using NAME{all_partitions}="card%e". But because
the first name ist not card0 but just card, the device nodes for the
next three devices get overwritten with the nodes of the first
partitions of the first device:
sda -> card sdb -> card1 sdc -> card2 sdd -> card3
sda1 -> card1 sdb1 -> card11 sdc1 -> card21 sdd1 -> ...
sda2 -> card2 sdb2 -> card12 sdc2 -> card22
sda3 -> card3 sdb3 -> card13 sdc3 -> card23
...
My first idea was something like SYMLINK{all_partitions}="cardreader%e"
but that didn't work ;-). Second idea was to start the numbering with
zero. I looked at the sources and found the second the easier way
(patch attached) although the result looks not very appealing and a lot
like the old /dev ...
The patch seems to work, but it's not absolutely accurately tested
Also I have not inspected the rest of the source if this numbering has
side effects. 8-)
Michael
-- Michael Gutmann
Multimediazentrum Heinrich-Heine-Universität Düsseldorf
D-40225 Düsseldorf, Moorenstr. 5, Geb. 14.77
Tel.: +49 211 81 19730, Fax: +49 211 81 19741
[-- Attachment #2: namedev.diff --]
[-- Type: text/x-diff, Size: 782 bytes --]
--- udev-050.orig/namedev.c 2005-01-29 17:24:18.000000000 +0100
+++ udev-050/namedev.c 2005-01-29 17:54:36.000000000 +0100
@@ -164,6 +164,8 @@ static int find_free_number(struct udevi
struct udevice db_udev;
strfieldcpy(filename, name);
+ /* starting with filename "name0" instead of just "name" MG */
+ snprintf(filename, NAME_SIZE, "%s%d", name, num);
while (1) {
dbg("look for existing node '%s'", filename);
memset(&db_udev, 0x00, sizeof(struct udevice));
@@ -301,7 +303,7 @@ static void apply_format(struct udevice
break;
case 'e':
next_free_number = find_free_number(udev, string);
- if (next_free_number > 0) {
+ if (next_free_number >= 0) {
sprintf(temp2, "%d", next_free_number);
strfieldcatmax(string, temp2, maxsize);
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Problem in udev with %e device numbering
2005-01-29 17:53 Problem in udev with %e device numbering Michael Gutmann
@ 2005-01-29 19:53 ` Kay Sievers
2005-01-30 10:39 ` Michael Gutmann
2005-01-30 14:58 ` Kay Sievers
2 siblings, 0 replies; 4+ messages in thread
From: Kay Sievers @ 2005-01-29 19:53 UTC (permalink / raw)
To: linux-hotplug
On Sat, 2005-01-29 at 18:53 +0100, Michael Gutmann wrote:
> device numbering with %e breaks with NAME{all_partitions} when using
> usb-devices that attach more than one virtual scsi-disk. I've got a
> multi-card-reader that announces itself as four scsi-drives, even if
> no card is plugged in. Partitions certainly can be found only when a
> card is put into the card reader. Unfortunately they are only found if
> something tries to use the card, f.e. fdisk.
If you don't use anything that polls the device for a media change,
which is what all major desktop installation do today, you don't get
these nodes, yes.
> So I have to use NAME(all_partitions}. No problem so far, but I want to
> use symbolic names instead of sd?. But if I use SYMLINK="cardreader%e"
> f.e. there are only links to sd[abcd] and not to the partitions.
> The only way I see is using NAME{all_partitions}="card%e".
There is no sane way to use the %e key in cases you get concurrent
events asking for enumeration of the same name. It's a too simple hack
and there is no way with the current udev model to get this fixed inside
of udev.
The only sane solution, I can imagine would be an external program, that
does the enumeration and returns the value to udev. This external
program would need to maintain its own database in a dotfile in /dev and
must use a file lock to serialize concurrent processes asking for the
value. This topic was already discussed on this list, you may look at
the archives...
Kay
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Problem in udev with %e device numbering
2005-01-29 17:53 Problem in udev with %e device numbering Michael Gutmann
2005-01-29 19:53 ` Kay Sievers
@ 2005-01-30 10:39 ` Michael Gutmann
2005-01-30 14:58 ` Kay Sievers
2 siblings, 0 replies; 4+ messages in thread
From: Michael Gutmann @ 2005-01-30 10:39 UTC (permalink / raw)
To: linux-hotplug
Hello Kay,
sorry for bothering you, but maybe you can help me out with
understanding the underlying problem.
On Sat, 2005-01-29 at 20:53 You wrote:
> On Sat, 2005-01-29 at 18:53 +0100, Michael Gutmann wrote:
<...>
> > card is put into the card reader. Unfortunately they are only found if
> > something tries to use the card, f.e. fdisk.
>
> If you don't use anything that polls the device for a media change,
> which is what all major desktop installation do today, you don't get
> these nodes, yes.
Sorry, didn't want to blame udev for doing this. I was rather
disappointed, that the card reader didn't announce changes itself ;-)
> > So I have to use NAME(all_partitions}. No problem so far, but I want to
> > use symbolic names instead of sd?. But if I use SYMLINK="cardreader%e"
> > f.e. there are only links to sd[abcd] and not to the partitions.
> > The only way I see is using NAME{all_partitions}="card%e".
>
> There is no sane way to use the %e key in cases you get concurrent
> events asking for enumeration of the same name. It's a too simple hack
> and there is no way with the current udev model to get this fixed inside
> of udev.
Oh shit. I get your point:
Jan 30 11:17:47 localhost kernel: usb-storage: device found at 2
Jan 30 11:17:48 localhost kernel: usb-storage: waiting for device to settle before scanning
Jan 30 11:17:48 localhost usb.agent[5358]: usb-storage: loaded successfully
Jan 30 11:17:52 localhost kernel: Vendor: Generic Model: Flash R/W Rev: 2002
Jan 30 11:17:52 localhost kernel: Type: Direct-Access ANSI SCSI revision: 02
Jan 30 11:17:52 localhost kernel: Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0
Jan 30 11:17:52 localhost kernel: Vendor: Generic Model: Flash R/W Rev: 2002
Jan 30 11:17:52 localhost kernel: Type: Direct-Access ANSI SCSI revision: 02
Jan 30 11:17:52 localhost kernel: Attached scsi removable disk sdb at scsi0, channel 0, id 0, lun 1
Jan 30 11:17:53 localhost udev[5456]: configured rule in '/etc/udev/rules.d/10_micha.rules' at line 3 applied, 'sda' becomes 'card%e'
Jan 30 11:17:53 localhost udev[5481]: configured rule in '/etc/udev/rules.d/10_micha.rules' at line 3 applied, 'sdb' becomes 'card%e'
Jan 30 11:17:53 localhost kernel: Vendor: Generic Model: Flash R/W Rev: 2002
Jan 30 11:17:53 localhost kernel: Type: Direct-Access ANSI SCSI revision: 02
Jan 30 11:17:53 localhost kernel: Attached scsi removable disk sdc at scsi0, channel 0, id 0, lun 2
Jan 30 11:17:53 localhost udev[5499]: configured rule in '/etc/udev/rules.d/10_micha.rules' at line 3 applied, 'sdc' becomes 'card%e'
Jan 30 11:17:53 localhost kernel: Vendor: Generic Model: Flash R/W Rev: 2002
Jan 30 11:17:53 localhost kernel: Type: Direct-Access ANSI SCSI revision: 02
Jan 30 11:17:53 localhost udev[5499]: creating device node '/dev/card0'
Jan 30 11:17:53 localhost udev[5499]: creating device partition nodes '/dev/card0[1-15]'
Jan 30 11:17:53 localhost udev[5481]: creating device node '/dev/card0'
Jan 30 11:17:53 localhost udev[5481]: creating device partition nodes '/dev/card0[1-15]'
Jan 30 11:17:53 localhost udev[5456]: creating device node '/dev/card0'
Jan 30 11:17:53 localhost udev[5456]: creating device partition nodes '/dev/card0[1-15]'
Jan 30 11:17:53 localhost kernel: Attached scsi removable disk sdd at scsi0, channel 0, id 0, lun 3
Jan 30 11:17:53 localhost kernel: usb-storage: device scan complete
Jan 30 11:17:53 localhost udev[5522]: configured rule in '/etc/udev/rules.d/10_micha.rules' at line 3 applied, 'sdd' becomes 'card%e'
Jan 30 11:17:53 localhost udev[5522]: creating device node '/dev/card1'
Jan 30 11:17:53 localhost udev[5522]: creating device partition nodes '/dev/card1[1-15]'
But here I get into trouble: with kernel 2.6.10 device numbering is
serialized dependent on the physical device (as I understood the
discussion last december) As you can see, the different parts of the
card reader are identified as luns. Isn't it possible to identify the
physical device behind that luns and serialize the numbering for it?
> The only sane solution, I can imagine would be an external program, that
> does the enumeration and returns the value to udev. This external
> program would need to maintain its own database in a dotfile in /dev and
> must use a file lock to serialize concurrent processes asking for the
> value. This topic was already discussed on this list, you may look at
> the archives...
Argh, this misses the elegance I marvel at udev.
> Kay
Thanks,
Michael
-- Michael Gutmann
Multimediazentrum Heinrich-Heine-Universität Düsseldorf
D-40225 Düsseldorf, Moorenstr. 5, Geb. 14.77
Tel.: +49 211 81 19730, Fax: +49 211 81 19741
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Problem in udev with %e device numbering
2005-01-29 17:53 Problem in udev with %e device numbering Michael Gutmann
2005-01-29 19:53 ` Kay Sievers
2005-01-30 10:39 ` Michael Gutmann
@ 2005-01-30 14:58 ` Kay Sievers
2 siblings, 0 replies; 4+ messages in thread
From: Kay Sievers @ 2005-01-30 14:58 UTC (permalink / raw)
To: linux-hotplug
On Sun, 2005-01-30 at 11:39 +0100, Michael Gutmann wrote:
> On Sat, 2005-01-29 at 20:53 You wrote:
> > On Sat, 2005-01-29 at 18:53 +0100, Michael Gutmann wrote:
> <...>
> > > card is put into the card reader. Unfortunately they are only found if
> > > something tries to use the card, f.e. fdisk.
> >
> > If you don't use anything that polls the device for a media change,
> > which is what all major desktop installation do today, you don't get
> > these nodes, yes.
>
> Sorry, didn't want to blame udev for doing this. I was rather
> disappointed, that the card reader didn't announce changes itself ;-)
I've never seen any USB storage device that can do this. Only one, that
causes a whole USB device diconnect on media removal. :)
> > > So I have to use NAME(all_partitions}. No problem so far, but I want to
> > > use symbolic names instead of sd?. But if I use SYMLINK="cardreader%e"
> > > f.e. there are only links to sd[abcd] and not to the partitions.
> > > The only way I see is using NAME{all_partitions}="card%e".
> >
> > There is no sane way to use the %e key in cases you get concurrent
> > events asking for enumeration of the same name. It's a too simple hack
> > and there is no way with the current udev model to get this fixed inside
> > of udev.
>
> Oh shit. I get your point:
>
> Jan 30 11:17:47 localhost kernel: usb-storage: device found at 2
> Jan 30 11:17:48 localhost kernel: usb-storage: waiting for device to settle before scanning
> Jan 30 11:17:48 localhost usb.agent[5358]: usb-storage: loaded successfully
> Jan 30 11:17:52 localhost kernel: Vendor: Generic Model: Flash R/W Rev: 2002
> Jan 30 11:17:52 localhost kernel: Type: Direct-Access ANSI SCSI revision: 02
> Jan 30 11:17:52 localhost kernel: Attached scsi removable disk sda at scsi0, channel 0, id 0, lun 0
> Jan 30 11:17:52 localhost kernel: Vendor: Generic Model: Flash R/W Rev: 2002
> Jan 30 11:17:52 localhost kernel: Type: Direct-Access ANSI SCSI revision: 02
> Jan 30 11:17:52 localhost kernel: Attached scsi removable disk sdb at scsi0, channel 0, id 0, lun 1
> Jan 30 11:17:53 localhost udev[5456]: configured rule in '/etc/udev/rules.d/10_micha.rules' at line 3 applied, 'sda' becomes 'card%e'
> Jan 30 11:17:53 localhost udev[5481]: configured rule in '/etc/udev/rules.d/10_micha.rules' at line 3 applied, 'sdb' becomes 'card%e'
> Jan 30 11:17:53 localhost kernel: Vendor: Generic Model: Flash R/W Rev: 2002
> Jan 30 11:17:53 localhost kernel: Type: Direct-Access ANSI SCSI revision: 02
> Jan 30 11:17:53 localhost kernel: Attached scsi removable disk sdc at scsi0, channel 0, id 0, lun 2
> Jan 30 11:17:53 localhost udev[5499]: configured rule in '/etc/udev/rules.d/10_micha.rules' at line 3 applied, 'sdc' becomes 'card%e'
> Jan 30 11:17:53 localhost kernel: Vendor: Generic Model: Flash R/W Rev: 2002
> Jan 30 11:17:53 localhost kernel: Type: Direct-Access ANSI SCSI revision: 02
> Jan 30 11:17:53 localhost udev[5499]: creating device node '/dev/card0'
> Jan 30 11:17:53 localhost udev[5499]: creating device partition nodes '/dev/card0[1-15]'
> Jan 30 11:17:53 localhost udev[5481]: creating device node '/dev/card0'
> Jan 30 11:17:53 localhost udev[5481]: creating device partition nodes '/dev/card0[1-15]'
> Jan 30 11:17:53 localhost udev[5456]: creating device node '/dev/card0'
> Jan 30 11:17:53 localhost udev[5456]: creating device partition nodes '/dev/card0[1-15]'
> Jan 30 11:17:53 localhost kernel: Attached scsi removable disk sdd at scsi0, channel 0, id 0, lun 3
> Jan 30 11:17:53 localhost kernel: usb-storage: device scan complete
> Jan 30 11:17:53 localhost udev[5522]: configured rule in '/etc/udev/rules.d/10_micha.rules' at line 3 applied, 'sdd' becomes 'card%e'
> Jan 30 11:17:53 localhost udev[5522]: creating device node '/dev/card1'
> Jan 30 11:17:53 localhost udev[5522]: creating device partition nodes '/dev/card1[1-15]'
>
> But here I get into trouble: with kernel 2.6.10 device numbering is
> serialized dependent on the physical device (as I understood the
> discussion last december) As you can see, the different parts of the
> card reader are identified as luns. Isn't it possible to identify the
> physical device behind that luns and serialize the numbering for it?
Maybe we could, but it doesn't really address the fundamental flaw.
What if I connect more than one of these readers at the same time? The
enumeration numbers will still get mixed up.
> > The only sane solution, I can imagine would be an external program, that
> > does the enumeration and returns the value to udev. This external
> > program would need to maintain its own database in a dotfile in /dev and
> > must use a file lock to serialize concurrent processes asking for the
> > value. This topic was already discussed on this list, you may look at
> > the archives...
>
> Argh, this misses the elegance I marvel at udev.
Yes, that's not nice, but I really don't know how we could do a nice
enumeration over multiple devices/subsystems. The only thing, which can
be solved(using file locks) is that the enumeration counter does not
hand out the same number multiple times(as it can happen today).
The only sane solution is to use custom rules for every device and match
against individual attributes to create individual names for every
device, or to encode the topological position into the device name.
To create a single enumerated device name with sane sequences for
multiple devices seems like an unsolvable problem.
Kay
-------------------------------------------------------
This SF.Net email is sponsored by: IntelliVIEW -- Interactive Reporting
Tool for open source databases. Create drag-&-drop reports. Save time
by over 75%! Publish reports on the web. Export to DOC, XLS, RTF, etc.
Download a FREE copy at http://www.intelliview.com/go/osdn_nl
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2005-01-30 14:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-29 17:53 Problem in udev with %e device numbering Michael Gutmann
2005-01-29 19:53 ` Kay Sievers
2005-01-30 10:39 ` Michael Gutmann
2005-01-30 14:58 ` Kay Sievers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).