diff options
author | Dave Reisner <d@falconindy.com> | 2011-06-04 18:49:32 +0200 |
---|---|---|
committer | Dave Reisner <d@falconindy.com> | 2011-06-07 20:38:43 +0200 |
commit | 5aa2f5872f1f6b391d33875dfe18dcc3a3eaca24 (patch) | |
tree | 435376fa3d6bccd8f150ee5d815097f8cb532065 | |
parent | acf51fb86ff05643f642aaf9588eff8dd3ba88fe (diff) | |
download | mkinitcpio-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>
-rw-r--r-- | init_functions | 14 |
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)" |