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 grep -q '^nobody' /etc/group
38 [ $? -ne 0 ] && _notrun "/etc/group does not contain user nobody."
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 grep '^nobody' /etc/group | perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[2],$a[0] }'
89 if [ ! -f /etc/projid ]; then
93 perl -ne '@a = split(/:/); END { printf "id=%d name=%s\n", $a[1],$a[0] }' \
99 umount $SCRATCH_DEV >/dev/null 2>&1
100 _scratch_mount || _fail "qmount failed"
101 chmod ugo+rwx $SCRATCH_MNT
106 # setup exactly what it is we'll be testing
108 if src/feature -u $SCRATCH_DEV
110 type=u ; eval `_choose_uid`; ln -s $seq.usrquota $seq.out
111 elif src/feature -g $SCRATCH_DEV
113 type=g ; eval `_choose_gid`; ln -s $seq.grpquota $seq.out
114 elif src/feature -p $SCRATCH_DEV
116 type=p ; eval `_choose_prid`; ln -s $seq.prjquota $seq.out
117 elif src/feature -U $SCRATCH_DEV
119 type=u ; eval `_choose_uid`; ln -s $seq.uqnoenforce $seq.out
121 elif src/feature -G $SCRATCH_DEV
123 type=g ; eval `_choose_gid`; ln -s $seq.gqnoenforce $seq.out
125 elif src/feature -P $SCRATCH_DEV
127 type=p ; eval `_choose_prid`; ln -s $seq.pqnoenforce $seq.out
130 _notrun "No quota support at mount time"
133 echo "Using output from '" `ls -l $seq.out` "'" >>$seq.full
134 echo "and using type=$type id=$id" >>$seq.full
137 # make sure this script returns success