1#!/usr/local/bin/ksh93 -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# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 23# Use is subject to license terms. 24 25. $STF_SUITE/include/libtest.kshlib 26. $STF_SUITE/tests/xattr/xattr_common.kshlib 27 28################################################################################ 29# 30# __stc_assertion_start 31# 32# ID: xattr_013_pos 33# 34# DESCRIPTION: 35# The noxattr mount option functions as expected 36# 37# STRATEGY: 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 44# 45# TESTABILITY: explicit 46# 47# TEST_AUTOMATION_LEVEL: automated 48# 49# CODING_STATUS: COMPLETED (2006-12-15) 50# 51# __stc_assertion_end 52# 53################################################################################ 54 55function cleanup { 56 57 log_must $RM $TESTDIR/myfile.${TESTCASE_ID} 58} 59 60 61log_assert "The noxattr mount option functions as expected" 62log_onexit cleanup 63 64test_requires RUNAT 65 66$ZFS set 2>&1 | $GREP xattr > /dev/null 67if [ $? -ne 0 ] 68then 69 log_unsupported "noxattr mount option not supported on this release." 70fi 71 72log_must $TOUCH $TESTDIR/myfile.${TESTCASE_ID} 73create_xattr $TESTDIR/myfile.${TESTCASE_ID} passwd /etc/passwd 74 75log_must $UMOUNT $TESTDIR 76log_must $ZFS mount -o noxattr $TESTPOOL/$TESTFS 77 78# check that we can't perform xattr operations 79log_mustnot eval "$RUNAT $TESTDIR/myfile.${TESTCASE_ID} $CAT passwd > /dev/null 2>&1" 80log_mustnot eval "$RUNAT $TESTDIR/myfile.${TESTCASE_ID} $RM passwd > /dev/null 2>&1" 81log_mustnot eval "$RUNAT $TESTDIR/myfile.${TESTCASE_ID} $CP /etc/passwd . > /dev/null 2>&1" 82 83log_must $TOUCH $TESTDIR/new.${TESTCASE_ID} 84log_mustnot eval "$RUNAT $TESTDIR/new.${TESTCASE_ID} $CP /etc/passwd . > /dev/null 2>&1" 85log_mustnot eval "$RUNAT $TESTDIR/new.${TESTCASE_ID} $RM passwd > /dev/null 2>&1" 86 87# now mount the filesystem again as normal 88log_must $UMOUNT $TESTDIR 89log_must $ZFS mount $TESTPOOL/$TESTFS 90 91# we should still have an xattr on the first file 92verify_xattr $TESTDIR/myfile.${TESTCASE_ID} passwd /etc/passwd 93 94# there should be no xattr on the file we created while the fs was mounted 95# -o noxattr 96log_mustnot eval "$RUNAT $TESTDIR/new.${TESTCASE_ID} $CAT passwd > /dev/null 2>&1" 97create_xattr $TESTDIR/new.${TESTCASE_ID} passwd /etc/passwd 98 99log_pass "The noxattr mount option functions as expected" 100