linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* 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

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).