summaryrefslogtreecommitdiffstats
path: root/init_functions
diff options
context:
space:
mode:
authorBenjamin Richter <br@waldteufel-online.net>2010-02-17 15:12:19 +0100
committerThomas Bächler <thomas@archlinux.org>2010-02-20 16:08:50 +0100
commit3bd7dd1a022b29c35287ce82c19c2da239b4251a (patch)
treea2cfe2e9fd0b0d8b5caa9ac98c38acb63e02cab2 /init_functions
parent722d99d81a57a7f1737c028ae0170b33676db5d8 (diff)
downloadmkinitcpio-3bd7dd1a022b29c35287ce82c19c2da239b4251a.tar.gz
mkinitcpio-3bd7dd1a022b29c35287ce82c19c2da239b4251a.tar.xz
Use only a single loop for searching /sys/block
Diffstat (limited to 'init_functions')
-rw-r--r--init_functions20
1 files changed, 8 insertions, 12 deletions
diff --git a/init_functions b/init_functions
index c84fa65..ebdb468 100644
--- a/init_functions
+++ b/init_functions
@@ -33,18 +33,14 @@ default_mount_handler() {
msg "\nRoot device '${root}' doesn't exist. Attempting to create it."
rootdev=""
if [ ${root:0:5} = "/dev/" ]; then
- # It might be a block device (/dev/sda)
- if [ -f /sys/block/${root:5}/dev ]; then
- rootdev="$(cat /sys/block/${root:5}/dev | sed 's|:| |')"
- # It might be a partition on any block device (/dev/sda1)
- else
- for dir in /sys/block/*; do
- if [ -f ${dir}/${root:5}/dev ]; then
- rootdev="$(cat ${dir}/${root:5}/dev | sed 's|:| |')"
- break
- fi
- done
- fi
+ # 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|:| |')"
+ break
+ fi
+ done
# It might be a major/minor pair (8:1)
elif echo ${root} | grep -q :; then
rootdev="$(echo ${root} | sed 's|:| |')"