egrep -o "[0-9]+ bytes" | $AWK_PROG '{print $1}'
}
+# Older mount output referred to "block device" when mounting RO devices
+# It's gone in newer versions
+_filter_ro_mount() {
+ sed -e "s/mount: block device//g" \
+ -e "s/mount: cannot mount block device/mount: cannot mount/g"
+}
+
# make sure this script returns success
/bin/true
# -o norecovery is used.
#
echo "mounting filesystem that needs recovery on a read-only device:"
-_scratch_mount 2>&1 | _filter_scratch
+_scratch_mount 2>&1 | _filter_scratch | _filter_ro_mount
echo "unmounting read-only filesystem"
umount $SCRATCH_MNT 2>&1 | _filter_scratch
# data recovery hack.
#
echo "mounting filesystem with -o norecovery on a read-only device:"
-_scratch_mount -o norecovery 2>&1 | _filter_scratch
+_scratch_mount -o norecovery 2>&1 | _filter_scratch | _filter_ro_mount
echo "unmounting read-only filesystem"
umount $SCRATCH_MNT 2>&1 | _filter_scratch
# the underlying device is not write protected.
#
echo "mounting filesystem that needs recovery with -o ro:"
-_scratch_mount -o ro 2>&1 | _filter_scratch
+_scratch_mount -o ro 2>&1 | _filter_scratch
# success, all done
echo "*** done"
QA output created by 200
setting device read-only
mounting read-only block device:
-mount: block device SCRATCH_DEV is write-protected, mounting read-only
+mount: SCRATCH_DEV is write-protected, mounting read-only
touching file on read-only filesystem (should fail)
touch: cannot touch 'SCRATCH_MNT/foo': Read-only file system
unmounting read-only filesystem
unmounting shutdown filesystem:
setting device read-only
mounting filesystem that needs recovery on a read-only device:
-mount: block device SCRATCH_DEV is write-protected, mounting read-only
-mount: cannot mount block device SCRATCH_DEV read-only
+mount: SCRATCH_DEV is write-protected, mounting read-only
+mount: cannot mount SCRATCH_DEV read-only
unmounting read-only filesystem
umount: SCRATCH_MNT: not mounted
mounting filesystem with -o norecovery on a read-only device:
-mount: block device SCRATCH_DEV is write-protected, mounting read-only
+mount: SCRATCH_DEV is write-protected, mounting read-only
unmounting read-only filesystem
setting device read-write
mounting filesystem that needs recovery with -o ro: