]> granicus.if.org Git - zfs/blob - tests/zfs-tests/tests/functional/projectquota/projectid_001_pos.ksh
Project Quota on ZFS
[zfs] / tests / zfs-tests / tests / functional / projectquota / projectid_001_pos.ksh
1 #!/bin/ksh -p
2 #
3 # CDDL HEADER START
4 #
5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
8 #
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
13 #
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
19 #
20 # CDDL HEADER END
21 #
22
23 #
24 # Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
25 # Use is subject to license terms.
26 #
27
28 #
29 # Copyright (c) 2017 by Fan Yong. All rights reserved.
30 #
31
32 . $STF_SUITE/tests/functional/projectquota/projectquota_common.kshlib
33
34 #
35 #
36 # DESCRIPTION:
37 #       Check project ID/flags can be set/inherited properly
38 #
39 #
40 # STRATEGY:
41 #       1. Create a regular file and a directroy.
42 #       2. Set project ID on both directroy and regular file.
43 #       3. New created subdir or regular file should inherit its parent's
44 #          project ID if its parent has project inherit flag.
45 #       4. New created subdir should inherit its parent project's inherit flag.
46 #
47
48 function cleanup
49 {
50         log_must rm -f $PRJFILE
51         log_must rm -rf $PRJDIR
52 }
53
54 if ! lsattr -pd > /dev/null 2>&1; then
55         log_unsupported "Current e2fsprogs does not support set/show project ID"
56 fi
57
58 log_onexit cleanup
59
60 log_assert "Check project ID/flags can be set/inherited properly"
61
62 log_must touch $PRJFILE
63 log_must mkdir $PRJDIR
64
65 log_must chattr -p $PRJID1 $PRJFILE
66 log_must eval "lsattr -p $PRJFILE | grep $PRJID1 | grep '\- '"
67 log_must chattr -p $PRJID1 $PRJDIR
68 log_must eval "lsattr -pd $PRJDIR | grep $PRJID1 | grep '\- '"
69
70 log_must chattr +P $PRJDIR
71 log_must eval "lsattr -pd $PRJDIR | grep $PRJID1 | grep '\-P '"
72
73 # "-1" is invalid project ID, should be denied
74 log_mustnot chattr -p -1 $PRJFILE
75 log_must eval "lsattr -p $PRJFILE | grep $PRJID1 | grep '\- '"
76
77 log_must mkdir $PRJDIR/dchild
78 log_must eval "lsattr -pd $PRJDIR/dchild | grep $PRJID1 | grep '\-P '"
79 log_must touch $PRJDIR/fchild
80 log_must eval "lsattr -p $PRJDIR/fchild | grep $PRJID1"
81
82 log_must touch $PRJDIR/dchild/foo
83 log_must eval "lsattr -p $PRJDIR/dchild/foo | grep $PRJID1"
84
85 # not support project ID/flag on symlink
86 log_must ln -s $PRJDIR/dchild/foo $PRJDIR/dchild/s_foo
87 log_mustnot lsattr -p $PRJDIR/dchild/s_foo
88 log_mustnot chattr -p 123 $PRJDIR/dchild/s_foo
89 log_mustnot chattr +P $PRJDIR/dchild/s_foo
90
91 # not support project ID/flag on block special file
92 log_must mknod $PRJDIR/dchild/b_foo b 124 124
93 log_mustnot lsattr -p $PRJDIR/dchild/b_foo
94 log_mustnot chattr -p 123 $PRJDIR/dchild/b_foo
95 log_mustnot chattr +P $PRJDIR/dchild/b_foo
96
97 # not support project ID/flag on character special file
98 log_must mknod $PRJDIR/dchild/c_foo c 125 125
99 log_mustnot lsattr -p $PRJDIR/dchild/c_foo
100 log_mustnot chattr -p 123 $PRJDIR/dchild/c_foo
101 log_mustnot chattr +P $PRJDIR/dchild/c_foo
102
103 log_pass "Check project ID/flags can be set/inherited properly"