2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Red Hat, Inc. All Rights Reserved.
7 # Test the online filesystem label set/get ioctls
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
24 # get standard environment, filters and checks
28 # remove previous $seqres.full before test
31 # real QA test starts here
35 _require_xfs_io_command "label"
36 _require_label_get_max
38 _scratch_mkfs > $seqres.full 2>&1
41 # Make sure we can set & clear the label
42 $XFS_IO_PROG -c "label -s label.$seq" $SCRATCH_MNT
43 $XFS_IO_PROG -c "label" $SCRATCH_MNT
45 $XFS_IO_PROG -c "label -c" $SCRATCH_MNT
46 $XFS_IO_PROG -c "label" $SCRATCH_MNT
48 # And that userspace can see it now, while mounted
49 # NB: some blkid has trailing whitespace, filter it out here
50 $XFS_IO_PROG -c "label -s label.$seq" $SCRATCH_MNT
51 $XFS_IO_PROG -c "label" $SCRATCH_MNT
52 blkid -s LABEL $SCRATCH_DEV | _filter_scratch | sed -e "s/ $//g"
54 # And that the it is still there when it's unmounted
56 blkid -s LABEL $SCRATCH_DEV | _filter_scratch | sed -e "s/ $//g"
58 # And that it persists after a remount
60 $XFS_IO_PROG -c "label" $SCRATCH_MNT
62 # And that a too-long label is rejected, beyond the interface max:
63 fs_label=$(perl -e "print 'l' x 257;")
64 $XFS_IO_PROG -c "label -s $fs_label" $SCRATCH_MNT
66 # And it succeeds right at the filesystem max:
67 max_label_len=$(_label_get_max)
68 fs_label=$(perl -e "print 'o' x $max_label_len;")
69 $XFS_IO_PROG -c "label -s $fs_label" $SCRATCH_MNT | sed -e 's/o\+/MAXLABEL/'
71 # And that it fails past the filesystem max:
72 let toolong_label_len=max_label_len+1
73 fs_label=$(perl -e "print 'o' x $toolong_label_len;")
74 $XFS_IO_PROG -c "label -s $fs_label " $SCRATCH_MNT