| #!/bin/bash |
| # SPDX-License-Identifier: GPL-3.0+ |
| # Copyright (c) 2017 FUJITSU LIMITED. All rights reserved. |
| # |
| # If the entire block device is formatted with a filesystem and mounted, |
| # running "blockdev --rereadpt" should fail and return EBUSY. On buggy kernel, |
| # it passes unexpectedly. |
| # |
| # Regression test for commit 77032ca66f86 ("Return EBUSY from BLKRRPART for |
| # mounted whole-dev fs"). |
| |
| . tests/block/rc |
| |
| DESCRIPTION="try BLKRRPART on a mounted device" |
| QUICK=1 |
| |
| requires() { |
| _have_program mkfs.ext3 |
| } |
| |
| test_device() { |
| echo "Running ${TEST_NAME}" |
| |
| mkfs.ext3 -q -F "$TEST_DEV" |
| mkdir "$TMPDIR/mntpoint" |
| mount "$TEST_DEV" "$TMPDIR/mntpoint" |
| |
| local out |
| out="$(blockdev --rereadpt "$TEST_DEV" 2>&1)" |
| if ! echo "$out" | grep -o "Device or resource busy"; then |
| echo "$out" |
| fi |
| |
| umount "$TMPDIR/mntpoint" |
| |
| echo "Test complete" |
| } |