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# ident "@(#)xattr_013_pos.ksh 1.1 07/02/06 SMI" 26# 27 28# $FreeBSD$ 29 30. $STF_SUITE/include/libtest.kshlib 31. $STF_SUITE/tests/xattr/xattr_common.kshlib 32 33################################################################################ 34# 35# __stc_assertion_start 36# 37# ID: xattr_013_pos 38# 39# DESCRIPTION: 40# The noxattr mount option functions as expected 41# 42# STRATEGY: 43# 1. Create a file on a filesystem and add an xattr to it 44# 2. Unmount the filesystem, and mount it -o noxattr 45# 3. Verify that the xattr cannot be read and new files 46# cannot have xattrs set on them. 47# 4. Unmount and mount the filesystem normally 48# 5. Verify that xattrs can be set and accessed again 49# 50# TESTABILITY: explicit 51# 52# TEST_AUTOMATION_LEVEL: automated 53# 54# CODING_STATUS: COMPLETED (2006-12-15) 55# 56# __stc_assertion_end 57# 58################################################################################ 59 60function cleanup { 61 62 log_must $RM $TESTDIR/myfile.${TESTCASE_ID} 63} 64 65 66log_assert "The noxattr mount option functions as expected" 67log_onexit cleanup 68 69test_requires RUNAT 70 71$ZFS set 2>&1 | $GREP xattr > /dev/null 72if [ $? -ne 0 ] 73then 74 log_unsupported "noxattr mount option not supported on this release." 75fi 76 77log_must $TOUCH $TESTDIR/myfile.${TESTCASE_ID} 78create_xattr $TESTDIR/myfile.${TESTCASE_ID} passwd /etc/passwd 79 80log_must $UMOUNT $TESTDIR 81log_must $ZFS mount -o noxattr $TESTPOOL/$TESTFS 82 83# check that we can't perform xattr operations 84log_mustnot eval "$RUNAT $TESTDIR/myfile.${TESTCASE_ID} $CAT passwd > /dev/null 2>&1" 85log_mustnot eval "$RUNAT $TESTDIR/myfile.${TESTCASE_ID} $RM passwd > /dev/null 2>&1" 86log_mustnot eval "$RUNAT $TESTDIR/myfile.${TESTCASE_ID} $CP /etc/passwd . > /dev/null 2>&1" 87 88log_must $TOUCH $TESTDIR/new.${TESTCASE_ID} 89log_mustnot eval "$RUNAT $TESTDIR/new.${TESTCASE_ID} $CP /etc/passwd . > /dev/null 2>&1" 90log_mustnot eval "$RUNAT $TESTDIR/new.${TESTCASE_ID} $RM passwd > /dev/null 2>&1" 91 92# now mount the filesystem again as normal 93log_must $UMOUNT $TESTDIR 94log_must $ZFS mount $TESTPOOL/$TESTFS 95 96# we should still have an xattr on the first file 97verify_xattr $TESTDIR/myfile.${TESTCASE_ID} passwd /etc/passwd 98 99# there should be no xattr on the file we created while the fs was mounted 100# -o noxattr 101log_mustnot eval "$RUNAT $TESTDIR/new.${TESTCASE_ID} $CAT passwd > /dev/null 2>&1" 102create_xattr $TESTDIR/new.${TESTCASE_ID} passwd /etc/passwd 103 104log_pass "The noxattr mount option functions as expected" 105