aboutsummaryrefslogtreecommitdiffstats
path: root/main/openrc/modloop.initd
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2011-08-24 10:33:53 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2011-08-24 10:35:08 +0000
commit96fe7d3661d0ea57b367d6daad2ea61f82ebeb94 (patch)
tree74eaaaa0c10aaf40ca9ad718299531d9cfec8fbd /main/openrc/modloop.initd
parent5613ea69f5be77c27274e6216dc9b03182da0fd3 (diff)
downloadaports-96fe7d3661d0ea57b367d6daad2ea61f82ebeb94.tar.bz2
aports-96fe7d3661d0ea57b367d6daad2ea61f82ebeb94.tar.xz
main/openrc: fix modloop to find mounts by UUID and LABEL
ref #734
Diffstat (limited to 'main/openrc/modloop.initd')
-rw-r--r--main/openrc/modloop.initd33
1 files changed, 29 insertions, 4 deletions
diff --git a/main/openrc/modloop.initd b/main/openrc/modloop.initd
index 714b6057a3..1a12f6fccd 100644
--- a/main/openrc/modloop.initd
+++ b/main/openrc/modloop.initd
@@ -20,10 +20,35 @@ init_KOPT() {
done
}
+resolve_dev() {
+ case "$1" in
+ UUID=*|LABEL=*) findfs "$1";;
+ *) readlink -f "$1";;
+ esac
+}
+
find_mnt() {
- local dev="$1"
- local fsfile="$2"
- awk "\$ == \"$dev\" {print \$2}\"" "$fsfile" 2>/dev/null
+ local search_dev="$1" fstab="$2"
+ local dev mnt fs mntopts chk
+ case "$search_dev" in
+ UUID=*|LABEL=*|/dev/*);;
+ *) search_dev=/dev/$search_dev;;
+ esac
+ local search_real_dev=$(resolve_dev $search_dev)
+ while read dev mnt fs mntopts chk; do
+ local real_dev=$(resolve_dev $dev)
+ local i j
+ for i in "$search_dev" "$search_real_dev"; do
+ [ -z "$i" ] && continue
+ for j in "$dev" "$real_dev"; do
+ [ -z "$j" ] && continue
+ if [ "$i" = "$j" ]; then
+ echo "$mnt"
+ return
+ fi
+ done
+ done
+ done < $fstab 2>/dev/null
}
# initialies: alpine_dev, alpine_mnt, alpine_fs, alpine_mounted
@@ -34,7 +59,7 @@ find_media() {
alpine_fs=${KOPT_alpine_dev#*:}
[ "$alpine_fs" = "$KOPT_alpine_dev" ] && unset alpine_fs
# first we check if alpine_dev is mounted and use this
- alpine_mnt=$(find_mnt /dev/$alpine_dev /proc/mounts)
+ alpine_mnt=$(find_mnt $alpine_dev /proc/mounts)
if [ -z "$alpine_mnt" ]; then
# then we check fstab
alpine_mnt=$(find_mnt /dev/$alpine_dev /etc/fstab)