2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Facebook. All Rights Reserved.
7 # Test swap file activation restrictions specific to Btrfs, swap file can't be
8 # CoW file nor compressed file.
11 _begin_fstest auto quick swap
16 _require_scratch_swapfile
18 _scratch_mkfs >> $seqres.full 2>&1
22 # We can't use _format_swapfile because we don't want chattr +C, and we can't
23 # unset it after the swap file has been created.
24 rm -f "$SCRATCH_MNT/swap"
25 touch "$SCRATCH_MNT/swap"
26 chmod 0600 "$SCRATCH_MNT/swap"
27 _pwrite_byte 0x61 0 $(($(get_page_size) * 10)) "$SCRATCH_MNT/swap" >> $seqres.full
28 $MKSWAP_PROG "$SCRATCH_MNT/swap" >> $seqres.full
29 swapon "$SCRATCH_MNT/swap" 2>&1 | _filter_scratch
30 swapoff "$SCRATCH_MNT/swap" >/dev/null 2>&1
32 echo "Compressed file"
33 rm -f "$SCRATCH_MNT/swap"
34 _format_swapfile "$SCRATCH_MNT/swap" $(($(get_page_size) * 10))
35 $CHATTR_PROG +c "$SCRATCH_MNT/swap" 2>&1 | grep -o "Invalid argument while setting flags"