]> git.ipfire.org Git - thirdparty/systemd.git/blame - extras/start_udev
[PATCH] cleanup udevd/udevstart
[thirdparty/systemd.git] / extras / start_udev
CommitLineData
b9e3301c 1#! /bin/sh
2152332e
GKH
2#
3# start_udev
4#
5# script to initialize /dev by using udev.
6#
7fdc5cb4
GKH
7# Copyright (C) 2004 Greg Kroah-Hartman <greg@kroah.com>
8#
9# Released under the GPL v2 only.
10#
2152332e
GKH
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#
7fdc5cb4
GKH
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#
2152332e
GKH
23
24. /etc/udev/udev.conf
25
26prog=udev
27sysfs_dir=/sys
28bin=/sbin/udev
29udevd=/sbin/udevd
30
31run_udev () {
a4f5eb03 32 export ACTION=add
a4f5eb03 33
2152332e
GKH
34 # handle block devices and their partitions
35 for i in ${sysfs_dir}/block/*; do
36 # add each drive
37 export DEVPATH=${i#${sysfs_dir}}
38 echo "$DEVPATH"
39 $bin block
40
41 # add each partition, on each device
42 for j in $i/*; do
43 if [ -f $j/dev ]; then
44 export DEVPATH=${j#${sysfs_dir}}
45 echo "$DEVPATH"
46 $bin block
47 fi
48 done
49 done
50 # all other device classes
51 for i in ${sysfs_dir}/class/*; do
52 for j in $i/*; do
53 if [ -f $j/dev ]; then
54 export DEVPATH=${j#${sysfs_dir}}
55 CLASS=`echo ${i#${sysfs_dir}} | \
56 cut --delimiter='/' --fields=3-`
57 echo "$DEVPATH"
58 $bin $CLASS
59 fi
60 done
61 done
62 return 0
63}
64
65make_extra_nodes () {
66 # there are a few things that sysfs does not export for us.
67 # these things go here (and remember to remove them in
68 # remove_extra_nodes()
69 #
70 # Thanks to Gentoo for the initial list of these.
71 ln -snf /proc/self/fd $udev_root/fd
72 ln -snf /proc/self/fd/0 $udev_root/stdin
73 ln -snf /proc/self/fd/1 $udev_root/stdout
74 ln -snf /proc/self/fd/2 $udev_root/stderr
75 ln -snf /proc/kcore $udev_root/core
76
77 mkdir $udev_root/pts
78 mkdir $udev_root/shm
79}
80
81# don't use udev if sysfs is not mounted.
82if [ ! -d $sysfs_dir/block ]; then
83 exit 1
84fi
85
86echo "mounting... ramfs at $udev_root"
87mount -n -t ramfs none $udev_root
88
2152332e 89# propogate /udev from /sys
2152332e 90echo "Creating initial udev device nodes:"
27abdb46
GKH
91
92# You can use the shell scripts above by calling run_udev or execute udevstart
93# which does the same thing, but much faster by not using shell.
94# only comment out one of the following lines.
95#run_udev
96/sbin/udevstart
2152332e
GKH
97
98echo "making extra nodes"
99make_extra_nodes
100
101echo "udev startup is finished!"
102exit 0