1#!/bin/ksh -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 23# 24# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27 28# 29# Copyright (c) 2017 by Fan Yong. Fan rights reserved. 30# Copyright 2019 Joyent, Inc. 31# 32 33. $STF_SUITE/tests/functional/projectquota/projectquota_common.kshlib 34 35# 36# DESCRIPTION: 37# Check changing project ID for the file with directory-based 38# extended attributes. 39# 40# 41# STRATEGY: 42# 1. create new file with default project ID 43# 2. set non-ACL extended attributes on the file 44# 3. use zfs projectspace to check the object usage 45# 4. change the file's project ID 46# 5. use zfs projectspace to check the object usage again 47# 48 49function cleanup 50{ 51 log_must rm -f $PRJGUARD 52 log_must rm -f $PRJFILE 53} 54 55log_onexit cleanup 56 57log_assert "Check changing project ID with directory-based extended attributes" 58 59log_must zfs set xattr=on $QFS 60 61log_must touch $PRJGUARD 62# log_must chattr -p $PRJID1 $PRJGUARD 63log_must zfs project -s -p $PRJID1 $PRJGUARD 64log_must touch $PRJFILE 65 66# log_must setfattr -n trusted.ea1 -v val1 $PRJFILE 67# log_must setfattr -n trusted.ea2 -v val2 $PRJFILE 68# log_must setfattr -n trusted.ea3 -v val3 $PRJFILE 69echo "dummy attribute data" >/tmp/attr.$$ 70log_must runat $PRJFILE cp /tmp/attr.$$ trusted.ea1 71log_must runat $PRJFILE cp /tmp/attr.$$ trusted.ea2 72log_must runat $PRJFILE cp /tmp/attr.$$ trusted.ea3 73rm /tmp/attr.$$ 74 75sync_pool 76typeset prj_bef=$(project_obj_count $QFS $PRJID1) 77 78# log_must chattr -p $PRJID1 $PRJFILE 79log_must zfs project -s -p $PRJID1 $PRJFILE 80sync_pool 81typeset prj_aft=$(project_obj_count $QFS $PRJID1) 82 83[[ $prj_aft -ge $((prj_bef + 5)) ]] || 84 log_fail "new value ($prj_aft) is NOT 5 largr than old one ($prj_bef)" 85 86log_pass "Changing project ID with directory-based extended attributes pass" 87