common/rc: add _scratch_{u}mount_idmapped() helpers
[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 _require_quota
39 _require_scratch
40
41 _scratch_mkfs >> $seqres.full 2>&1
42
43 MOUNT_OPTIONS="-o usrquota,grpquota"
44 _qmount
45 _require_getnextquota
46
47 echo "Launch all quotas"
48
49 # We want to create a block of quotas for an id very near
50 # 2^32, then ask for the next quota after it.  The returned
51 # ID should not overflow to 0.
52
53 # Populate  with 2^32-4
54 ID=4294967292
55 setquota -u $ID $ID $ID $ID $ID $SCRATCH_MNT
56 touch ${SCRATCH_MNT}/${ID}
57 chown ${ID} ${SCRATCH_MNT}/${ID}
58
59 # remount just for kicks, make sure we get it off disk
60 _scratch_unmount
61 _qmount
62
63 # Ask for the next quota after $ID; should get nothing back
64 # If kernelspace wraps, we'll get 0 back.
65 for TYPE in u g; do
66         let NEXT=ID+1
67         echo "Ask for ID after $NEXT expecting nothing"
68         $here/src/test-nextquota -i $NEXT -${TYPE} -d $SCRATCH_DEV
69 done
70
71 # success, all done
72 status=0
73 exit