diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 19:10:49 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-14 19:10:49 +0000 |
commit | cfe5e3905201349e9cf3f95d52ff4bd100bde37d (patch) | |
tree | d0baf160cbee3195249d095f85e52d20c21acf02 /tests/ts/wipefs | |
parent | Initial commit. (diff) | |
download | util-linux-cfe5e3905201349e9cf3f95d52ff4bd100bde37d.tar.xz util-linux-cfe5e3905201349e9cf3f95d52ff4bd100bde37d.zip |
Adding upstream version 2.39.3.upstream/2.39.3
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ts/wipefs')
-rwxr-xr-x | tests/ts/wipefs/wipefs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/ts/wipefs/wipefs b/tests/ts/wipefs/wipefs new file mode 100755 index 0000000..c79be0c --- /dev/null +++ b/tests/ts/wipefs/wipefs @@ -0,0 +1,33 @@ +#!/bin/bash + +TS_TOPDIR="${0%/*}/../.." +TS_DESC="wipefs" + +. "$TS_TOPDIR"/functions.sh +ts_init "$*" + +ts_check_test_command "$TS_CMD_WIPEFS" + +ts_skip_nonroot + +# set global variable TS_DEVICE +ts_scsi_debug_init dev_size_mb=50 num_parts=2 + +# remove old backups +rm -rf $HOME/wipefs-$(basename ${TS_DEVICE})-*.bak + +#remove the magic byte, back it up +$TS_CMD_WIPEFS --all --backup ${TS_DEVICE} &>/dev/null || ts_die "wipefs failed" + +#there should be just one magic string/backup file in this case +INFILE=$(ls $HOME/wipefs-$(basename ${TS_DEVICE})-*.bak) +OFFT=$(echo $INFILE | sed 's/^.*-\(.*\).bak$/\1/') +dd if=$INFILE of=$TS_DEVICE bs=1 conv=notrunc seek=$(($OFFT)) &>/dev/null + +#the bytes should be copied back, check if wipefs can recognize it +$TS_CMD_WIPEFS -a ${TS_DEVICE} > $TS_OUTDIR/out 2>/dev/null + +# check for output +[ -s $TS_OUTDIR/out ] && echo "OK" &> $TS_OUTPUT || exit 1 + +ts_finalize |