1 |
#!/bin/sh |
#!/bin/sh |
2 |
# $Header: /root/magellan-cvs/src/udev/write_root_link_rule.sh,v 1.1 2008-03-22 18:13:36 niro Exp $ |
# $Header: /root/magellan-cvs/src/udev/write_root_link_rule.sh,v 1.2 2008-12-22 20:30:09 niro Exp $ |
3 |
# |
# |
4 |
# This script should run before doing udevtrigger at boot. |
# This script should run before doing udevtrigger at boot. |
5 |
# It will create a rule matching the device directory / is on, and |
# It will create a rule matching the device directory / is on, and |
13 |
# under the terms of the GNU General Public License as published by the |
# under the terms of the GNU General Public License as published by the |
14 |
# Free Software Foundation version 2 of the License. |
# Free Software Foundation version 2 of the License. |
15 |
# |
# |
16 |
# (c) 2007 Matthias Schwarzott <zzam@gentoo.org> |
# (c) 2007-2008 Matthias Schwarzott <zzam@gentoo.org> |
17 |
|
|
18 |
DEV=$(udevadm info --device-id-of-file=/) |
eval $(udevadm info --export --export-prefix="ROOT_" --device-id-of-file=/) |
|
if [ $? = 0 ]; then |
|
|
MAJOR="${DEV% *}" |
|
|
MINOR="${DEV#* }" |
|
19 |
|
|
20 |
[ -d /dev/.udev/rules.d ] || mkdir -p /dev/.udev/rules.d |
[ $? = 0 ] || exit 0 |
21 |
RULES=/dev/.udev/rules.d/10-root-link.rules |
[ "$ROOT_MAJOR" = 0 ] && exit 0 |
22 |
|
|
23 |
echo "# Created by /lib/udev/write_root_link_rule" > "${RULES}" |
DIR=/dev/.udev/rules.d |
24 |
echo "# This rule should create /dev/root as link to real root device." >> "${RULES}" |
[ -d "$DIR" ] || mkdir -p "$DIR" |
25 |
echo "SUBSYSTEM==\"block\", ENV{MAJOR}==\"$MAJOR\", ENV{MINOR}==\"$MINOR\", SYMLINK+=\"root\"" >> "${RULES}" |
RULES=$DIR/10-root-link.rules |
26 |
fi |
|
27 |
|
echo "# Created by /lib/udev/write_root_link_rule" > "${RULES}" |
28 |
|
echo "# This rule should create /dev/root as link to real root device." >> "${RULES}" |
29 |
|
echo "SUBSYSTEM==\"block\", ENV{MAJOR}==\"$ROOT_MAJOR\", ENV{MINOR}==\"$ROOT_MINOR\", SYMLINK+=\"root\"" >> "${RULES}" |