Skip to content

Commit

Permalink
Handle devices that are mounted at multiple paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Goll committed Dec 31, 2021
1 parent 9a15ab7 commit 60f432e
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions bashmount
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,10 @@ print_device() {
done
fi
elif check_mounted "$devname"; then
mountpath="$(info_mountpath "$devname")"
printf '%s' " ${GREEN}[$mountpath]${ALL_OFF}"
local -a mountpath_arr=()
info_mountpath_arr "$devname" mountpath_arr
printf -v mountpath "[%s] " "${mountpath_arr[@]}"
printf '%s' " ${GREEN}${mountpath}${ALL_OFF}"
mounted[${#mounted[*]}]="$devname"
fi
printf '\n'
Expand Down Expand Up @@ -379,7 +381,11 @@ info_fstype() {
lsblk -drno FSTYPE "$1" 2>/dev/null
}
info_mountpath() {
findmnt -no TARGET "$1" 2>/dev/null
findmnt -no TARGET "$1" 2>/dev/null | head -n1
}
info_mountpath_arr() {
local -n arr=$2
IFS=$'\n' arr=( $(findmnt -no TARGET "$1" 2>/dev/null) )
}
info_partlabel() {
lsblk -drno PARTLABEL "$1" 2>/dev/null
Expand Down Expand Up @@ -704,8 +710,12 @@ submenu() {
else
printf '%s' " mounted : "
if (( mounted )); then
local -a mountpath_arr=()
printf '%s\n' "${GREEN}yes${ALL_OFF}"
printf '%s\n' " mountpath : $(info_mountpath "$devname")"
info_mountpath_arr "$devname" mountpath_arr
for mountpath in ${mountpath_arr[@]}; do
printf '%s\n' " mountpath : $mountpath"
done
else
printf '%s\n' "${RED}no${ALL_OFF}"
fi
Expand Down

0 comments on commit 60f432e

Please sign in to comment.