Hello,

some my statements in Part 1 were wrong.

1) I said OK to this rule:

ENV{MODALIAS}=="?*",    RUN+="/sbin/modprobe $env{MODALIAS}"

Unfortunately, due to udev (and kernel?) bug, this doesn't work for
input devices even with 2.6.15 + gregkh patch. A working configuration
requires patching udev to accept a comma (",") as a trusted character in
sysfs attribute values. Patch is attached.

Then, the rule has to be rewritten as:

SYSFS{modalias}=="?*", RUN+="/sbin/modprobe $sysfs{modalias}"

Otherwise, udev looks at the wrong modalias for input devices.

2) I said OK to the following piece of the initscript:

          list=$(echo /sys/bus/*/devices/*/uevent)
          list="$list $(echo /sys/class/*/*/uevent)"
          list="$list $(echo /sys/block/*/uevent /sys/block/*/*/uevent)"

The following line should be added for input subdevices to work in
certain semi-non-modular configurations:

          list="$list $(echo /sys/class/*/*/*/uevent)"

With those changes, it is indeed possible to kill the input.sh hack and
its rule.

3) I forgot to say that, after commenting out udevstart, you may get some errors due to /dev/null not being available. Avoid them by issuing the following commands:

mknod -m 0666 /lib/udev/devices/null c 1 3
mknod -m 0600 /lib/udev/devices/console c 5 1

4) Also, I promised to talk about debugging.

I have a suspicion that the current waiting procedure is not good
enough, and an uevent can slip through. I ask all who will test Jim's
package to compile the test program:

gcc -o /lib/udev/bug bug.c

This program will append the whole uevent environment to the /dev/bug
file if it exists and the event is not related to known slow busses.
The compiled program is used instead of a shell script in order to
minimize timing differences between situations with and without the
program. Then, add the following rule to the end of 05-udev-early.rules:

RUN+="bug"

and replace the udev initscript with the attached one. Then reboot a few
times.

If the initscript tells you to report a bug, please do so. My statement
about unbootable system is VERY serious. I did have some uevents in the
/dev/bugreport file, all of them were USB-related. In order to avoid
SPAM, in the attached version of bug.c I disabled reporting of all USB
and IEEE1394 uevents that unexpectedly get past the loop.

To Matthew Burgess: this "bug.c" test also applies to you if you
implement hotplug removal independently.

--
Alexander E. Patrakov
Don't mail to [EMAIL PROTECTED]: the server is off until 2006-01-11
Use my GMail or linuxfromscratch address instead
Submitted By: Alexander E. Patrakov
Date: 2006-01-06
Initial Package Version: 079
Upstream Status: Not submitted yet, need confirmation from Jim Gifford
Origin: Alexander E. Patrakov
Description: Allows a comma in sysfs attribute values.
Needed for loading input modules properly.

--- udev-079/udev_utils_string.c	2005-12-22 23:51:30.000000000 +0000
+++ udev-079/udev_utils_string.c	2006-01-06 17:32:51.000000000 +0000
@@ -245,7 +245,7 @@
 		if ((str[i] >= '0' && str[i] <= '9') ||
 		    (str[i] >= 'A' && str[i] <= 'Z') ||
 		    (str[i] >= 'a' && str[i] <= 'z') ||
-		    strchr(" #$%+-./:[EMAIL PROTECTED]", str[i])) {
+		    strchr(" #$%+-./:[EMAIL PROTECTED],", str[i])) {
 			i++;
 			continue;
 		}


#define _GNU_SOURCE
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <argz.h>

int main(int argc, char * argv[])
{
	char * envz;
	char * devpath;
	size_t len;
	int bug;
	devpath = getenv("DEVPATH");
	if (devpath) {
		/* Avoid SPAM on the list.
		   USB and IEEE1394 are known troublemakers.
		 */
		if (strstr(devpath, "usb"))
			return 0;
		if (strstr(devpath, "1394"))
			return 0;
	}
	devpath = getenv("PHYSDEVPATH");
	if (devpath) {
		if (strstr(devpath, "usb"))
			return 0;
		if (strstr(devpath, "1394"))
			return 0;
	}
	bug = open("/dev/bug", O_WRONLY | O_APPEND);
	if (bug == -1)
		return 0;
	setenv("_SEPARATOR", "--------------------------------------", 1);
	argz_create(environ, &envz, &len);
	argz_stringify(envz, len, '\n');
	envz[len-1]='\n';
	write(bug, envz, len);
	close(bug);
	free(envz);
	return 0;
}

#!/bin/sh
########################################################################
# Begin $rc_base/init.d/udev
#
# Description : Udev Boot Script
#
# Authors     : Based on Open Suse Udev Rules
#               [EMAIL PROTECTED]
#
# Adapted to  : Jim Gifford
# LFS
#
# Version     : 00.00
#
# Notes       :
#
########################################################################

. /etc/sysconfig/rc
. ${rc_functions}

trigger_device_events() {
        # generate events with the sysfs trigger
        list=$(echo /sys/bus/*/devices/*/uevent)
        list="$list $(echo /sys/class/*/*/uevent)"
        list="$list $(echo /sys/class/*/*/*/uevent)"
        list="$list $(echo /sys/block/*/uevent /sys/block/*/*/uevent)"
        for i in $list; do
            case "$i" in
                */device/uevent|*\**)
                    # skip followed device symlinks
                    continue
                    ;;

                */class/mem/*|*/class/tty/*)
                    first="$first $i"
                    ;;

                */block/md*)
                    last="$last $i"
                    ;;

                */*)
                    default="$default $i"
                    ;;
            esac
        done

        # trigger the sorted events
        for i in $first $default $last; do
            echo "add" > "$i"
        done
}

case "$1" in
    start)
        boot_mesg "Creating /dev in tmpfs..."
        mount -n -t tmpfs tmpfs /dev -o mode=755,size=4M
        evaluate_retval

        boot_mesg "Copying static entries..."
        cp -ar /lib/udev/devices/* /dev
        evaluate_retval

#       boot_mesg "Executing udevstart..."
#       udevstart
#       evaluate_retval

        # disable hotplug helper, udevd listens to netlink
        echo "" > /proc/sys/kernel/hotplug

        # start udevd
        boot_mesg "Starting udevd..."
        /sbin/udevd --daemon
        evaluate_retval

        # cleanup some stuff
#       rm -f /var/run/sysconfig/network
#       rm -rf /events/*

        # start coldplugging
        boot_mesg "Performing Coldplugging..."

        # unlikely, but we may be faster than the first event
        mkdir -p /dev/.udev/queue

        # configure all devices
        trigger_device_events

        # until we know how to do better, just wait for _all_ events to finish
        loop=300
        while test -d /dev/.udev/queue; do
            sleep 0.1;
            test "$loop" -gt 0 || break
            loop=$(($loop - 1))
        done
        >/dev/bug
        test "$loop" -gt 0
        evaluate_retval
        sleep 2
        if test -s /dev/bug; then
            mv /dev/bug /dev/bugreport
            boot_mesg "Please mail the contents of /dev/bugreport to 
lfs-dev@linuxfromscratch.org" ${WARNING}
            boot_mesg "Otherwise, the next version of LFS will be unbootable on 
your system!"
            echo_failure
            sleep 10
        else
            rm -f /dev/bug
        fi
        ;;

    stop)
        boot_mesg "Stopping udevd..."
        echo "/sbin/hotplug" > /proc/sys/kernel/hotplug
        killproc /sbin/udevd
        ;;

    restart)
        boot_mesg "Restarting udevd..."
        killproc /sbin/udevd
        loadproc /sbin/udevd --daemon
        evaluate_retval
        ;;

    status)
        statusproc /sbin/udevd
        ;;

    reload)
        boot_mesg "Reloading udev rules..."
        udevcontrol reload_rules
        cp --preserve=all --recursive --update /lib/udev/devices/* /dev
        evaluate_retval
        ;;

    force-reload)
        boot_mesg "Updating all available device nodes in /dev..."
        udevcontrol reload_rules
        rm -rf /dev/.udev /dev/disk
        cp --preserve=all --recursive --update /lib/udev/devices/* /dev
        trigger_device_events
        evaluate_retval
        ;;

    *)
        echo "Usage: $0 {start|stop|restart|status|reload|force-reload}"
        exit 1
        ;;
esac

-- 
http://linuxfromscratch.org/mailman/listinfo/lfs-dev
FAQ: http://www.linuxfromscratch.org/faq/
Unsubscribe: See the above information page

Reply via email to