summaryrefslogtreecommitdiff
path: root/tests/generic/492
blob: c488c8babfacc1a918ad6d27f0eb05e41f96161e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 Red Hat, Inc.  All Rights Reserved.
#
# FS QA Test 492
#
# Test the online filesystem label set/get ioctls
#
. ./common/preamble
_begin_fstest auto quick

# Import common functions.
. ./common/filter

# real QA test starts here

_supported_fs generic
_require_scratch
_require_xfs_io_command "label"
_require_label_get_max

_scratch_mkfs > $seqres.full 2>&1
_scratch_mount

# Make sure we can set & clear the label
$XFS_IO_PROG -c "label -s label.$seq" $SCRATCH_MNT
$XFS_IO_PROG -c "label" $SCRATCH_MNT

$XFS_IO_PROG -c "label -c" $SCRATCH_MNT
$XFS_IO_PROG -c "label" $SCRATCH_MNT

# And that userspace can see it now, while mounted
# NB: some blkid has trailing whitespace, filter it out here
$XFS_IO_PROG -c "label -s label.$seq" $SCRATCH_MNT
$XFS_IO_PROG -c "label" $SCRATCH_MNT
blkid -s LABEL $SCRATCH_DEV | _filter_scratch | sed -e "s/ $//g"

# And that the it is still there when it's unmounted
_scratch_unmount
blkid -s LABEL $SCRATCH_DEV | _filter_scratch | sed -e "s/ $//g"

# And that it persists after a remount
_scratch_mount
$XFS_IO_PROG -c "label" $SCRATCH_MNT

# And that a too-long label is rejected, beyond the interface max:
fs_label=$(perl -e "print 'l' x 257;")
$XFS_IO_PROG -c "label -s $fs_label" $SCRATCH_MNT

# And it succeeds right at the filesystem max:
max_label_len=$(_label_get_max)
fs_label=$(perl -e "print 'o' x $max_label_len;")
$XFS_IO_PROG -c "label -s $fs_label" $SCRATCH_MNT | sed -e 's/o\+/MAXLABEL/'

# And that it fails past the filesystem max:
let toolong_label_len=max_label_len+1
fs_label=$(perl -e "print 'o' x $toolong_label_len;")
$XFS_IO_PROG -c "label -s $fs_label " $SCRATCH_MNT

# success, all done
status=0
exit