When doing premount, check whether mountpoint is already mounted first.

This commit is contained in:
Rob Pearce 2020-11-05 09:24:29 +11:00
parent fbaadd8e18
commit 01af0ca438
1 changed files with 23 additions and 5 deletions

18
bare.sh
View File

@ -438,6 +438,20 @@ function restorecmd_help() {
echo echo
} }
function is_mounted() {
local dir dev1 dev2 rv
dir="$1"
dev1=$(stat -f %d $dir 2>/dev/null)
dev2=$(stat -f %d $dir/.. 2>/dev/null)
if [[ $dev1 == $dev2 ]]; then
rv=1
else
rv=0
fi
return $rv
}
# Handle args # Handle args
ARGS="acd:hs:tvx:" ARGS="acd:hs:tvx:"
@ -806,6 +820,9 @@ for f in $REPO_LIST; do
if [[ $MOUNTREPO -eq 1 ]]; then if [[ $MOUNTREPO -eq 1 ]]; then
path=`gettagval "$f" premount` path=`gettagval "$f" premount`
[[ $VERBOSE -eq 1 ]] && log "debug: doing repo premount at $path via fstab" [[ $VERBOSE -eq 1 ]] && log "debug: doing repo premount at $path via fstab"
if is_mounted $path; then
log "Pre-mount of '$path': already mounted"
else
mount $path mount $path
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
log "Pre-mount of '$path': success" log "Pre-mount of '$path': success"
@ -814,6 +831,7 @@ for f in $REPO_LIST; do
continue continue
fi fi
fi fi
fi
if [[ $CMD == "go" ]]; then if [[ $CMD == "go" ]]; then
NEEDMOUNT=1 NEEDMOUNT=1