summaryrefslogtreecommitdiffstats
path: root/init_functions
diff options
context:
space:
mode:
authorThomas Bächler <thomas@archlinux.org>2010-02-20 18:28:21 +0100
committerThomas Bächler <thomas@archlinux.org>2010-02-20 18:28:21 +0100
commit568e4aa7b19c388de3ebc9c651996d1b577c3f09 (patch)
treee66ff83bfce8b00497a05469e7564248a49da3f9 /init_functions
parent28496fc955d0652ac2ab342d985247fdf9c2e72c (diff)
downloadmkinitcpio-568e4aa7b19c388de3ebc9c651996d1b577c3f09.tar.gz
mkinitcpio-568e4aa7b19c388de3ebc9c651996d1b577c3f09.tar.xz
default_mount_hook: Use major and minor variables instead of a single rootdev variable
This is nicer and more explicit than before, based on a patch by Benjamin Richter
Diffstat (limited to 'init_functions')
-rw-r--r--init_functions16
1 files changed, 9 insertions, 7 deletions
diff --git a/init_functions b/init_functions
index 1258aff..45ca896 100644
--- a/init_functions
+++ b/init_functions
@@ -31,31 +31,33 @@ launch_interactive_shell() {
default_mount_handler() {
if [ ${root:0:5} != "/dev/" ] || ! poll_device "${root}" ${rootdelay}; then
msg "Root device '${root}' doesn't exist. Attempting to create it."
- rootdev=""
+ major=""
+ minor=""
if [ ${root:0:5} = "/dev/" ]; then
# It might be a block device (/dev/sda) -> /sys/block/sda/dev
# or a partition (/dev/sda1) -> /sys/block/sda/sda1/dev
for dir in /sys/block /sys/block/*; do
if [ -f ${dir}/${root:5}/dev ]; then
- rootdev="$(cat ${dir}/${root:5}/dev | sed 's|:| |')"
+ major="$(cat ${dir}/${root:5}/dev | cut -d: -f1)"
+ minor="$(cat ${dir}/${root:5}/dev | cut -d: -f2)"
break
fi
done
# It might be a major/minor pair (8:1)
elif echo ${root} | grep -q :; then
- rootdev="$(echo ${root} | sed 's|:| |')"
+ major="$(echo ${root} | cut -d: -f1)"
+ minor="$(echo ${root} | cut -d: -f2)"
root="/dev/root"
# It might be major/minor encoded as a single hex-number (lilo-style) (801)
elif [ ${#root} -le 4 -a ${#root} -gt 2 ] && echo "${root}" | grep -qe '^[A-Fa-f0-9]*$'; then
str_offset=$((${#root}-2))
major=$((0x${root:0:${str_offset}}))
minor=$((0x${root:${str_offset}}))
- rootdev="${major} ${minor}"
root="/dev/root"
fi
- if [ -n "${rootdev}" ]; then
- msg "Creating root device ${root} with major $(echo "${rootdev}" | cut -d\ -f1) and minor $(echo "${rootdev}" | cut -d\ -f2)."
- mknod ${root} b ${rootdev}
+ if [ -n "${major}" -a -n "${minor}" ]; then
+ msg "Creating root device ${root} with major ${major} and minor ${minor}."
+ mknod ${root} b ${major} ${minor}
else
err "Unable to determine major/minor number of root device '${root}'."
echo "You are being dropped to a recovery shell"