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.
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.
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]
24 # Copyright 2009 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2017 by Fan Yong. All rights reserved.
32 . $STF_SUITE/tests/functional/projectquota/projectquota_common.kshlib
37 # Check project ID/flags can be set/inherited properly
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.
50 log_must rm -f $PRJFILE
51 log_must rm -rf $PRJDIR
54 if ! lsattr -pd > /dev/null 2>&1; then
55 log_unsupported "Current e2fsprogs does not support set/show project ID"
60 log_assert "Check project ID/flags can be set/inherited properly"
62 log_must touch $PRJFILE
63 log_must mkdir $PRJDIR
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 '\- '"
70 log_must chattr +P $PRJDIR
71 log_must eval "lsattr -pd $PRJDIR | grep $PRJID1 | grep '\-P '"
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 '\- '"
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"
82 log_must touch $PRJDIR/dchild/foo
83 log_must eval "lsattr -p $PRJDIR/dchild/foo | grep $PRJID1"
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
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
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
103 log_pass "Check project ID/flags can be set/inherited properly"