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]
22 # Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 # Use is subject to license terms.
27 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
30 . $STF_SUITE/include/libtest.shlib
31 . $STF_SUITE/tests/functional/xattr/xattr_common.kshlib
35 # The noxattr mount option functions as expected
38 # 1. Create a file on a filesystem and add an xattr to it
39 # 2. Unmount the filesystem, and mount it -o noxattr
40 # 3. Verify that the xattr cannot be read and new files
41 # cannot have xattrs set on them.
42 # 4. Unmount and mount the filesystem normally
43 # 5. Verify that xattrs can be set and accessed again
48 log_must rm $TESTDIR/myfile.$$
52 log_assert "The noxattr mount option functions as expected"
55 zfs set 2>&1 | grep xattr > /dev/null
58 log_unsupported "noxattr mount option not supported on this release."
61 log_must touch $TESTDIR/myfile.$$
62 create_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
64 log_must umount $TESTDIR
65 log_must zfs mount -o noxattr $TESTPOOL/$TESTFS
67 # check that we can't perform xattr operations
69 log_mustnot eval "runat $TESTDIR/myfile.$$ cat passwd > /dev/null 2>&1"
70 log_mustnot eval "runat $TESTDIR/myfile.$$ rm passwd > /dev/null 2>&1"
71 log_mustnot eval "runat $TESTDIR/myfile.$$ cp /etc/passwd . \
74 log_must touch $TESTDIR/new.$$
75 log_mustnot eval "runat $TESTDIR/new.$$ cp /etc/passwd . \
77 log_mustnot eval "runat $TESTDIR/new.$$ rm passwd > /dev/null 2>&1"
79 log_mustnot get_xattr passwd $TESTDIR/myfile.$$
80 log_mustnot rm_xattr passwd $TESTDIR/myfile.$$
81 log_mustnot set_xattr_stdin passwd $TESTDIR/myfile.$$ </etc/passwd
83 log_must touch $TESTDIR/new.$$
84 log_mustnot set_xattr_stdin passwd $TESTDIR/new.$$ </etc/passwd
85 log_mustnot rm_xattr passwd $TESTDIR/new.$$
88 # now mount the filesystem again as normal
89 log_must umount $TESTDIR
90 log_must zfs mount $TESTPOOL/$TESTFS
92 # we should still have an xattr on the first file
93 verify_xattr $TESTDIR/myfile.$$ passwd /etc/passwd
95 # there should be no xattr on the file we created while the fs was mounted
98 log_mustnot eval "runat $TESTDIR/new.$$ cat passwd > /dev/null 2>&1"
100 log_mustnot get_xattr passwd $TESTDIR/new.$$
102 create_xattr $TESTDIR/new.$$ passwd /etc/passwd
104 log_pass "The noxattr mount option functions as expected"