aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2009-09-29 09:40:53 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2009-09-29 09:40:53 +0000
commit5572e8a3db95f179b3433e5ea5f8c6fa2c8c65ab (patch)
tree0166ffc980cbef02e0661fb32eaae4b383e1703f
parentf1cce1c16bba49903e0f24a7a3d3c2f1903b324c (diff)
downloadalpine-conf-5572e8a3db95f179b3433e5ea5f8c6fa2c8c65ab.tar.bz2
alpine-conf-5572e8a3db95f179b3433e5ea5f8c6fa2c8c65ab.tar.xz
setup-disk: fix find_disks
The old way did not detect ida/c0d0. The new should detect it. We also filter out md devices.
-rw-r--r--setup-disk.in42
1 files changed, 32 insertions, 10 deletions
diff --git a/setup-disk.in b/setup-disk.in
index d53fba1..33cc868 100644
--- a/setup-disk.in
+++ b/setup-disk.in
@@ -146,25 +146,47 @@ find_swap_size() {
has_mounted_part() {
local p
- # parse /proc/mounts for moutned devices
+ # parse /proc/mounts for mounted devices
for p in $(awk '$1 ~ /^\/dev\// {gsub("/dev/", "", $1); print $1}' \
/proc/mounts); do
- if [ -e /sys/block/$1/$p ]; then
- return 0
- fi
+ [ -e /sys/block/$1/$p ] && return 0
done
return 1
}
+has_holders() {
+ local i
+ # check if device is used by any md devices
+ for i in $1/holders/* $1/*/holders/*; do
+ [ -e "$i" ] && return 0
+ done
+ return 1
+}
+
+is_available_disk() {
+ local dev=$1
+ local b=$(echo $p | sed 's:/:!:g')
+
+ # check if its a "root" block device and not a partition
+ [ -e /sys/block/$b ] || return 1
+
+ # check so it does not have mounted partitions
+ has_mounted_part $dev && return 1
+
+ # check so its not part of an md setup
+ has_holders /sys/block/$b && return 1
+
+ # check so its not an md device
+ [ -e /sys/block/$b/md ] && return 1
+
+ return 0
+}
+
find_disks() {
- local p= disks=
+ local p=
for p in $(awk '$1 ~ /[0-9]+/ {print $4}' /proc/partitions); do
- b=$(echo $p | sed 's:/:!:g')
- if [ -e /sys/block/$b/device ] && ! has_mounted_part $p; then
- disks="$disks $p"
- fi
+ is_available_disk $p && echo -n " $p"
done
- echo $disks
}
useall() {