diff options
author | Elliott Hughes <enh@google.com> | 2019-07-26 16:00:38 -0700 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2019-07-27 16:27:22 -0500 |
commit | cde31cc6bbc32fc3c5405c63243697e1cdd21884 (patch) | |
tree | c3e5bc66656aa9d1293bf8319e37bfb134100a20 | |
parent | 0f64560002b885fca7e04544ece3504e92dc29ae (diff) | |
download | toybox-cde31cc6bbc32fc3c5405c63243697e1cdd21884.tar.gz |
losetup.test: bail out if loopback devices are already in use.
There's probably a way to filter out the existing ones, but it's likely
to be pretty painful and isn't immediately necessary.
(I hit this case on Android cloud x86 devices.)
-rwxr-xr-x | tests/losetup.test | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/tests/losetup.test b/tests/losetup.test index 7968ecd9..2f72b920 100755 --- a/tests/losetup.test +++ b/tests/losetup.test @@ -2,13 +2,18 @@ [ -f testing.sh ] && . testing.sh -if [ "$(id -u)" -ne 0 ] -then +if [ "$(id -u)" -ne 0 ]; then echo "$SHOWSKIP: losetup (not root)" return 2>/dev/null exit fi +if [ "$(losetup -a | wc -l)" -ne 0 ]; then + echo "$SHOWSKIP: losetup (devices already in use)" + return 2>/dev/null + exit +fi + # Android's loopback devices are only in /dev/block/loop*. # Debian has symlinks like /dev/block/7:0 back to ../loop*. if [ -b /dev/block/sda ]; then |