generic: convert tests to SPDX license tags
[xfstests-dev.git] / tests / generic / 400
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test 400
6 #
7 # test out high quota ids retrieved by Q_GETNEXTQUOTA
8 # Request for next ID near 2^32 should not wrap to 0
9 #
10 # Designed to use the new Q_GETNEXTQUOTA quotactl
11 #
12 seq=`basename $0`
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1        # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23         cd /
24         rm -f $tmp.*
25 }
26
27 # get standard environment, filters and checks
28 . ./common/rc
29 . ./common/filter
30 . ./common/quota
31
32 # remove previous $seqres.full before test
33 rm -f $seqres.full
34
35 # real QA test starts here
36
37 _supported_fs generic
38 _supported_os Linux
39 _require_quota
40 _require_scratch
41
42 _scratch_mkfs >> $seqres.full 2>&1
43
44 MOUNT_OPTIONS="-o usrquota,grpquota"
45 _qmount
46 _require_getnextquota
47
48 echo "Launch all quotas"
49
50 # We want to create a block of quotas for an id very near
51 # 2^32, then ask for the next quota after it.  The returned
52 # ID should not overflow to 0.
53
54 # Populate  with 2^32-4
55 ID=4294967292
56 setquota -u $ID $ID $ID $ID $ID $SCRATCH_MNT
57 touch ${SCRATCH_MNT}/${ID}
58 chown ${ID} ${SCRATCH_MNT}/${ID}
59
60 # remount just for kicks, make sure we get it off disk
61 _scratch_unmount
62 _qmount
63
64 # Ask for the next quota after $ID; should get nothing back
65 # If kernelspace wraps, we'll get 0 back.
66 for TYPE in u g; do
67         let NEXT=ID+1
68         echo "Ask for ID after $NEXT expecting nothing"
69         $here/src/test-nextquota -i $NEXT -${TYPE} -d $SCRATCH_DEV
70 done
71
72 # success, all done
73 status=0
74 exit