# Test listing the subvolumes
echo "Listing subvolumes"
-$BTRFS_UTIL_PROG subvolume list $SCRATCH_MNT | awk '{ print $NF }'
+$BTRFS_UTIL_PROG subvolume list $SCRATCH_MNT | $AWK_PROG '{ print $NF }'
# Delete the snapshot
$BTRFS_UTIL_PROG subvolume delete $SCRATCH_MNT/snap | _filter_btrfs_subvol_delete
_populate_fs -n 1 -f 20 -d 10 -r $dirp -s 10
# pick last dev in the list
- dev_del=`echo ${SCRATCH_DEV_POOL} | awk '{print $NF}'`
+ dev_del=`echo ${SCRATCH_DEV_POOL} | $AWK_PROG '{print $NF}'`
$BTRFS_UTIL_PROG device delete $dev_del $SCRATCH_MNT || _fail "btrfs device delete failed"
$BTRFS_UTIL_PROG filesystem show $SCRATCH_DEV 2>&1 | grep $dev_del >> $seqres.full && _fail "btrfs still shows the deleted dev"
_scratch_unmount
_require_scratch
_require_scratch_dev_pool
-FIRST_POOL_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $1}'`
-LAST_POOL_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $NF}'`
+FIRST_POOL_DEV=`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}'`
+LAST_POOL_DEV=`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $NF}'`
TOTAL_DEVS=`echo $SCRATCH_DEV_POOL | wc -w`
LABEL=TestLabel.$seq
echo "== Show filesystem by label"
$BTRFS_UTIL_PROG filesystem show $LABEL | _filter_btrfs_filesystem_show $TOTAL_DEVS
-UUID=`$BTRFS_UTIL_PROG filesystem show $LABEL | grep uuid: | awk '{print $NF}'`
+UUID=`$BTRFS_UTIL_PROG filesystem show $LABEL | grep uuid: | $AWK_PROG '{print $NF}'`
echo "UUID $UUID" >> $seqres.full
local num_devs4raid="$2"
local with_cancel="$3"
local fssize="$4"
- local source_dev="`echo ${SCRATCH_DEV_POOL} | awk '{print $1}'`"
+ local source_dev="`echo ${SCRATCH_DEV_POOL} | $AWK_PROG '{print $1}'`"
local quick="quick"
[[ $fssize != 64 ]] && quick="thorough"
# the shared values of both the original subvol and snapshot should
# match
a_shared=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep "0/$subvolid")
- a_shared=$(echo $a_shared | awk '{ print $2 }')
+ a_shared=$(echo $a_shared | $AWK_PROG '{ print $2 }')
echo "subvol a id=$subvolid" >> $seqres.full
subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT b)
echo "subvol b id=$subvolid" >> $seqres.full
b_shared=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep "0/$subvolid")
- b_shared=$(echo $b_shared | awk '{ print $2 }')
+ b_shared=$(echo $b_shared | $AWK_PROG '{ print $2 }')
$BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT >> $seqres.full
[ $b_shared -eq $a_shared ] || _fail "shared values don't match"
}
sync
output=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep "0/$subvolid")
echo "qgroup values before rescan: $output" >> $seqres.full
- refer=$(echo $output | awk '{ print $2 }')
- excl=$(echo $output | awk '{ print $3 }')
+ refer=$(echo $output | $AWK_PROG '{ print $2 }')
+ excl=$(echo $output | $AWK_PROG '{ print $3 }')
_run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
output=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep "0/$subvolid")
echo "qgroup values after rescan: $output" >> $seqres.full
- [ $refer -eq $(echo $output | awk '{ print $2 }') ] || \
+ [ $refer -eq $(echo $output | $AWK_PROG '{ print $2 }') ] || \
_fail "reference values don't match after rescan"
- [ $excl -eq $(echo $output | awk '{ print $3 }') ] || \
+ [ $excl -eq $(echo $output | $AWK_PROG '{ print $3 }') ] || \
_fail "exclusive values don't match after rescan"
}
fi
_scratch_mount >>$seqres.full 2>&1
- local missing_dev=`echo $SCRATCH_DEV_POOL | awk '{print $2}'`
- local missing_dev_id=`$BTRFS_UTIL_PROG filesystem show $SCRATCH_MNT | grep $missing_dev | awk '{print $2}'`
+ local missing_dev=`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}'`
+ local missing_dev_id=`$BTRFS_UTIL_PROG filesystem show $SCRATCH_MNT | grep $missing_dev | $AWK_PROG '{print $2}'`
# get some data on the filesystem so there's something to replace
_ddt of="$SCRATCH_MNT"/file1 bs=1M count=1 >> $seqres.full 2>&1
$CLONER_PROG $SCRATCH_MNT/src $SCRATCH_MNT/src.clone2
-snap_src_sz=`ls -lah $SCRATCH_MNT/src.clone1 | awk '{print $5}'`
+snap_src_sz=`ls -lah $SCRATCH_MNT/src.clone1 | $AWK_PROG '{print $5}'`
echo "attempting ioctl (src.clone1 src)"
$CLONER_PROG -s 0 -d 0 -l ${snap_src_sz} \
$SCRATCH_MNT/src.clone1 $SCRATCH_MNT/src | _filter_btrfs_cloner_error
echo "File src data after attempt to clone from src.clone1 into src:"
od -t x1 $SCRATCH_MNT/src
-snap_src_sz=`ls -lah $SCRATCH_MNT/src.clone2 | awk '{print $5}'`
+snap_src_sz=`ls -lah $SCRATCH_MNT/src.clone2 | $AWK_PROG '{print $5}'`
echo "attempting ioctl (src.clone2 src)"
$CLONER_PROG -s 0 -d 0 -l ${snap_src_sz} \
$SCRATCH_MNT/src.clone2 $SCRATCH_MNT/src
new_default()
{
new_subvolume
- SUB=$($BTRFS_UTIL_PROG subvolume list $SCRATCH_MNT |awk '{print $2}')
+ SUB=$($BTRFS_UTIL_PROG subvolume list $SCRATCH_MNT | $AWK_PROG '{print $2}')
_run_btrfs_util_prog subvolume set-default $SUB $SCRATCH_MNT
_unmount_flakey
_require_scratch
_require_scratch_dev_pool
-FIRST_POOL_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $1}'`
+FIRST_POOL_DEV=`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}'`
TOTAL_DEVS=`echo $SCRATCH_DEV_POOL | wc -w`
_scratch_pool_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
_scratch_dev_pool_get 2
-dev1=`echo $SCRATCH_DEV_POOL | awk '{print $1}'`
-dev2=`echo $SCRATCH_DEV_POOL | awk '{print $2}'`
+dev1=`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}'`
+dev2=`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}'`
# RAID1 is not supported on zoned btrfs
_require_non_zoned_device "$dev1"
_scratch_dev_pool_get 3
-dev1=`echo $SCRATCH_DEV_POOL | awk '{print $1}'`
-dev2=`echo $SCRATCH_DEV_POOL | awk '{print $2}'`
-dev3=`echo $SCRATCH_DEV_POOL | awk '{print $3}'`
+dev1=`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}'`
+dev2=`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}'`
+dev3=`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $3}'`
echo dev1=$dev1 >> $seqres.full
echo dev2=$dev2 >> $seqres.full
$BTRFS_UTIL_PROG send -p $SCRATCH_MNT/mysnap1 -f $send_files_dir/2.snap \
$SCRATCH_MNT/mysnap2 2>&1 >/dev/null | _filter_scratch
-sum_src_snap1=$(md5sum $SCRATCH_MNT/mysnap1/foobar | awk '{print $1}')
-sum_src_snap2=$(md5sum $SCRATCH_MNT/mysnap2/foobar | awk '{print $1}')
+sum_src_snap1=$(md5sum $SCRATCH_MNT/mysnap1/foobar | $AWK_PROG '{print $1}')
+sum_src_snap2=$(md5sum $SCRATCH_MNT/mysnap2/foobar | $AWK_PROG '{print $1}')
echo "File digests in the original filesystem:" >> $seqres.full
echo "md5sum $SCRATCH_MNT/mysnap1/foobar " $sum_src_snap1 >> $seqres.full
echo "md5sum $SCRATCH_MNT/mysnap2/foobar " $sum_src_snap2 >> $seqres.full
$BTRFS_UTIL_PROG receive -f $send_files_dir/1.snap $SCRATCH_MNT > /dev/null
$BTRFS_UTIL_PROG receive -f $send_files_dir/2.snap $SCRATCH_MNT > /dev/null
-sum_dest_snap1=$(md5sum $SCRATCH_MNT/mysnap1/foobar | awk '{print $1}')
-sum_dest_snap2=$(md5sum $SCRATCH_MNT/mysnap2/foobar | awk '{print $1}')
+sum_dest_snap1=$(md5sum $SCRATCH_MNT/mysnap1/foobar | $AWK_PROG '{print $1}')
+sum_dest_snap2=$(md5sum $SCRATCH_MNT/mysnap2/foobar | $AWK_PROG '{print $1}')
echo "File digests in the new filesystem:" | tee -a $seqres.full
echo "md5sum $SCRATCH_MNT/mysnap1/foobar " $sum_src_snap1 >> $seqres.full
echo "md5sum $SCRATCH_MNT/mysnap2/foobar " $sum_src_snap2 >> $seqres.full
_scratch_dev_pool_get 2
-dev_seed=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
-dev_sprout=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
+dev_seed=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}')
+dev_sprout=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}')
create_seed()
{
_scratch_dev_pool_get 3
-dev_seed=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
-dev_sprout_seed=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
-dev_sprout=$(echo $SCRATCH_DEV_POOL | awk '{print $3}')
+dev_seed=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}')
+dev_sprout_seed=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}')
+dev_sprout=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $3}')
create_seed()
{
_scratch_dev_pool_get 3
-dev_seed=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
-dev_sprout=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
-dev_replace_tgt=$(echo $SCRATCH_DEV_POOL | awk '{print $3}')
+dev_seed=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}')
+dev_sprout=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}')
+dev_replace_tgt=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $3}')
create_seed()
{
_scratch_dev_pool_get 2
-dev_seed=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
-dev_sprout=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
+dev_seed=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}')
+dev_sprout=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}')
create_seed()
{
# Create the swap file, then add the device. That way we know it's all on one
# device.
_format_swapfile "$SCRATCH_MNT/swap" $(($(get_page_size) * 10)) > /dev/null
-scratch_dev2="$(echo "${SCRATCH_DEV_POOL}" | awk '{ print $2 }')"
+scratch_dev2="$(echo "${SCRATCH_DEV_POOL}" | $AWK_PROG '{ print $2 }')"
$BTRFS_UTIL_PROG device add -f "$scratch_dev2" "$SCRATCH_MNT" >> $seqres.full
swapon "$SCRATCH_MNT/swap" 2>&1 | _filter_scratch
swapoff "$SCRATCH_MNT/swap" > /dev/null 2>&1
# We check the filesystem manually because we move devices around.
rm -f "${RESULT_DIR}/require_scratch"
-scratch_dev1="$(echo "${SCRATCH_DEV_POOL}" | awk '{ print $1 }')"
-scratch_dev2="$(echo "${SCRATCH_DEV_POOL}" | awk '{ print $2 }')"
-scratch_dev3="$(echo "${SCRATCH_DEV_POOL}" | awk '{ print $3 }')"
+scratch_dev1="$(echo "${SCRATCH_DEV_POOL}" | $AWK_PROG '{ print $1 }')"
+scratch_dev2="$(echo "${SCRATCH_DEV_POOL}" | $AWK_PROG '{ print $2 }')"
+scratch_dev3="$(echo "${SCRATCH_DEV_POOL}" | $AWK_PROG '{ print $3 }')"
echo "Remove device"
_scratch_mkfs >> $seqres.full 2>&1
get_super_gen()
{
local ret=$($BTRFS_UTIL_PROG inspect dump-super "$SCRATCH_DEV" |\
- grep ^generation | awk '{print $2}')
+ grep ^generation | $AWK_PROG '{print $2}')
if [ -z $ret ]; then
_fail "failed to get super block generation"
fi
_scratch_mount
# pick last dev in the list
-dev_del=`echo ${SCRATCH_DEV_POOL} | awk '{print $NF}'`
+dev_del=`echo ${SCRATCH_DEV_POOL} | $AWK_PROG '{print $NF}'`
$BTRFS_UTIL_PROG device delete $dev_del $SCRATCH_MNT || _fail "btrfs device delete failed"
for i in {0..2}; do
output=$($BTRFS_UTIL_PROG inspect-internal dump-super -s $i $dev_del 2>&1)
_require_scratch_dev_pool 2
_scratch_dev_pool_get 2
-device_1=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
-device_2=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
+device_1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}')
+device_2=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}')
echo device_1=$device_1 device_2=$device_2 >> $seqres.full
_mkfs_dev $device_1
_mount $device_1 $mnt
-[[ $(findmnt $mnt | grep -v TARGET | awk '{print $2}') != $device_1 ]] && \
+[[ $(findmnt $mnt | grep -v TARGET | $AWK_PROG '{print $2}') != $device_1 ]] && \
_fail "mounted device changed"
for sb_bytenr in 65536 67108864; do
$BTRFS_UTIL_PROG device scan $device_2 >> $seqres.full 2>&1
[[ $? != 1 ]] && _fail "cloned device scan should fail"
-[[ $(findmnt $mnt | grep -v TARGET | awk '{print $2}') != $device_1 ]] && \
+[[ $(findmnt $mnt | grep -v TARGET | $AWK_PROG '{print $2}') != $device_1 ]] && \
_fail "mounted device changed"
# Original device scan should be successful
_notrun "This test need 4k page size"
fi
-device_1=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
-device_2=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
+device_1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}')
+device_2=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}')
echo device_1=$device_1 device_2=$device_2 >> $seqres.full
# don't test with the first device as auto fs check (_check_scratch_fs)
# picks the first device
- device_1=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
+ device_1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}')
$BTRFS_UTIL_PROG device add -f "$device_1" "$TEST_DIR/$seq.mnt" >> \
$seqres.full
- device_2=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
+ device_2=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}')
_mount -o degraded $device_2 $SCRATCH_MNT
# Check if missing device is reported as in the .out
$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | \
# don't test with the first device as auto fs check (_check_scratch_fs)
# picks the first device
- device_1=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
+ device_1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}')
$WIPEFS_PROG -a $device_1 >> $seqres.full 2>&1
- device_2=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
+ device_2=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}')
_mount -o degraded $device_2 $SCRATCH_MNT
# Check if missing device is reported as in the 196.out
$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | \
# buffered reads whould result in 2 * sectors_per_page errors since readahead code always submits
# at least 1 page worth of IO and it will be counted as error(s) as well
$XFS_IO_PROG -c "pread -b $filesize 0 $filesize" "$SCRATCH_MNT/foobar" > /dev/null 2>&1
-errs=$($BTRFS_UTIL_PROG device stats $SCRATCH_DEV | awk '/corruption_errs/ { print $2 }')
+errs=$($BTRFS_UTIL_PROG device stats $SCRATCH_DEV | $AWK_PROG '/corruption_errs/ { print $2 }')
if [ $errs -ne $((2 * $sectors_per_page)) ]; then
_fail "Errors: $errs expected: 2"
fi
# DIO does check every sector
$XFS_IO_PROG -d -c "pread -b $filesize 0 $filesize" "$SCRATCH_MNT/foobar" > /dev/null 2>&1
-errs=$($BTRFS_UTIL_PROG device stats $SCRATCH_DEV | awk '/corruption_errs/ { print $2 }')
+errs=$($BTRFS_UTIL_PROG device stats $SCRATCH_DEV | $AWK_PROG '/corruption_errs/ { print $2 }')
if [ $errs -ne $((6 * $sectors_per_page)) ]; then
_fail "Errors: $errs expected: 6"
fi
_scratch_dev_pool_get 2
-seed=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
-sprout=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
+seed=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}')
+sprout=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}')
_mkfs_dev $seed
$BTRFS_TUNE_PROG -S 1 $seed
_scratch_dev_pool_get 2
-dev_seed=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
-dev_sprout=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
+dev_seed=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}')
+dev_sprout=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}')
# Create the seed device
_mkfs_dev $dev_seed
{
setup_dmdev
dmdev=$(realpath $lvdev)
- scratch_dev2=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
- scratch_dev3=$(echo $SCRATCH_DEV_POOL | awk '{print $3}')
+ scratch_dev2=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}')
+ scratch_dev3=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $3}')
_mkfs_dev $scratch_dev3
_mount $scratch_dev3 $seq_mnt