mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-07 04:56:58 +02:00
Specifically, detect if the umount failed due to current access, if so, give it up to 9 more runs (w/ 1s pauses) continuing only if it's still failing due to currently open files. Via this, it should suppress the race of gvfs/trashd looking at quick mounted/umounted pathways. This CL is a two parter; this adds the script, and converts common.sh consumers over to using the override. The next CL will modify the chroot itself to ensure our script gets picked up/used. BUG=chromium-os:23443 TEST=trybot, manul validation. Change-Id: I92dedd91d6133c2063b1e5dbbc1a68366844801d Reviewed-on: https://gerrit.chromium.org/gerrit/32087 Commit-Ready: Brian Harring <ferringb@chromium.org> Reviewed-by: Brian Harring <ferringb@chromium.org> Tested-by: Brian Harring <ferringb@chromium.org>
30 lines
858 B
Bash
Executable File
30 lines
858 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Work around a bug on precise where gvfs trash goes looking in mounts
|
|
# it shouldn't, resulting in the umount failing when it shouldn't.
|
|
# See crosbug.com/23443 for the sordid details.
|
|
|
|
suppressed_dir=$(dirname "$(readlink -f "$0")")
|
|
cleaned_path="$(echo "$PATH" | sed -e 's+\(^\|:\)/usr/local/sbin\(:\|$\)++g')"
|
|
binary="$(PATH="${cleaned_path}" type -P umount)"
|
|
if [ $? -ne 0 ]; then
|
|
echo "umount: command not found" >&2
|
|
exit 127
|
|
fi
|
|
|
|
for x in {1..10}; do
|
|
# umount doesn't give use a distinct exit code for device is busy; thus grep
|
|
# the output.
|
|
output=$(LC_ALL=C "${binary}" "$@" 2>&1)
|
|
ret=$?
|
|
if [ ${ret} -eq 0 ] || [[ "${output}" == *"device is busy"* ]]; then
|
|
# Nothing to do in these scenarios; either ran fine, or it failed in a non
|
|
# busy fashion.
|
|
break
|
|
fi
|
|
sleep 1
|
|
done
|
|
|
|
echo -n "${output}" >&2
|
|
exit ${ret}
|