3 # Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
6 # Functions useful for quota tests
10 # checks that the XFS quota support in the kernel is enabled
11 # and that we have valid quota user tools installed.
15 src/feature -q $TEST_DEV
16 [ $? -ne 0 ] && _notrun "Installed kernel does not support XFS quota"
17 [ -x /usr/sbin/xfs_quota ] || _notrun "Quota user tools not installed"
21 # checks that the XFS project quota support in the kernel is enabled.
25 src/feature -p $TEST_DEV
26 [ $? -ne 0 ] && _notrun "Installed kernel does not support project quotas"
30 # checks for user nobody in /etc/passwd and /etc/group.
34 grep -q '^nobody' /etc/passwd
35 [ $? -ne 0 ] && _notrun "/etc/passwd does not contain user nobody."
37 egrep -q '^no(body|group)' /etc/group
38 [ $? -ne 0 ] && _notrun "/etc/group does not contain nobody/nogroup."
41 # create a file as a specific user (uid)
42 # takes filename, id, type (u/g/p), blocksize, blockcount
46 [ $# != 5 ] && _notrun "broken call to _file_as_id in test $seq"
50 echo PARENT: xfs_io -r -c "chproj $2" -c "chattr +P" $parent >>$seq.full
51 $XFS_IO_PROG -r -c "chproj $2" -c "chattr +P" $parent >>$seq.full 2>&1
52 magik='$>' # (irrelevent, above set projid-inherit-on-parent)
54 magik='$>' # perlspeak for effective uid
56 magik='$)' # perlspeak for effective gid
58 _notrun "broken type in call to _file_as_id in test $seq"
61 perl <<EOF >>$seq.full 2>&1
68 print "dd if=/dev/zero of=$1 bs=$4 count=$5";
69 exec "dd if=/dev/zero of=$1 bs=$4 count=$5";
72 # for debugging the above euid change, try... [need write in cwd]
73 # exec "dd if=/dev/zero of=$1 bs=$4 count=$5 >>$seq.full 2>&1";
76 echo PARENT: xfs_io -r -c "chproj 0" -c "chattr -P" $parent >>$seq.full
77 $XFS_IO_PROG -r -c "chproj 0" -c "chattr -P" $parent >>$seq.full 2>&1
83 grep '^nobody' /etc/passwd | perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[2],$a[0] }'
88 egrep '^no(body|group)' /etc/group | perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[2],$a[0] }'
93 if [ "X$projid_file" == "X" ]; then
94 projid_file=/etc/projid
96 if [ ! -f $projid_file ]; then
100 perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[1],$a[0] }' \
106 umount $SCRATCH_DEV >/dev/null 2>&1
107 _scratch_mount || _fail "qmount failed"
108 chmod ugo+rwx $SCRATCH_MNT
113 # setup exactly what it is we'll be testing
115 if src/feature -u $SCRATCH_DEV
119 [ ! -f $seq.out ] && ln -s $seq.usrquota $seq.out
120 elif src/feature -g $SCRATCH_DEV
124 [ ! -f $seq.out ] && ln -s $seq.grpquota $seq.out
125 elif src/feature -p $SCRATCH_DEV
129 [ ! -f $seq.out ] && ln -s $seq.prjquota $seq.out
130 elif src/feature -U $SCRATCH_DEV
134 [ ! -f $seq.out ] && ln -s $seq.uqnoenforce $seq.out
136 elif src/feature -G $SCRATCH_DEV
140 [ ! -f $seq.out ] && ln -s $seq.gqnoenforce $seq.out
142 elif src/feature -P $SCRATCH_DEV
146 [ ! -f $seq.out ] && ln -s $seq.pqnoenforce $seq.out
149 _notrun "No quota support at mount time"
152 echo "Using output from '" `ls -l $seq.out` "'" >>$seq.full
153 echo "and using type=$type id=$id" >>$seq.full
156 # make sure this script returns success