3b58db8deaacce343566b7d0ec47a19a2f41db5f
[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 . ./common/preamble
14 _begin_fstest auto quick quota
15
16 my_mtab=${tmp}.mtab
17
18 mtab=/proc/self/mounts
19
20 # Override the default cleanup function.
21 _cleanup()
22 {
23     cd /
24     rm -f ${tmp}.*
25 }
26
27 # Import common functions.
28 . ./common/filter
29 . ./common/quota
30
31 echo "Silence is golden."
32
33 # real QA test starts here
34
35 # Modify as appropriate.
36 _supported_fs xfs
37
38 _require_quota
39 _require_scratch
40
41 _scratch_mkfs >> $seqres.full 2>&1
42
43 # Just use the current mount table as an example mtab file.  Odds
44 # are good there's nothing wrong with it.
45 _setup_my_mtab() {
46         cp "${mtab}" "${my_mtab}"
47 }
48
49 # Any bogus entry in the mtab file is enough to trigger the problem.
50 # So just append a bogus entry at the end of the private mtab file.
51 # This matches an actually-observed entry in a mount table (with a
52 # few characters in the paths changed to protect the innocent).
53 _perturb_my_mtab() {
54         cat <<-! >> "${my_mtab}"
55                 /dev/disk/by-id/scsi-3600508e000000000c329ba1d8b0c391b-part3 /tmp/autoY8qcJ9\040(deleted) xfs rw 0 0
56         !
57 }
58
59 _check() {
60         if [ $# -eq 0 ]; then
61                 export MOUNT_OPTIONS=""
62         elif [ $# -eq 1 ]; then
63                 [ $1 = u -o $1 = g -o $1 = p ] || exit
64                 export MOUNT_OPTIONS="-o${1}quota"
65         else
66                 exit
67         fi
68
69         _qmount
70
71         # Set up a private mount table file, then try out a simple quota
72         # command to show mounts
73         _setup_my_mtab
74         echo print | xfs_quota  -t "${my_mtab}" > /dev/null || exit
75
76         # Do the same simple quota command after adding a bogus entry to the
77         # mount table.  Old code will bail on this because it has trouble
78         # with the bogus entry.
79         _perturb_my_mtab
80         echo print | xfs_quota -t "${my_mtab}" > /dev/null || exit
81 }
82
83 #########
84
85 # Mount SCRATCH with no quota options
86 _check
87
88 # user quota enabled
89 _check u
90
91 # group quota enabled
92 _check g
93
94 # user quota enabled
95 _check p
96
97 status=0        # success, all done