Skip to content

Commit

Permalink
pluto automounter: Retry automount in case device driver isn't ready
Browse files Browse the repository at this point in the history
The automounter can try to mount the device prematurely.  Catch this
kind of error output and retry a few times with some time in between
in case we can successfully mount this device.

Signed-off-by: Tim Nordell <[email protected]>
  • Loading branch information
tim-nordell-nimbelink authored and mhennerich committed Jun 17, 2021
1 parent bb00d64 commit af1f0a2
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion board/pluto/automounter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,36 @@ my_umount()
[ -d "${destdir}/$1" ] && rmdir "${destdir}/$1"
}

do_mount()
{
local errno
local err

errno=0
for I in $(seq 5)
do
err=$(mount -t auto -o sync "/dev/$1" "${destdir}/$1" 2>&1)
errno=$?

# If we get a "Device or resource busy" error, retry again in a
# little bit, otherwise just return immediately.
if ! echo "${err}" | grep -q "Device or resource busy"
then
return ${errno}
fi

sleep .25
done

echo "${err}" >&2
return ${errno}
}

my_mount()
{
mkdir -p "${destdir}/$1" || exit 1

if ! mount -t auto -o sync "/dev/$1" "${destdir}/$1"; then
if ! do_mount $1; then
# failed to mount, clean up mountpoint
rmdir "${destdir}/$1"
exit 1
Expand Down

0 comments on commit af1f0a2

Please sign in to comment.