summaryrefslogtreecommitdiffstats
path: root/init_functions
diff options
context:
space:
mode:
authorDave Reisner <d@falconindy.com>2011-06-04 18:49:32 +0200
committerDave Reisner <d@falconindy.com>2011-06-07 20:38:43 +0200
commit5aa2f5872f1f6b391d33875dfe18dcc3a3eaca24 (patch)
tree435376fa3d6bccd8f150ee5d815097f8cb532065 /init_functions
parentacf51fb86ff05643f642aaf9588eff8dd3ba88fe (diff)
downloadmkinitcpio-5aa2f5872f1f6b391d33875dfe18dcc3a3eaca24.tar.gz
mkinitcpio-5aa2f5872f1f6b391d33875dfe18dcc3a3eaca24.tar.xz
init_functions: simplify mount case of root=/dev/*
/sys/class/block contains all of our block devices, including the partitions of each parent block device, so directly check for the existance of the dev file rather than looping. Signed-off-by: Dave Reisner <d@falconindy.com>
Diffstat (limited to 'init_functions')
-rw-r--r--init_functions14
1 files changed, 5 insertions, 9 deletions
diff --git a/init_functions b/init_functions
index d9ffe4a..a94f525 100644
--- a/init_functions
+++ b/init_functions
@@ -87,15 +87,11 @@ default_mount_handler() {
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
- 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 block device (/dev/sda) -> /sys/class/block/sda/dev
+ if [ -e /sys/class/block/${root:5}/dev ]; then
+ IFS=':' read major minor < "/sys/class/block/${root:5}/dev"
+ break
+ fi
# It might be a major/minor pair (8:1)
elif echo ${root} | grep -q :; then
major="$(echo ${root} | cut -d: -f1)"