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) 2013 by Delphix. All rights reserved.
31 . $STF_SUITE/include/libtest.shlib
32 . $STF_SUITE/tests/functional/userquota/userquota_common.kshlib
37 # Check whether chattr works as expected
42 # 2. Use chattr to make them writable, immutable and appendonly
43 # 3. Try to write and append to each file
46 set -A files writable immutable append
50 for i in ${files[*]}; do
52 log_must chflags noschg $TESTDIR/$i
53 log_must rm -f $TESTDIR/$i
55 log_must chattr -ia $TESTDIR/$i
56 log_must rm -f $TESTDIR/$i
64 log_assert "Check whether chflags works as expected"
66 log_assert "Check whether chattr works as expected"
69 log_must touch $TESTDIR/writable
70 log_must touch $TESTDIR/immutable
71 log_must touch $TESTDIR/append
74 log_must chflags noschg $TESTDIR/writable
75 log_must chflags schg $TESTDIR/immutable
76 log_must chflags sappnd $TESTDIR/append
78 log_must chattr -i $TESTDIR/writable
79 log_must chattr +i $TESTDIR/immutable
80 log_must chattr +a $TESTDIR/append
83 log_must eval "echo test > $TESTDIR/writable"
84 log_must eval "echo test >> $TESTDIR/writable"
85 log_mustnot eval "echo test > $TESTDIR/immutable"
86 log_mustnot eval "echo test >> $TESTDIR/immutable"
87 log_mustnot eval "echo test > $TESTDIR/append"
88 log_must eval "echo test >> $TESTDIR/append"
91 log_pass "chflags works as expected"
93 log_pass "chattr works as expected"