* Possible udev bug and some questions
@ 2003-12-24 22:25 Martin Schlemmer
2003-12-25 0:19 ` Greg KH
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: Martin Schlemmer @ 2003-12-24 22:25 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1.1: Type: text/plain, Size: 4131 bytes --]
Hi
I know its not good form to post so many issues in one, but I
am currently on dialup, and not for more than a few hours. Also
please CC me, as I am not on this list.
1) if you look at the following code in namedev.c (in
function do_callout()):
--
if (sysfs_device) {
dbg("dev->bus='%s' sysfs_device->bus='%s'",
dev->bus, sysfs_device->bus);
if (strcasecmp(dev->bus, sysfs_device->bus) !=
0)
continue;
}
--
there is a slight problem - if sysfs_device = NULL, then the
'strcasecmp(dev->bus, sysfs_device->bus) != 0' test will never
be evaluated, and result in the callout to run for all non-phisical (?)
devices.
Attached is a possible patch, and this also brings me to second
question:
2) If I understand the udev manual correct, all 'methods' should have a
suitable 'key'. If I now look again at namedev.c, then whenever we
work with a non-phisical (?) (or not attached to a phisical bus?)
device, then non of the 'keys' used with 'methods' are available, as
get_sysfs_device() fails. Should any of the 'methods' then be run?
Or more to the code, should any of the do_* (do_callout, etc) functions
then be called for a device for which get_sysfs_device() failed?
Reference code for above (function namedev_name_device()):
--
/* find the sysfs_device associated with this class device */
sysfs_device = get_sysfs_device(class_dev);
if (sysfs_device) {
dbg("sysfs_device->path='%s'", sysfs_device->path);
dbg("sysfs_device->bus_id='%s'", sysfs_device->bus_id);
dbg("sysfs_device->bus='%s'", sysfs_device->bus);
strfieldcpy(udev->bus_id, sysfs_device->bus_id);
wait_for_device_to_initialize(sysfs_device);
} else {
dbg("class_dev->name = '%s'", class_dev->name);
}
--
3) After looking at ide-devfs.sh, I converted it to create the 'compat'
symlinks (/dev/{cdroms,discs}/* stuff) if anybody is interested (as
ide-devfs-compat.sh). Also, it would be nice if somebody could have
a look for holes - I am not sure what will happen with modular ide
setups ...
I would however like to extend it to scsi disks, but not sure what is
the most generic and easy way to try and figure out how many disks
there is ... any ideas?
This sorda brings me to point four:
4) Is there any reason why only one 'method' (meaning only one of the
callouts I may have for ide devices - I may want to use both the
ide-devfs.sh and ide-devfs-compat.sh to have multiple symlinks for on
device ...) is done for each device and/or hotplug event (beside lack
of time to implement) ? Same for why only 'type' of 'method' is done
for each (if a CALLOUT is done, the rest is skipped) ?
If no other reason that time, is anybody working on it, and if not,
any pointers to not clash with future plans (meaning I might want to
take a shot at implementing it)?
5) I use a devfs-less setup with udev, 2.6.0 kernel with most of the
sysfs patches from Greg, if not all, and a pre 2.3.3 glibc. Also
have devpts compiled in, and mounted to /dev/pts. I now have the
following 'w' output:
--
$ w
00:22:22 up 1:15, 13 users, load average: 0.98, 0.28, 0.14
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
azarah tty4 23:07 1:14m 1.19s 0.00s /bin/sh
/usr/X11R6/bin/startx
azarah ttyp0 23:08 ? 0.00s 0.00s -bash
azarah ttyp1 23:08 ? 0.00s 0.00s -bash
...
--
where I would rather expect something like this (devfs box):
--
$ w
00:35:38 up 32 days, 8:01, 1 user, load average: 0.19, 0.26, 0.20
USER TTY LOGIN@ IDLE JCPU PCPU WHAT
azarah pts/0 00:35 1.00s 0.04s 0.02s w
--
Just me, or somebody else have this as well? I know this could be a
few things (glibc, etc), but I want to try and get a 'starting point'
for debugging (if it should list 'pts/*' as TTY in the first place ...).
Thanks,
--
Martin Schlemmer
[-- Attachment #1.2: udev-010-valid-bus-for-CALLOUT.patch --]
[-- Type: text/x-patch, Size: 507 bytes --]
--- udev-010/namedev.c.orig 2003-12-24 17:19:52.992734720 +0200
+++ udev-010/namedev.c 2003-12-24 17:41:57.469383664 +0200
@@ -402,6 +402,9 @@
dbg("dev->bus='%s' sysfs_device->bus='%s'", dev->bus, sysfs_device->bus);
if (strcasecmp(dev->bus, sysfs_device->bus) != 0)
continue;
+ /* for this CALLOUT we need a valid sysfs_device */
+ } else if ((dev->bus != NULL) || (strlen(dev->bus) != 0)) {
+ continue;
}
/* substitute anything that needs to be in the program name */
[-- Attachment #1.3: ide-devfs-compat.sh --]
[-- Type: text/x-sh, Size: 927 bytes --]
#!/bin/sh
# udev CALLOUT script
# return compat devfs-names for ide-devices
# CALLOUT, BUS="ide", PROGRAM="/etc/udev/ide-devfs-compat.sh %k %b %n", ID="hd*", NAME="%1c", SYMLINK="%2c"
HOST=${2%\.[0-9]}
TARGET=${2#[0-9]\.}
if [ -z ${HOST#[13579]} ]; then
HOST=`expr $HOST - 1`
BUS="1"
else
BUS="0"
fi
get_dev_number() {
local x=
local num=0
local MEDIA=
for x in /proc/ide/*/media; do
if [ -e "$x" ]; then
MEDIA=`cat $x`
if [ "$MEDIA" = "$2" ]; then
num=`expr $num + 1`
fi
if [ "$x" = "/proc/ide/$1/media" ]; then
break
fi
fi
done
echo `expr $num - 1`
}
if [ -z "$3" ]; then
MEDIA=`cat /proc/ide/$1/media`
if [ "$MEDIA" = "cdrom" ]; then
echo $1 cdroms/cdrom`get_dev_number $1 cdrom`
elif [ "$MEDIA" = "disk" ]; then
echo $1 discs/disc`get_dev_number $1 disk`/disc
fi
else
echo $1 discs/disc`get_dev_number $1 disk`/part$3
fi
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Possible udev bug and some questions
2003-12-24 22:25 Possible udev bug and some questions Martin Schlemmer
@ 2003-12-25 0:19 ` Greg KH
2003-12-25 0:30 ` Greg KH
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Greg KH @ 2003-12-25 0:19 UTC (permalink / raw)
To: linux-hotplug
On Thu, Dec 25, 2003 at 12:25:22AM +0200, Martin Schlemmer wrote:
> Hi
>
> I know its not good form to post so many issues in one, but I
> am currently on dialup, and not for more than a few hours. Also
> please CC me, as I am not on this list.
>
> 1) if you look at the following code in namedev.c (in
> function do_callout()):
>
> --
> if (sysfs_device) {
> dbg("dev->bus='%s' sysfs_device->bus='%s'",
> dev->bus, sysfs_device->bus);
> if (strcasecmp(dev->bus, sysfs_device->bus) !> 0)
> continue;
>
> }
> --
>
> there is a slight problem - if sysfs_device = NULL, then the
> 'strcasecmp(dev->bus, sysfs_device->bus) != 0' test will never
> be evaluated, and result in the callout to run for all non-phisical (?)
> devices.
Ah, good catch. I've put a test in the udev-test.pl script to catch
this bug, and added the following patch:
--- a/namedev.c Wed Dec 24 16:09:18 2003
+++ b/namedev.c Wed Dec 24 16:09:18 2003
@@ -399,7 +399,10 @@
if (dev->type != CALLOUT)
continue;
- if (sysfs_device) {
+ if (dev->bus[0] != '\0') {
+ /* as the user specified a bus, we must match it up */
+ if (!sysfs_device)
+ continue;
dbg("dev->bus='%s' sysfs_device->bus='%s'", dev->bus, sysfs_device->bus);
if (strcasecmp(dev->bus, sysfs_device->bus) != 0)
continue;
I also made the BUS key optional for the CALLOUT rule. If the BUS value
is not present, then the CALLOUT rule is always called. Does this work
for you?
> 2) If I understand the udev manual correct, all 'methods' should have a
> suitable 'key'. If I now look again at namedev.c, then whenever we
> work with a non-phisical (?) (or not attached to a phisical bus?)
> device, then non of the 'keys' used with 'methods' are available, as
> get_sysfs_device() fails. Should any of the 'methods' then be run?
> Or more to the code, should any of the do_* (do_callout, etc) functions
> then be called for a device for which get_sysfs_device() failed?
Yeah, I've been thinking about this too. There are a lot of devices in
sysfs that do not have a "device" symlink right now (for one reason or
another...) When the device symlink is present, we can get a lot more
information about the device, and use it in udev.
Right now, if we can not find a sysfs_device, we can still run most of
the rules. LABEL works, CALLOUT now works, NUMBER makes no sense at all
without a sysfs_device and does not work. Same thing for TOPOLOGY.
Then REPLACE works too.
So without that link, we do the best that we can.
Is there something about the way devices without a sysfs_device works in
udev today that you do not like (except for the above bug...)
> 4) Is there any reason why only one 'method' (meaning only one of the
> callouts I may have for ide devices - I may want to use both the
> ide-devfs.sh and ide-devfs-compat.sh to have multiple symlinks for on
> device ...) is done for each device and/or hotplug event (beside lack
> of time to implement) ? Same for why only 'type' of 'method' is done
> for each (if a CALLOUT is done, the rest is skipped) ?
We stop comparing when we find the first rule that succeeds. Otherwise
how are we going to handle "catchall rules"? I don't want to have to
come up with a situation of weighting rules, and if more than one
matches, determing what needs to be done (both, none, one, etc.)
If you want to call two callout scripts, just make a new script that
calls them both :)
> 5) I use a devfs-less setup with udev, 2.6.0 kernel with most of the
> sysfs patches from Greg, if not all, and a pre 2.3.3 glibc. Also
> have devpts compiled in, and mounted to /dev/pts. I now have the
> following 'w' output:
Are you using udev to manage your /dev tree?
'w' works for me without using udev to manage my /dev tree. Try that to
see if it's a udev issue or not.
thanks,
greg k-h
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id\x1278&alloc_id371&op=click
_______________________________________________
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] 10+ messages in thread
* Re: Possible udev bug and some questions
2003-12-24 22:25 Possible udev bug and some questions Martin Schlemmer
2003-12-25 0:19 ` Greg KH
@ 2003-12-25 0:30 ` Greg KH
2003-12-25 10:06 ` Kay Sievers
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Greg KH @ 2003-12-25 0:30 UTC (permalink / raw)
To: linux-hotplug
On Wed, Dec 24, 2003 at 04:19:14PM -0800, Greg KH wrote:
> On Thu, Dec 25, 2003 at 12:25:22AM +0200, Martin Schlemmer wrote:
> > Hi
> >
> > I know its not good form to post so many issues in one, but I
> > am currently on dialup, and not for more than a few hours. Also
> > please CC me, as I am not on this list.
> >
> > 1) if you look at the following code in namedev.c (in
> > function do_callout()):
> >
> > --
> > if (sysfs_device) {
> > dbg("dev->bus='%s' sysfs_device->bus='%s'",
> > dev->bus, sysfs_device->bus);
> > if (strcasecmp(dev->bus, sysfs_device->bus) !> > 0)
> > continue;
> >
> > }
> > --
> >
> > there is a slight problem - if sysfs_device = NULL, then the
> > 'strcasecmp(dev->bus, sysfs_device->bus) != 0' test will never
> > be evaluated, and result in the callout to run for all non-phisical (?)
> > devices.
>
> Ah, good catch. I've put a test in the udev-test.pl script to catch
> this bug, and added the following patch:
I made the same patch for the LABEL rule, as that also could trigger
wrong acceptances.
thanks again.
greg k-h
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id\x1278&alloc_id371&op=click
_______________________________________________
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] 10+ messages in thread
* Re: Possible udev bug and some questions
2003-12-24 22:25 Possible udev bug and some questions Martin Schlemmer
2003-12-25 0:19 ` Greg KH
2003-12-25 0:30 ` Greg KH
@ 2003-12-25 10:06 ` Kay Sievers
2003-12-25 18:59 ` Martin Schlemmer
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Kay Sievers @ 2003-12-25 10:06 UTC (permalink / raw)
To: linux-hotplug
On Thu, Dec 25, 2003 at 12:25:22AM +0200, Martin Schlemmer wrote:
> 3) After looking at ide-devfs.sh, I converted it to create the 'compat'
> symlinks (/dev/{cdroms,discs}/* stuff) if anybody is interested (as
> ide-devfs-compat.sh).
[...]
> 4) Is there any reason why only one 'method' (meaning only one of the
> callouts I may have for ide devices - I may want to use both the
> ide-devfs.sh and ide-devfs-compat.sh to have multiple symlinks for on
> device ...) is done for each device and/or hotplug event (beside lack
> of time to implement) ? Same for why only 'type' of 'method' is done
> for each (if a CALLOUT is done, the rest is skipped) ?
Why not merge the two callout scripts in one, so that it
returns the two symlinks at once?
We support multiple symlinks separated by spaces.
...,NAME="%k", SYMLINK="%2c %3c"
> 5) I use a devfs-less setup with udev, 2.6.0 kernel with most of the
> sysfs patches from Greg, if not all, and a pre 2.3.3 glibc. Also
> have devpts compiled in, and mounted to /dev/pts. I now have the
> following 'w' output:
>
> --
> $ w
> 00:22:22 up 1:15, 13 users, load average: 0.98, 0.28, 0.14
> USER TTY LOGIN@ IDLE JCPU PCPU WHAT
> azarah tty4 23:07 1:14m 1.19s 0.00s /bin/sh
> /usr/X11R6/bin/startx
> azarah ttyp0 23:08 ? 0.00s 0.00s -bash
> azarah ttyp1 23:08 ? 0.00s 0.00s -bash
No problem here, my glibc package is 2.3.2.
kay@pim:~/src/udev.kay$ w
10:55:19 up 4 days, 22:53, 4 users, load average: 0.00, 0.02, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
kay tty1 - Sat12 4days 38.78s 0.00s /bin/sh /usr/bin/X11/startx
kay pts/0 :0.0 10:12 0.00s 0.07s 0.00s w
kay pts/1 :0.0 10:43 24.00s 0.23s 0.22s ssh puk
kay pts/2 :0.0 10:20 28:38 0.04s 0.04s bash
thanks,
Kay
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id\x1278&alloc_id371&op=click
_______________________________________________
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] 10+ messages in thread
* Re: Possible udev bug and some questions
2003-12-24 22:25 Possible udev bug and some questions Martin Schlemmer
` (2 preceding siblings ...)
2003-12-25 10:06 ` Kay Sievers
@ 2003-12-25 18:59 ` Martin Schlemmer
2003-12-25 19:32 ` Kay Sievers
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Martin Schlemmer @ 2003-12-25 18:59 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 4682 bytes --]
On Thu, 2003-12-25 at 02:19, Greg KH wrote:
> > 1) if you look at the following code in namedev.c (in
> > function do_callout()):
> >
> > there is a slight problem - if sysfs_device = NULL, then the
> > 'strcasecmp(dev->bus, sysfs_device->bus) != 0' test will never
> > be evaluated, and result in the callout to run for all non-phisical (?)
> > devices.
>
> Ah, good catch. I've put a test in the udev-test.pl script to catch
> this bug, and added the following patch:
> I also made the BUS key optional for the CALLOUT rule. If the BUS value
> is not present, then the CALLOUT rule is always called. Does this work
> for you?
>
Seems Ok, thanks.
> > 2) If I understand the udev manual correct, all 'methods' should have a
> > suitable 'key'. If I now look again at namedev.c, then whenever we
> > work with a non-phisical (?) (or not attached to a phisical bus?)
> > device, then non of the 'keys' used with 'methods' are available, as
> > get_sysfs_device() fails. Should any of the 'methods' then be run?
> > Or more to the code, should any of the do_* (do_callout, etc) functions
> > then be called for a device for which get_sysfs_device() failed?
>
> Right now, if we can not find a sysfs_device, we can still run most of
> the rules. LABEL works, CALLOUT now works, NUMBER makes no sense at all
> without a sysfs_device and does not work. Same thing for TOPOLOGY.
> Then REPLACE works too.
>
> So without that link, we do the best that we can.
>
Ok, makes sense - just wanted to verify if I should look deeper or not.
> Is there something about the way devices without a sysfs_device works in
> udev today that you do not like (except for the above bug...)
>
No. Once again, I was not sure about CALLOUT, LABEL, NUMBER and
TOPOLOGY, but CALLOUT is fixed, and according to your other mail,
so is LABEL, and NUMBER and TOPOLOGY have sufficient checks for
valid sysfs_device.
>
> > 4) Is there any reason why only one 'method' (meaning only one of the
> > callouts I may have for ide devices - I may want to use both the
> > ide-devfs.sh and ide-devfs-compat.sh to have multiple symlinks for on
> > device ...) is done for each device and/or hotplug event (beside lack
> > of time to implement) ? Same for why only 'type' of 'method' is done
> > for each (if a CALLOUT is done, the rest is skipped) ?
>
> We stop comparing when we find the first rule that succeeds. Otherwise
> how are we going to handle "catchall rules"? I don't want to have to
> come up with a situation of weighting rules, and if more than one
> matches, determing what needs to be done (both, none, one, etc.)
>
I was thinking more of 'find one, do whatever, find next, do whatever'.
I can see however that this could get messy.
> If you want to call two callout scripts, just make a new script that
> calls them both :)
>
I do not see how to do that, except if you let the scripts create the
symlinks/whatever, which is not entirely what I want.
Let me give an example that do not use CALLOUT:
LABEL BUS="scsi", SYSFS_type="5", SYMLINK="cdroms/cdrom%n"
LABEL BUS="scsi", SYSFS_type="5", SYMLINK="sr/%n"
Silly/may_not_work example, but it basically shows that I want two
symlinks for the same thing ...
The only other logical way I can think of, is to be able to stack
SYMLINK like so:
LABEL BUS="scsi", SYSFS_type="5", SYMLINK="cdroms/cdrom%n",
SYMLINK="sr/%n"
which does not work currently. That Ok with you?
A note though - I tried a quick hack for above with the help of the list.h
stuff (needs some more work to not actually segfault :/), but then I got
to the db stuff, and realized that it will be a slight issue to a link list
saved with the tdb stuff - much hacking. Other ideas that may be easier?
> > 5) I use a devfs-less setup with udev, 2.6.0 kernel with most of the
> > sysfs patches from Greg, if not all, and a pre 2.3.3 glibc. Also
> > have devpts compiled in, and mounted to /dev/pts. I now have the
> > following 'w' output:
>
> Are you using udev to manage your /dev tree?
>
> 'w' works for me without using udev to manage my /dev tree. Try that to
> see if it's a udev issue or not.
>
Bah, my udev.permissions was too gracious with test for /dev/pt*
(parallel tape drives), and set /dev/ptmx with 0600 permissions as
well :/ Thanks anyhow for looking.
Last question - with the pending libsysfs fixes, will there still be
the need for the second or so delay? Why I am asking, is because if
I want to generate devices in initramfs or such, it still will take
a long time ...
Thanks,
--
Martin Schlemmer
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Possible udev bug and some questions
2003-12-24 22:25 Possible udev bug and some questions Martin Schlemmer
` (3 preceding siblings ...)
2003-12-25 18:59 ` Martin Schlemmer
@ 2003-12-25 19:32 ` Kay Sievers
2003-12-25 20:00 ` Kay Sievers
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Kay Sievers @ 2003-12-25 19:32 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 1282 bytes --]
On Thu, Dec 25, 2003 at 09:24:57PM +0200, Martin Schlemmer wrote:
> On Thu, 2003-12-25 at 12:06, Kay Sievers wrote:
> > On Thu, Dec 25, 2003 at 12:25:22AM +0200, Martin Schlemmer wrote:
> > > 3) After looking at ide-devfs.sh, I converted it to create the 'compat'
> > > symlinks (/dev/{cdroms,discs}/* stuff) if anybody is interested (as
> > > ide-devfs-compat.sh).
> > [...]
> > > 4) Is there any reason why only one 'method' (meaning only one of the
> > > callouts I may have for ide devices - I may want to use both the
> > > ide-devfs.sh and ide-devfs-compat.sh to have multiple symlinks for on
> > > device ...) is done for each device and/or hotplug event (beside lack
> > > of time to implement) ? Same for why only 'type' of 'method' is done
> > > for each (if a CALLOUT is done, the rest is skipped) ?
> >
> > Why not merge the two callout scripts in one, so that it
> > returns the two symlinks at once?
> > We support multiple symlinks separated by spaces.
> >
> > ...,NAME="%k", SYMLINK="%2c %3c"
> >
>
> Right, now why isn't that in the docs? Unfortunately I also missed it
> while trying at hacking multiple SYMLINK=foo, SYMLINK=bar support.
it's in a man page example :)
here is a patch for the script and a small fix for namedev to work with...
thanks,
Kay
[-- Attachment #2: 02-ide-devfs.diff --]
[-- Type: text/plain, Size: 2420 bytes --]
diff -Nru a/extras/ide-devfs.sh b/extras/ide-devfs.sh
--- a/extras/ide-devfs.sh Thu Dec 25 20:27:43 2003
+++ b/extras/ide-devfs.sh Thu Dec 25 20:27:43 2003
@@ -2,7 +2,7 @@
# udev CALLOUT script
# return devfs-names for ide-devices
-# CALLOUT, BUS="ide", PROGRAM="/etc/udev/ide-devfs.sh %k %b %n", ID="hd*", NAME="%1c", SYMLINK="%2c"
+# CALLOUT, PROGRAM="/etc/udev/ide-devfs.sh %k %b %n", ID="hd*", NAME="%1c", SYMLINK="%2c %3c"
HOST=${2%\.[0-9]}
TARGET=${2#[0-9]\.}
@@ -14,14 +14,33 @@
BUS="0"
fi
+get_dev_number() {
+ local x=
+ local num=0
+ local MEDIA=
+
+ for x in /proc/ide/*/media; do
+ if [ -e "$x" ]; then
+ MEDIA=`cat $x`
+ if [ "$MEDIA" = "$2" ]; then
+ num=`expr $num + 1`
+ fi
+ if [ "$x" = "/proc/ide/$1/media" ]; then
+ break
+ fi
+ fi
+ done
+
+ echo `expr $num - 1`
+}
+
if [ -z "$3" ]; then
MEDIA=`cat /proc/ide/$1/media`
if [ "$MEDIA" = "cdrom" ]; then
- echo $1 ide/host$HOST/bus$BUS/target$TARGET/lun0/cd
+ echo $1 ide/host$HOST/bus$BUS/target$TARGET/lun0/cd cdroms/cdrom`get_dev_number $1 cdrom`
elif [ "$MEDIA" = "disk" ]; then
- echo $1 ide/host$HOST/bus$BUS/target$TARGET/lun0/disc
+ echo $1 ide/host$HOST/bus$BUS/target$TARGET/lun0/disc discs/disc`get_dev_number $1 disc`
fi
else
echo $1 ide/host$HOST/bus$BUS/target$TARGET/lun0/part$3
fi
-
diff -Nru a/namedev.c b/namedev.c
--- a/namedev.c Thu Dec 25 20:27:43 2003
+++ b/namedev.c Thu Dec 25 20:27:43 2003
@@ -200,11 +200,12 @@
case 'D':
if (strlen(udev->kernel_number) == 0) {
strcat(pos, "disc");
+ dbg("substitute devfs disc");
break;
}
strcat(pos, "part");
strcat(pos, udev->kernel_number);
- dbg("substitute kernel number '%s'", udev->kernel_number);
+ dbg("substitute devfs part number '%s'", udev->kernel_number);
break;
case 'm':
sprintf(pos, "%u", udev->minor);
@@ -225,12 +226,14 @@
num--;
pos3 = strsep(&pos2, " ");
if (pos3 == NULL) {
- dbg("requested part of callout string not found");
+ dbg("requested part of callout string is empty");
break;
}
}
- strcat(pos, pos3);
- dbg("substitute partial callout output '%s'", pos3);
+ if (pos3) {
+ strcat(pos, pos3);
+ dbg("substitute partial callout output '%s'", pos3);
+ }
} else {
strcat(pos, udev->callout_value);
dbg("substitute callout output '%s'", udev->callout_value);
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: Possible udev bug and some questions
2003-12-24 22:25 Possible udev bug and some questions Martin Schlemmer
` (4 preceding siblings ...)
2003-12-25 19:32 ` Kay Sievers
@ 2003-12-25 20:00 ` Kay Sievers
2003-12-25 21:04 ` Kay Sievers
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Kay Sievers @ 2003-12-25 20:00 UTC (permalink / raw)
To: linux-hotplug
On Thu, Dec 25, 2003 at 09:52:53PM +0200, Martin Schlemmer wrote:
> > here is a patch for the script and a small fix for namedev to work with...
> >
>
> BTW, there is a slight issue with your version of the script - it drops
> the /dev/discs/part* symlinks. Patch against your version attached.
Are you sure devfs does partitions in there?
It only lists the discs on my machine:
kay@pim:~/src/udev.kay$ tree /devfs/discs/
/devfs/discs/
|-- disc0 -> ../ide/host0/bus0/target0/lun0
|-- disc1 -> ../ide/host0/bus0/target1/lun0
`-- disc2 -> ../ide/host2/bus0/target0/lun0
Kay
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id\x1278&alloc_id371&op=click
_______________________________________________
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] 10+ messages in thread
* Re: Possible udev bug and some questions
2003-12-24 22:25 Possible udev bug and some questions Martin Schlemmer
` (5 preceding siblings ...)
2003-12-25 20:00 ` Kay Sievers
@ 2003-12-25 21:04 ` Kay Sievers
2003-12-25 21:26 ` Kay Sievers
2003-12-25 22:58 ` Kay Sievers
8 siblings, 0 replies; 10+ messages in thread
From: Kay Sievers @ 2003-12-25 21:04 UTC (permalink / raw)
To: linux-hotplug
On Thu, Dec 25, 2003 at 10:35:37PM +0200, Martin Schlemmer wrote:
> On Thu, 2003-12-25 at 22:00, Kay Sievers wrote:
> > On Thu, Dec 25, 2003 at 09:52:53PM +0200, Martin Schlemmer wrote:
> > > > here is a patch for the script and a small fix for namedev to work with...
> > > >
> > >
> > > BTW, there is a slight issue with your version of the script - it drops
> > > the /dev/discs/part* symlinks. Patch against your version attached.
> >
> > Are you sure devfs does partitions in there?
> > It only lists the discs on my machine:
> >
> > kay@pim:~/src/udev.kay$ tree /devfs/discs/
> > /devfs/discs/
> > |-- disc0 -> ../ide/host0/bus0/target0/lun0
> > |-- disc1 -> ../ide/host0/bus0/target1/lun0
> > `-- disc2 -> ../ide/host2/bus0/target0/lun0
> >
>
> Well, seems like you modified some other things to the script as
> well. Here is a 2.4 box (and we have been using /dev/discs/*/disc
> to call hdparm for ages on 2.4 boxes):
>
> --
> $ ls -l /dev/discs/disc0/
> total 0
> brw------- 1 root root 3, 0 Jan 1 1970 disc
> brw------- 1 root root 3, 1 Jan 1 1970 part1
> brw------- 1 root root 3, 2 Jan 1 1970 part2
> brw------- 1 root root 3, 3 Jan 1 1970 part3
> azarah@gateway azarah $ uname -a
> Linux gateway.lan 2.4.17 #2 Wed Aug 20 22:32:11 SAST 2003 i686 Pentium
> III (Katmai) GenuineIntel GNU/Linux
> azarah@gateway azarah $
What the hell is this?
Is it something in your devfs.conf, that creates this?
On 2.4.20 I get:
puk:~# tree /devfs/discs/
/devfs/discs/
`-- disc0 -> ../ide/host0/bus0/target0/lun0
> Patch is attached to fix the other issue. It is a new version of
> previous patch. Also note that /proc/ide/*/media contain 'disk'
> for hdd's, so the call to get_dev_number() should have 'disk'
> as second argument, and not 'disc' ...
Yes, it should be 'disk' - i'm confused now :)
If you call get_dev_number() with hda1 it will newer break at the current device,
cause there is is no hda1 in the iterated list. So it's ever the last dis[ck]
pim:/home/kay# ls -la /proc/ide/*/media
-r--r--r-- 1 root root 0 Dec 25 21:54 /proc/ide/hda/media
-r--r--r-- 1 root root 0 Dec 25 21:54 /proc/ide/hdb/media
-r--r--r-- 1 root root 0 Dec 25 21:54 /proc/ide/hdc/media
-r--r--r-- 1 root root 0 Dec 25 21:54 /proc/ide/hde/media
thanks,
Kay
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id\x1278&alloc_id371&op=click
_______________________________________________
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] 10+ messages in thread
* Re: Possible udev bug and some questions
2003-12-24 22:25 Possible udev bug and some questions Martin Schlemmer
` (6 preceding siblings ...)
2003-12-25 21:04 ` Kay Sievers
@ 2003-12-25 21:26 ` Kay Sievers
2003-12-25 22:58 ` Kay Sievers
8 siblings, 0 replies; 10+ messages in thread
From: Kay Sievers @ 2003-12-25 21:26 UTC (permalink / raw)
To: linux-hotplug
On Thu, Dec 25, 2003 at 10:04:40PM +0100, Kay Sievers wrote:
> On Thu, Dec 25, 2003 at 10:35:37PM +0200, Martin Schlemmer wrote:
> > On Thu, 2003-12-25 at 22:00, Kay Sievers wrote:
> > > On Thu, Dec 25, 2003 at 09:52:53PM +0200, Martin Schlemmer wrote:
> > > > > here is a patch for the script and a small fix for namedev to work with...
> > > > >
> > > >
> > > > BTW, there is a slight issue with your version of the script - it drops
> > > > the /dev/discs/part* symlinks. Patch against your version attached.
> > >
> > > Are you sure devfs does partitions in there?
> > > It only lists the discs on my machine:
> > >
> > > kay@pim:~/src/udev.kay$ tree /devfs/discs/
> > > /devfs/discs/
> > > |-- disc0 -> ../ide/host0/bus0/target0/lun0
> > > |-- disc1 -> ../ide/host0/bus0/target1/lun0
> > > `-- disc2 -> ../ide/host2/bus0/target0/lun0
Oh, i see these are symlinks. Sorry, I misinterpreted the tree output.
Sure, there is part and disk in there...
Kay
-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills. Sign up for IBM's
Free Linux Tutorials. Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id\x1278&alloc_id371&op=click
_______________________________________________
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] 10+ messages in thread
* Re: Possible udev bug and some questions
2003-12-24 22:25 Possible udev bug and some questions Martin Schlemmer
` (7 preceding siblings ...)
2003-12-25 21:26 ` Kay Sievers
@ 2003-12-25 22:58 ` Kay Sievers
8 siblings, 0 replies; 10+ messages in thread
From: Kay Sievers @ 2003-12-25 22:58 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 1649 bytes --]
On Fri, Dec 26, 2003 at 12:01:41AM +0200, Martin Schlemmer wrote:
> '../ide/host0/bus0/target0/lun0/*' should be the real devices with
> /dev/hd* and /dev/{cdroms,discs}/* the symlinks to 'ide/....'. I just
> cannot see how to do it easy with udev currently - correct me if I am
> wrong.
You're right, sorry for the confusion.
> Here is once again a replacement on that previous
Please have a look at this patch against clean v011.
It seems to work now :)
thanks,
Kay
/udev/
|-- cdroms
| `-- cdrom0 -> ../hdc
|-- discs
| |-- disc0
| | |-- disc -> ../../hda
| | |-- part1 -> ../../hda1
| | |-- part2 -> ../../hda2
| | `-- part4 -> ../../hda4
| |-- disc1
| | |-- disc -> ../../hdb
| | `-- part1 -> ../../hdb1
| `-- disc2
| |-- disc -> ../../hde
| `-- part1 -> ../../hde1
|-- hda
|-- hda1
|-- hda2
|-- hda4
|-- hdb
|-- hdb1
|-- hdc
|-- hde
|-- hde1
`-- ide
|-- host0
| |-- bus0
| | |-- target0
| | | `-- lun0
| | | |-- disc -> ../../../../../hda
| | | |-- part1 -> ../../../../../hda1
| | | |-- part2 -> ../../../../../hda2
| | | `-- part4 -> ../../../../../hda4
| | `-- target1
| | `-- lun0
| | |-- disc -> ../../../../../hdb
| | `-- part1 -> ../../../../../hdb1
| `-- bus1
| `-- target0
| `-- lun0
| `-- cd -> ../../../../../hdc
`-- host2
`-- bus0
`-- target0
`-- lun0
|-- disc -> ../../../../../hde
`-- part1 -> ../../../../../hde1
[-- Attachment #2: 02-ide-devfs.diff --]
[-- Type: text/plain, Size: 1462 bytes --]
diff -Nru a/extras/ide-devfs.sh b/extras/ide-devfs.sh
--- a/extras/ide-devfs.sh Thu Dec 25 23:53:20 2003
+++ b/extras/ide-devfs.sh Thu Dec 25 23:53:20 2003
@@ -2,7 +2,7 @@
# udev CALLOUT script
# return devfs-names for ide-devices
-# CALLOUT, BUS="ide", PROGRAM="/etc/udev/ide-devfs.sh %k %b %n", ID="hd*", NAME="%1c", SYMLINK="%2c"
+# CALLOUT, BUS="ide", PROGRAM="/etc/udev/ide-devfs.sh %k %b %n", ID="hd*", NAME="%1c", SYMLINK="%2c %3c"
HOST=${2%\.[0-9]}
TARGET=${2#[0-9]\.}
@@ -14,14 +14,34 @@
BUS="0"
fi
+get_dev_number() {
+ local x=
+ local num=0
+ local MEDIA=
+ local DRIVE=${1%[0-9]*}
+
+ for x in /proc/ide/*/media; do
+ if [ -e "$x" ]; then
+ MEDIA=`cat $x`
+ if [ "$MEDIA" = "$2" ]; then
+ num=`expr $num + 1`
+ fi
+ if [ "$x" = "/proc/ide/$DRIVE/media" ]; then
+ break
+ fi
+ fi
+ done
+
+ echo `expr $num - 1`
+}
+
if [ -z "$3" ]; then
MEDIA=`cat /proc/ide/$1/media`
if [ "$MEDIA" = "cdrom" ]; then
- echo $1 ide/host$HOST/bus$BUS/target$TARGET/lun0/cd
+ echo $1 ide/host$HOST/bus$BUS/target$TARGET/lun0/cd cdroms/cdrom`get_dev_number $1 cdrom`
elif [ "$MEDIA" = "disk" ]; then
- echo $1 ide/host$HOST/bus$BUS/target$TARGET/lun0/disc
+ echo $1 ide/host$HOST/bus$BUS/target$TARGET/lun0/disc discs/disc`get_dev_number $1 disk`/disc
fi
else
- echo $1 ide/host$HOST/bus$BUS/target$TARGET/lun0/part$3
+ echo $1 ide/host$HOST/bus$BUS/target$TARGET/lun0/part$3 discs/disc`get_dev_number $1 disk`/part$3
fi
-
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2003-12-25 22:58 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-12-24 22:25 Possible udev bug and some questions Martin Schlemmer
2003-12-25 0:19 ` Greg KH
2003-12-25 0:30 ` Greg KH
2003-12-25 10:06 ` Kay Sievers
2003-12-25 18:59 ` Martin Schlemmer
2003-12-25 19:32 ` Kay Sievers
2003-12-25 20:00 ` Kay Sievers
2003-12-25 21:04 ` Kay Sievers
2003-12-25 21:26 ` Kay Sievers
2003-12-25 22: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).