From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Marco d'Itri" Date: Sat, 21 Feb 2004 22:20:36 +0000 Subject: updated init script Message-Id: <20040221222036.GA9441@wonderland.linux.it> MIME-Version: 1 Content-Type: multipart/mixed; boundary="HcAYCG3uE/tztfnV" List-Id: To: linux-hotplug@vger.kernel.org --HcAYCG3uE/tztfnV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline I'm attaching the new init script I wrote for the debian package[1], in the hope it will be useful to other distributions (again, please do not just distribute it with the package, it will do not good to debian users). I introduced a new config file which lists symlinks, directories and devices which cannot be created by udev (a notable example being /dev/ppp and probably the tun/tap devices). The script will also bind-mount the old /dev somewhere else, to allow MAKEDEV to still update it. (I think this will be needed at least until udev will continue to be an optional component of the distribution.) [1] which is currently waiting to be approved by the ftpmasters before entering the distribution, FYI. -- ciao, | Marco | [4698 pryzWZsHITiM6] --HcAYCG3uE/tztfnV Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=udev #!/bin/sh -e PATH="/sbin:/bin" UDEV=/sbin/udev . /etc/udev/udev.conf [ -x $UDEV ] || exit 0 case "$(uname -r)" in 2.[012345].*) echo "udev requires a 2.6.x kernel, not started." exit 0 ;; esac export UDEV_NO_SLEEP=1 export ACTION DEVPATH ############################################################################## # FIXME see README.Debian mount_sysfs() { [ -d /sys ] || mkdir /sys [ -d /sys/class ] || mount -t sysfs sysfs: /sys [ -d /proc/1 ] || mount -n /proc } # FIXME see README.Debian umount_proc() { umount -n /proc } mount_ramfs() { if grep -E -q "^none /u?dev ramfs" /proc/mounts; then return 0 fi mkdir -p /etc/udev/.dev mount --bind /dev /etc/udev/.dev echo -n "Mounting ramfs over $udev_root..." mount -n -t ramfs none $udev_root echo "done." } # We must manually create /dev/null because the shell needs it for "&". # If we were using initramfs the kernel would create it for us. create_dev_null() { [ -c $udev_root/null ] || mknod --mode=666 $udev_root/null c 1 3 } synthesize_events() { # add tty devices and all other device classes for i in /sys/class/*; do [ -d "$i" ] || continue for j in $i/*; do [ -f "$j/dev" ] || continue DEVPATH=${j#/sys} class=${DEVPATH#/class/} class=${class%/*} # echo -n " $DEVPATH($class)" $UDEV $class || echo -n " failed: $DEVPATH" done done # add block devices and their partitions for i in /sys/block/*; do [ -d "$i" ] || continue DEVPATH=${i#/sys} # echo -n " $DEVPATH" $UDEV block || echo -n " failed: $DEVPATH" for j in $i/*; do [ -f "$j/dev" ] || continue DEVPATH=${j#/sys} # echo -n " $DEVPATH" $UDEV block || echo -n " failed: $DEVPATH" done done return 0 } make_extra_nodes () { grep '^[^#]' /etc/udev/links.conf | \ while read type name arg1; do [ "$type" -a "$name" \ -a ! -e "$udev_root/$name" -a ! -L "$udev_root/$name" ] || continue case "$type" in L) ln -s $arg1 $udev_root/$name ;; D) mkdir -p $udev_root/$name ;; M) cd /dev /sbin/MAKEDEV $name ;; *) echo "unparseable line ($type $name $arg1)" ;; esac done } ############################################################################## case "$1" in start) mount_sysfs mount_ramfs create_dev_null # We want to start udevd ourselves if it isn't already running. # This lets udevd run at a sane nice level... udevd & ACTION=add echo -n "Creating initial udev device nodes..." synthesize_events make_extra_nodes umount_proc echo "done." ;; stop) # ACTION=remove # echo -n "Removing udev device nodes..." # synthesize_events # echo "done." # XXX users are not supposed to run this killall udevd umount /etc/udev/.dev umount /dev ;; restart|force-reload) echo -n "Creating again udev device nodes..." ACTION=add synthesize_events make_extra_nodes echo "done." ;; *) echo "Usage: /etc/init.d/udev {start|stop|restart|force-reload}" exit 1 ;; esac exit 0 --HcAYCG3uE/tztfnV Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="links.conf" # This file contains a list of symbolic links and directories which need # to be created in /dev/. L fd /proc/self/fd L stdin /proc/self/fd/0 L stdout /proc/self/fd/1 L stderr /proc/self/fd/2 L core /proc/kcore L sndstat /proc/asound/oss/sndstat L MAKEDEV /sbin/MAKEDEV-wrapper D pts D shm # I know, this is ugly, but I do not have a better solution. M ppp --HcAYCG3uE/tztfnV Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=MAKEDEV-wrapper #!/bin/sh -e # make /dev/MAKEDEV operate on the real /dev # credits for this hack goes to ElectricElf if [ "`pwd`" = /dev -a -d /etc/udev/.dev ]; then cd /etc/udev/.dev fi exec /sbin/MAKEDEV "$*" --HcAYCG3uE/tztfnV-- ------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id=3438&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