]> git.pld-linux.org Git - packages/systemd.git/blame - start_udev
- updated
[packages/systemd.git] / start_udev
CommitLineData
05149ed5
AM
1#!/bin/sh
2#
3# start_udev
4#
5# script to initialize /dev by using udev.
6#
7# Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com>
8#
9# Released under the GPL v2 only.
10#
11# This needs to be run at the earliest possible point in the boot
12# process.
13#
14# Based on the udev init.d script
15#
16# Thanks go out to the Gentoo developers for proving
17# that this is possible to do.
18#
19# Yes, it's very verbose, feel free to turn off all of the echo calls,
20# they were there to make me feel better that everything was working
21# properly during development...
22#
23# don't use udev if sysfs is not mounted.
24[ ! -d $sysfs_dir/class ] || exit 1
25[ -r /proc/mounts ] || exit 1
26[ -x /sbin/udev ] || exit 1
27[ -f /etc/udev/udev.conf ] && . /etc/udev/udev.conf
28
29
401263e1 30. /etc/rc.d/init.d/functions
05149ed5
AM
31
32prog=udev
33sysfs_dir=/sys
34bin=/sbin/udev
35udevd=/sbin/udevd
36MAKEDEV="/sbin/MAKEDEV"
37
38make_extra_nodes () {
39 ln -snf /proc/self/fd $udev_root/fd
40 ln -snf /proc/self/fd/0 $udev_root/stdin
41 ln -snf /proc/self/fd/1 $udev_root/stdout
42 ln -snf /proc/self/fd/2 $udev_root/stderr
43 ln -snf /proc/kcore $udev_root/core
44
45 [ -d $udev_root/pts ] || (mkdir $udev_root/pts;chmod 0755 $udev_root/pts)
46 [ -d $udev_root/shm ] || (mkdir $udev_root/shm;chmod 0755 $udev_root/shm)
47
48 if [ -x $MAKEDEV ]; then
49 $MAKEDEV -x $(
05149ed5
AM
50 for i in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
51 echo cpu/$i/microcode;
52 done;
6ba94d68
AM
53 for i in 1 2 3 4 5 6; do echo tty$i;done;
54 for i in 0 1 2 3 4 5 6 7; do echo loop$i; done;
55 for i in 0 1 2 3; do echo lp$i; echo par$i;done;
56 echo net/tun ppp console null zero;
05149ed5
AM
57 );
58 [ -a /dev/MAKEDEV ] || ln -s $MAKEDEV /dev/MAKEDEV;
6ba94d68 59 cp -a /etc/udev/devices/* /dev/ >/dev/null 2>&1 || :
05149ed5
AM
60 fi
61}
62
6ba94d68
AM
63# we cannot use /usr/bin/find here
64find_d () {
65 where=$1
66 what=$2
67 found=""
68 for f in $where/*; do
69 if [ -d "$f" -a ! -L "$f" ]; then
70 if [ "$f" != "${f%%$what}" ];then
71 # make sure we are at the path end
72 # we have no dirname and basename
73 rest="${f#*$what}"
74 [ "${rest##*/}" = "$rest" ] && found="$found $f"
75 fi
76 found="$found $(find_d $f $what)"
77 fi
78 done
79 echo "$found"
05149ed5
AM
80}
81
6ba94d68
AM
82# we cannot use /usr/bin/find here
83find_f () {
84 where=$1
85 what=$2
86 found=""
87 for f in $where/*; do
88 if [ -d "$f" -a ! -L "$f" ]; then
89 found="$found $(find_f $f $what)"
90 elif [ -e "$f" ]; then
91 [ "$f" != "${f%$what}" ] && found="$found $f"
92 fi
93 done
94 echo "$found"
05149ed5 95}
05149ed5 96
6ba94d68
AM
97# call hotplug with the scsi devices
98scsi_replay () {
99 HOTPLUG=$(cat /proc/sys/kernel/hotplug)
100 [ -z "$HOTPLUG" ] && return 1
101
102 scsi_hosts=$(find_d /sys/devices host\*)
103 SEQNUM=1
104
105 for host in $scsi_hosts; do
106 [ -d $host ] || continue
107 devs=$(find_f $host type)
108 for dev in $devs;do
109 [ -f $dev ] || continue
110 export SEQNUM
111 DEVPATH=${dev%/type}
112 DEVPATH=${DEVPATH#/sys}
113 export DEVPATH
114 export ACTION=add
115 $HOTPLUG scsi_device
e993d7ee 116 SEQNUM=$(($SEQNUM + 1))
6ba94d68 117 $HOTPLUG scsi
e993d7ee 118 SEQNUM=$(($SEQNUM + 1))
6ba94d68
AM
119 done
120 done
121 return 0
122}
05149ed5
AM
123
124export ACTION=add
125export UDEV_NO_SLEEP=1
6ba94d68
AM
126prog=udev
127ret=0
128nls "Starting udev"
05149ed5 129# propagate $udev_root from /sys
6ba94d68
AM
130grep -q "none ${udev_root%/} " /proc/mounts || {
131 mount -n -o mode=0755 -t tmpfs none "$udev_root"
132 ret=$(($ret + $?))
133}
134make_extra_nodes
135scsi_replay >/dev/null 2>&1
136ret=$(($ret + $?))
05149ed5 137rm -f $udev_root/.udev.tdb
6ba94d68
AM
138/sbin/udevstart
139ret=$(($ret + $?))
140[ $ret -eq 0 ] && ok || fail
05149ed5 141exit 0
This page took 0.043669 seconds and 4 git commands to generate.