summaryrefslogtreecommitdiff
blob: 4d6cd78c9d37e9b36bf11ef7963e8e1230b3a397 (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
#!/bin/sh
#
# This script should run before doing udevtrigger at boot.
# It will create a rule matching the device directory / is on, and
# creating /dev/root symlink pointing on its device node.
#
# This is especially useful for hal looking at /proc/mounts containing
# a line listing /dev/root as device:
#   /dev/root / reiserfs rw 0 0
# 
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation version 2 of the License.
#
# (c) 2007 Matthias Schwarzott <zzam@gentoo.org>

DEV=$(udevadm info --device-id-of-file=/)
if [ $? = 0 ]; then
	MAJOR="${DEV% *}"
	MINOR="${DEV#* }"

	[ -d /dev/.udev/rules.d ] || mkdir -p /dev/.udev/rules.d
	RULES=/dev/.udev/rules.d/10-root-link.rules

	echo "# Created by /lib/udev/write_root_link_rule" > "${RULES}"
	echo "# This rule should create /dev/root as link to real root device." >> "${RULES}"
	echo "SUBSYSTEM==\"block\", ENV{MAJOR}==\"$MAJOR\", ENV{MINOR}==\"$MINOR\", SYMLINK+=\"root\"" >> "${RULES}"
fi