diff --git a/common.sh b/common.sh index cc7a335..820caea 100644 --- a/common.sh +++ b/common.sh @@ -326,3 +326,26 @@ umount() { fi } +list_mounts() { + if [ -f /proc/self/mountinfo ]; then + local x dev mount devs found mountinfo_placeholders + found=: + + # mountinfo may have 10 or 11 fields depending on mount namespaces + if [ $(head -n1 /proc/self/mountinfo | wc -w) == 10 ]; then + mountinfo_placeholders="x x" + else + mountinfo_placeholders="x x x" + fi + + while read -r x x dev x mount ${mountinfo_placeholders} fs x; do + if [ -L "/sys/dev/block/$dev" ]; then + devs="/dev/`readlink \"/sys/dev/block/$dev\" | rev | cut -d/ -f1 | rev`" + printf '%s %s %s\n' "$(mapdevfs "$devs")" "$mount" "$fs" + found="return 0" + fi + done < /proc/self/mountinfo + $found + fi + grep "^/dev/" /proc/mounts | parse_proc_mounts +} diff --git a/linux-boot-prober b/linux-boot-prober index bacf219..804d9fe 100755 --- a/linux-boot-prober +++ b/linux-boot-prober @@ -17,7 +17,7 @@ bootmnt= bootsv= bootuuid= -grep "^/dev/" /proc/mounts | parse_proc_mounts >"$OS_PROBER_TMP/mounted-map" || true +list_mounts >"$OS_PROBER_TMP/mounted-map" || true if [ -z "$1" ]; then ERR=y diff --git a/os-prober b/os-prober index b76d85b..8b0c89b 100755 --- a/os-prober +++ b/os-prober @@ -128,7 +128,7 @@ done # We need to properly canonicalize partitions with mount points and partitions # used in RAID -grep "^/dev/" /proc/mounts | parse_proc_mounts >"$OS_PROBER_TMP/mounted-map" || true +list_mounts >"$OS_PROBER_TMP/mounted-map" || true : >"$OS_PROBER_TMP/swaps-map" if [ -f /proc/swaps ]; then grep "^/dev/" /proc/swaps | parse_proc_swaps >"$OS_PROBER_TMP/swaps-map" || true