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

28
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,12 +820,16 @@ 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"
mount $path if is_mounted $path; then
if [[ $? -eq 0 ]]; then log "Pre-mount of '$path': already mounted"
log "Pre-mount of '$path': success"
else else
log "Pre-mount of '$path': FAILED" mount $path
continue if [[ $? -eq 0 ]]; then
log "Pre-mount of '$path': success"
else
log "Pre-mount of '$path': FAILED"
continue
fi
fi fi
fi fi