-.
[xfstests-dev.git] / 054
1 #! /bin/sh
2 # FS QA Test No. 054
3 #
4 # Check behavior of chown with both user and group quota enabled,
5 # and changing both user and group together via chown(2).
6 #
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
9 #-----------------------------------------------------------------------
10 #
11 # creator
12 owner=nathans@sgi.com
13
14 seq=`basename $0`
15 echo "QA output created by $seq"
16
17 here=`pwd`
18 tmp=/tmp/$$
19 status=1        # failure is the default!
20
21 # get standard environment, filters and checks
22 . ./common.rc
23 . ./common.filter
24 . ./common.quota
25
26 _cleanup()
27 {
28         umount $SCRATCH_MNT 2>/dev/null
29         rm -f $tmp.*
30 }
31 trap "_cleanup; exit \$status" 0 1 2 3 15
32
33 # real QA test starts here
34 _supported_fs xfs
35 _supported_os Linux IRIX
36
37 cp /dev/null $seq.full
38 chmod ugo+rwx $seq.full
39
40 _require_scratch
41
42 _filter_stat()
43 {
44     sed "
45         /^Access:/d;
46         /^Modify:/d;
47         /^Change:/d;
48         s/Device: *[0-9][0-9]*,[0-9][0-9]*/Device: <DEVICE>/;
49         s/Inode: *[0-9][0-9]*/Inode: <INODE>/;
50         s,$SCRATCH_MNT,<MOUNT>,;
51     " | tr -s ' '
52 }
53
54 _exercise()
55 {
56         _scratch_mkfs_xfs >/dev/null 2>&1
57         _qmount
58
59         umask 022
60         touch $SCRATCH_MNT/testfile
61         if src/feature -c $SCRATCH_MNT/testfile; then
62                 :
63         else
64                 _notrun "Installed fileutils doesn't support 32 bit uids/gids"
65         fi
66
67         chown 12345 $SCRATCH_MNT/testfile
68         chgrp 54321 $SCRATCH_MNT/testfile
69         src/lstat64 $SCRATCH_MNT/testfile | _filter_stat
70
71         chown 34567 $SCRATCH_MNT/testfile
72         chgrp 76543 $SCRATCH_MNT/testfile
73         src/lstat64 $SCRATCH_MNT/testfile | _filter_stat
74
75         chown 56789 $SCRATCH_MNT/testfile
76         chgrp 98765 $SCRATCH_MNT/testfile
77         src/lstat64 $SCRATCH_MNT/testfile | _filter_stat
78
79         # finally give back to original owners
80         chown 12345 $SCRATCH_MNT/testfile
81         chgrp 54321 $SCRATCH_MNT/testfile
82         src/lstat64 $SCRATCH_MNT/testfile | _filter_stat
83
84         echo
85         umount $SCRATCH_MNT 2>/dev/null
86 }
87
88 _scratch_mkfs_xfs $SCRATCH_DEV >/dev/null 2>&1
89 export MOUNT_OPTIONS="-o uquota,gquota"
90 _qmount
91 if src/feature -G $SCRATCH_DEV ; then
92         :
93 else
94         _notrun "No quota support at mount time"
95 fi
96 umount $SCRATCH_MNT 2>/dev/null
97
98 export MOUNT_OPTIONS=""
99 echo "*** Default mount options"
100 _exercise
101
102 export MOUNT_OPTIONS="-o uquota"
103 echo "*** User quota mount option"
104 _exercise
105
106 export MOUNT_OPTIONS="-o gquota"
107 echo "*** Group quota mount option"
108 _exercise
109
110 export MOUNT_OPTIONS="-o uquota,gquota"
111 echo "*** User and Group quota mount options"
112 _exercise
113
114 # success, all done
115 status=0
116 exit