File: init-dev

package info (click to toggle)
userdevfs 0.13
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 216 kB
  • ctags: 1
  • sloc: sh: 135; makefile: 47
file content (74 lines) | stat: -rwxr-xr-x 1,599 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/sh

if [ ! -z "$1" ]; then
	ROOT="$1"
else
	ROOT=""
fi

DMESG='/var/log/dmesg'
if [ ! -f $DMESG ]; then
	dmesg > $DMESG
fi

if [ ! -d $ROOT/dev/vc ]; then
	echo '  Creating Virtual Console devices ...'
	mkdir -p $ROOT/dev/vc
	for i in 0 1 2 3 4 5; do
		mknod $ROOT/dev/vc/$i c 4 $i
	done
fi

if [ ! -d $ROOT/dev/loop ]; then
	echo '  Creating loopback devices ...'
	mkdir -p $ROOT/dev/loop
	for i in 0 1 2 3; do
		mknod $ROOT/dev/loop/$i b 7 $i 
	done
fi
	
if [ ! -d $ROOT/dev/floppy ]; then
	echo '  Creating floppy device(s) ...'
	mkdir -p $ROOT/dev/floppy
	mknod $ROOT/dev/floppy/0 b 2 0
fi

if [ ! -d $ROOT/dev/cdroms ]; then
	echo '  Creating cdrom devices ...'
	mkdir -p $ROOT/dev/cdroms

	IDECDROM=`grep -i cdrom $DMESG | grep -i ide | cut -d: -f 1`
	if [ "" != "$IDECDROM" ]; then
		CNT=0
		for i in $IDECDROM; do
			if [ ! -b $ROOT/dev/$i ]; then
				case $i in
				"hda") mknod $ROOT/dev/hda b 3 0 ;;
				"hdb") mknod $ROOT/dev/hdb b 3 64 ;;
				"hdc") mknod $ROOT/dev/hdc b 22 0 ;;
				"hdd") mknod $ROOT/dev/hdd b 22 64 ;;
				*)
					echo "Undefined IDE CDROM: $IDECDROM"
				esac
			fi
			ln -sf $ROOT/dev/$i /dev/cdroms/cdrom$CNT
			CNT=$(($CNT+1))
		done
	fi

	SCSICDROM=`grep -i detected $DMESG | grep -i scsi | \
		grep -i cd-rom | cut -d' ' -f 4 | sed -e 's/sr/scd/'`
	if [ "" != "$SCSICDROM" ]; then
		CNT=0
		for i in $SCSICDROM; do
			if [ ! -b $ROOT/dev/$i ]; then
				mknod $ROOT/dev/$i b 11 $CNT
			fi
			ln -sf $ROOT/dev/$i $ROOT/dev/cdroms/cdrom$CNT
			CNT=$(($CNT+1))
		done
		if [ ! -e $ROOT/dev/cdrom ]; then
			ln -sf $ROOT/dev/scd0 $ROOT/dev/cdrom
		fi
	fi
fi