fsx: Replace use of bcmp() with memcmp()
[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 _require_quota
42
43 _filter_stat()
44 {
45     sed "
46         /^Access:/d;
47         /^Modify:/d;
48         /^Change:/d;
49         s/Device: *[0-9][0-9]*,[0-9][0-9]*/Device: <DEVICE>/;
50         s/Inode: *[0-9][0-9]*/Inode: <INODE>/;
51         s,$SCRATCH_MNT,<MOUNT>,;
52     " | tr -s ' '
53 }
54
55 _exercise()
56 {
57         _scratch_mkfs_xfs >/dev/null 2>&1
58         _qmount
59
60         umask 022
61         touch $SCRATCH_MNT/testfile
62         if src/feature -c $SCRATCH_MNT/testfile; then
63                 :
64         else
65                 _notrun "Installed fileutils doesn't support 32 bit uids/gids"
66         fi
67
68         chown 12345 $SCRATCH_MNT/testfile
69         chgrp 54321 $SCRATCH_MNT/testfile
70         src/lstat64 $SCRATCH_MNT/testfile | _filter_stat
71
72         chown 34567 $SCRATCH_MNT/testfile
73         chgrp 76543 $SCRATCH_MNT/testfile
74         src/lstat64 $SCRATCH_MNT/testfile | _filter_stat
75
76         chown 56789 $SCRATCH_MNT/testfile
77         chgrp 98765 $SCRATCH_MNT/testfile
78         src/lstat64 $SCRATCH_MNT/testfile | _filter_stat
79
80         # finally give back to original owners
81         chown 12345 $SCRATCH_MNT/testfile
82         chgrp 54321 $SCRATCH_MNT/testfile
83         src/lstat64 $SCRATCH_MNT/testfile | _filter_stat
84
85         echo
86         umount $SCRATCH_MNT 2>/dev/null
87 }
88
89 _scratch_mkfs_xfs >> $seq.full 2>&1 || _fail "mkfs failed!"
90
91 _qmount_option "uquota,gquota"
92 _qmount
93 if src/feature -G $SCRATCH_DEV ; then
94         :
95 else
96         _notrun "No quota support at mount time"
97 fi
98 umount $SCRATCH_MNT 2>/dev/null
99
100 _qmount_option "rw" # no quota options
101 echo "*** Default mount options"
102 _exercise
103
104 _qmount_option "uquota"
105 echo "*** User quota mount option"
106 _exercise
107
108 export MOUNT_OPTIONS="-o gquota"
109 _qmount_option "gquota"
110 echo "*** Group quota mount option"
111 _exercise
112
113 _qmount_option "uquota,gquota"
114 echo "*** User and Group quota mount options"
115 _exercise
116
117 # success, all done
118 status=0
119 exit