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
36 _require_xfs_io_command "label"
37 _require_label_get_max
39 _scratch_mkfs > $seqres.full 2>&1
42 # Make sure we can set & clear the label
43 $XFS_IO_PROG -c "label -s label.$seq" $SCRATCH_MNT
44 $XFS_IO_PROG -c "label" $SCRATCH_MNT
46 $XFS_IO_PROG -c "label -c" $SCRATCH_MNT
47 $XFS_IO_PROG -c "label" $SCRATCH_MNT
49 # And that userspace can see it now, while mounted
50 # NB: some blkid has trailing whitespace, filter it out here
51 $XFS_IO_PROG -c "label -s label.$seq" $SCRATCH_MNT
52 $XFS_IO_PROG -c "label" $SCRATCH_MNT
53 blkid -s LABEL $SCRATCH_DEV | _filter_scratch | sed -e "s/ $//g"
55 # And that the it is still there when it's unmounted
57 blkid -s LABEL $SCRATCH_DEV | _filter_scratch | sed -e "s/ $//g"
59 # And that it persists after a remount
61 $XFS_IO_PROG -c "label" $SCRATCH_MNT
63 # And that a too-long label is rejected, beyond the interface max:
64 fs_label=$(perl -e "print 'l' x 257;")
65 $XFS_IO_PROG -c "label -s $fs_label" $SCRATCH_MNT
67 # And it succeeds right at the filesystem max:
68 max_label_len=$(_label_get_max)
69 fs_label=$(perl -e "print 'o' x $max_label_len;")
70 $XFS_IO_PROG -c "label -s $fs_label" $SCRATCH_MNT | sed -e 's/o\+/MAXLABEL/'
72 # And that it fails past the filesystem max:
73 let toolong_label_len=max_label_len+1
74 fs_label=$(perl -e "print 'o' x $toolong_label_len;")
75 $XFS_IO_PROG -c "label -s $fs_label " $SCRATCH_MNT