aboutsummaryrefslogtreecommitdiffstats
path: root/mdev/lib/ttydev
blob: ee31016e62b59f3654c868af2fb2dc25dcdc55a1 (plain)
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
#!/bin/busybox ash

#
# This will work, but it is a useless overhead for every tty
# that might be created. Only use it, if there is really some
# dirty compatibility with udev that won't resolve otherwise!
# You have been warned!
#

# $MDEV
# $ACTION

if [ "${MDEV}" = "console" ] || [ "${MDEV}" = "null" ];
then
	chmod 600 ${MDEV}
fi

CHAR=""
[ -e /sys${DEVPATH}/dev ] && CHAR=$(cat /sys${DEVPATH}/dev)

case "$ACTION" in
	add|"")
		if [ -n "${CHAR}" ];
		then
			mkdir -p char
			cd char
			[ -e "${CHAR}" ] && rm -f ${CHAR}
			ln -s ../${MDEV} ${CHAR}
			cd ..
		fi
		;;
	remove)
		[ -e char/${CHAR} ] && rm -f char/${CHAR}

		if [ -e char ];
		then
			cd char
			SLS=$(ls -l \
				| awk "/..\/${MDEV}/ {print \$9 }")
			for FILE in ${SLS};
			do
				rm -f ${FILE}
			done
			cd ..
			
			rmdir char 2>/dev/null
		fi
		;;
esac

exit 0