flatcar-scripts/path-overrides/umount
Mike Frysinger cc6d7b12a0 umount wrapper: fix inverted logic
The current logic exits when the output *is* "device is busy" when it
should be exiting when the output *isn't*.

BUG=chromium-os:23443
TEST=`./mod_image_for_recovery.sh` works again

Change-Id: I78eef746611de1044da664f32f8ec5e3b22b21f7
Reviewed-on: https://gerrit.chromium.org/gerrit/33170
Reviewed-by: Brian Harring <ferringb@chromium.org>
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
2012-09-12 22:32:18 -07:00

34 lines
1008 B
Bash
Executable File

#!/bin/bash
# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# 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 "$0")
cleaned_path=$(echo "${PATH}" | sed -r -e "s,(^|:)${suppressed_dir}(:|$),,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}