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), blocksize, blockcount
46 [ $# != 5 ] && _notrun "broken call to _file_as_id in test $seq"
50 echo xfs_io -f -c "chproj $2" -c "pwrite -b $4 0 $size" $1 >>$seq.full
51 $XFS_IO_PROG -f -c "chproj $2" -c "pwrite -b $4 0 $size" $1 \
55 magik='$>' # perlspeak for effective uid
57 magik='$)' # perlspeak for effective gid
59 _notrun "broken type in call to _file_as_id in test $seq"
62 perl <<EOF >>$seq.full 2>&1
69 print "dd if=/dev/zero of=$1 bs=$4 count=$5";
70 exec "dd if=/dev/zero of=$1 bs=$4 count=$5";
73 # for debugging the above euid change, try... [need write in cwd]
74 # exec "dd if=/dev/zero of=$1 bs=$4 count=$5 >>$seq.full 2>&1";
79 grep '^nobody' /etc/passwd | perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[2],$a[0] }'
84 egrep '^no(body|group)' /etc/group | perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[2],$a[0] }'
89 if [ $projid_file == "" ]; then
90 projid_file=/etc/projid
92 if [ ! -f $projid_file ]; then
96 perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[1],$a[0] }' \
102 umount $SCRATCH_DEV >/dev/null 2>&1
103 _scratch_mount || _fail "qmount failed"
104 chmod ugo+rwx $SCRATCH_MNT
109 # setup exactly what it is we'll be testing
111 if src/feature -u $SCRATCH_DEV
115 [ ! -f $seq.out ] && ln -s $seq.usrquota $seq.out
116 elif src/feature -g $SCRATCH_DEV
120 [ ! -f $seq.out ] && ln -s $seq.grpquota $seq.out
121 elif src/feature -p $SCRATCH_DEV
125 [ ! -f $seq.out ] && ln -s $seq.prjquota $seq.out
126 elif src/feature -U $SCRATCH_DEV
130 [ ! -f $seq.out ] && ln -s $seq.uqnoenforce $seq.out
132 elif src/feature -G $SCRATCH_DEV
136 [ ! -f $seq.out ] && ln -s $seq.gqnoenforce $seq.out
138 elif src/feature -P $SCRATCH_DEV
142 [ ! -f $seq.out ] && ln -s $seq.pqnoenforce $seq.out
145 _notrun "No quota support at mount time"
148 echo "Using output from '" `ls -l $seq.out` "'" >>$seq.full
149 echo "and using type=$type id=$id" >>$seq.full
152 # make sure this script returns success