fstests: check for filesystem FS_IOC_FSSETXATTR support
[xfstests-dev.git] / tests / xfs / 261
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2011 SGI.  All Rights Reserved.
4 #
5 # FS QA Test No. 261
6 #
7 # This test exercises an issue in libxcmd where a problem with any
8 # mount point or project quota directory causes the program to exit
9 # complete.  The effect of this is that one cannot operate on any
10 # directory, even if the problem directory is completely unrelated
11 # to the directory one wants to operate on.
12 #
13 seq=$(basename $0)
14 seqres=$RESULT_DIR/$seq
15 echo "QA output created by ${seq}"
16
17 here=$(pwd)
18
19 tmp=/tmp/$$
20 my_mtab=${tmp}.mtab
21
22 mtab=/proc/self/mounts
23
24 status=1        # failure is the default!
25 trap "_cleanup; exit \$status" 0 1 2 3 15
26
27 _cleanup()
28 {
29     cd /
30     rm -f ${tmp}.*
31 }
32
33 # get standard environment, filters and checks
34 . ./common/rc
35 . ./common/filter
36 . ./common/quota
37
38 echo "Silence is golden."
39 rm -f $seqres.full
40
41 # real QA test starts here
42
43 # Modify as appropriate.
44 _supported_fs xfs
45 _supported_os Linux
46
47 _require_quota
48 _require_scratch
49
50 _scratch_mkfs >> $seqres.full 2>&1
51
52 # Just use the current mount table as an example mtab file.  Odds
53 # are good there's nothing wrong with it.
54 _setup_my_mtab() {
55         cp "${mtab}" "${my_mtab}"
56 }
57
58 # Any bogus entry in the mtab file is enough to trigger the problem.
59 # So just append a bogus entry at the end of the private mtab file.
60 # This matches an actually-observed entry in a mount table (with a
61 # few characters in the paths changed to protect the innocent).
62 _perturb_my_mtab() {
63         cat <<-! >> "${my_mtab}"
64                 /dev/disk/by-id/scsi-3600508e000000000c329ba1d8b0c391b-part3 /tmp/autoY8qcJ9\040(deleted) xfs rw 0 0
65         !
66 }
67
68 _check() {
69         if [ $# -eq 0 ]; then
70                 export MOUNT_OPTIONS=""
71         elif [ $# -eq 1 ]; then
72                 [ $1 = u -o $1 = g -o $1 = p ] || exit
73                 export MOUNT_OPTIONS="-o${1}quota"
74         else
75                 exit
76         fi
77
78         _qmount
79
80         # Set up a private mount table file, then try out a simple quota
81         # command to show mounts
82         _setup_my_mtab
83         echo print | xfs_quota  -t "${my_mtab}" > /dev/null || exit
84
85         # Do the same simple quota command after adding a bogus entry to the
86         # mount table.  Old code will bail on this because it has trouble
87         # with the bogus entry.
88         _perturb_my_mtab
89         echo print | xfs_quota -t "${my_mtab}" > /dev/null || exit
90 }
91
92 #########
93
94 # Mount SCRATCH with no quota options
95 _check
96
97 # user quota enabled
98 _check u
99
100 # group quota enabled
101 _check g
102
103 # user quota enabled
104 _check p
105
106 status=0        # success, all done