1*f67950b2SNasf-Fan#!/bin/ksh -p 2*f67950b2SNasf-Fan# 3*f67950b2SNasf-Fan# CDDL HEADER START 4*f67950b2SNasf-Fan# 5*f67950b2SNasf-Fan# The contents of this file are subject to the terms of the 6*f67950b2SNasf-Fan# Common Development and Distribution License (the "License"). 7*f67950b2SNasf-Fan# You may not use this file except in compliance with the License. 8*f67950b2SNasf-Fan# 9*f67950b2SNasf-Fan# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*f67950b2SNasf-Fan# or http://www.opensolaris.org/os/licensing. 11*f67950b2SNasf-Fan# See the License for the specific language governing permissions 12*f67950b2SNasf-Fan# and limitations under the License. 13*f67950b2SNasf-Fan# 14*f67950b2SNasf-Fan# When distributing Covered Code, include this CDDL HEADER in each 15*f67950b2SNasf-Fan# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*f67950b2SNasf-Fan# If applicable, add the following below this CDDL HEADER, with the 17*f67950b2SNasf-Fan# fields enclosed by brackets "[]" replaced with your own identifying 18*f67950b2SNasf-Fan# information: Portions Copyright [yyyy] [name of copyright owner] 19*f67950b2SNasf-Fan# 20*f67950b2SNasf-Fan# CDDL HEADER END 21*f67950b2SNasf-Fan# 22*f67950b2SNasf-Fan 23*f67950b2SNasf-Fan# 24*f67950b2SNasf-Fan# Copyright 2009 Sun Microsystems, Inc. All rights reserved. 25*f67950b2SNasf-Fan# Use is subject to license terms. 26*f67950b2SNasf-Fan# 27*f67950b2SNasf-Fan 28*f67950b2SNasf-Fan# 29*f67950b2SNasf-Fan# Copyright (c) 2017 by Fan Yong. Fan rights reserved. 30*f67950b2SNasf-Fan# Copyright 2019 Joyent, Inc. 31*f67950b2SNasf-Fan# 32*f67950b2SNasf-Fan 33*f67950b2SNasf-Fan. $STF_SUITE/tests/functional/projectquota/projectquota_common.kshlib 34*f67950b2SNasf-Fan 35*f67950b2SNasf-Fan# 36*f67950b2SNasf-Fan# DESCRIPTION: 37*f67950b2SNasf-Fan# Check changing project ID for the file with directory-based 38*f67950b2SNasf-Fan# extended attributes. 39*f67950b2SNasf-Fan# 40*f67950b2SNasf-Fan# 41*f67950b2SNasf-Fan# STRATEGY: 42*f67950b2SNasf-Fan# 1. create new file with default project ID 43*f67950b2SNasf-Fan# 2. set non-ACL extended attributes on the file 44*f67950b2SNasf-Fan# 3. use zfs projectspace to check the object usage 45*f67950b2SNasf-Fan# 4. change the file's project ID 46*f67950b2SNasf-Fan# 5. use zfs projectspace to check the object usage again 47*f67950b2SNasf-Fan# 48*f67950b2SNasf-Fan 49*f67950b2SNasf-Fanfunction cleanup 50*f67950b2SNasf-Fan{ 51*f67950b2SNasf-Fan log_must rm -f $PRJGUARD 52*f67950b2SNasf-Fan log_must rm -f $PRJFILE 53*f67950b2SNasf-Fan} 54*f67950b2SNasf-Fan 55*f67950b2SNasf-Fanlog_onexit cleanup 56*f67950b2SNasf-Fan 57*f67950b2SNasf-Fanlog_assert "Check changing project ID with directory-based extended attributes" 58*f67950b2SNasf-Fan 59*f67950b2SNasf-Fanlog_must zfs set xattr=on $QFS 60*f67950b2SNasf-Fan 61*f67950b2SNasf-Fanlog_must touch $PRJGUARD 62*f67950b2SNasf-Fan# log_must chattr -p $PRJID1 $PRJGUARD 63*f67950b2SNasf-Fanlog_must zfs project -s -p $PRJID1 $PRJGUARD 64*f67950b2SNasf-Fanlog_must touch $PRJFILE 65*f67950b2SNasf-Fan 66*f67950b2SNasf-Fan# log_must setfattr -n trusted.ea1 -v val1 $PRJFILE 67*f67950b2SNasf-Fan# log_must setfattr -n trusted.ea2 -v val2 $PRJFILE 68*f67950b2SNasf-Fan# log_must setfattr -n trusted.ea3 -v val3 $PRJFILE 69*f67950b2SNasf-Fanecho "dummy attribute data" >/tmp/attr.$$ 70*f67950b2SNasf-Fanlog_must runat $PRJFILE cp /tmp/attr.$$ trusted.ea1 71*f67950b2SNasf-Fanlog_must runat $PRJFILE cp /tmp/attr.$$ trusted.ea2 72*f67950b2SNasf-Fanlog_must runat $PRJFILE cp /tmp/attr.$$ trusted.ea3 73*f67950b2SNasf-Fanrm /tmp/attr.$$ 74*f67950b2SNasf-Fan 75*f67950b2SNasf-Fansync_pool 76*f67950b2SNasf-Fantypeset prj_bef=$(project_obj_count $QFS $PRJID1) 77*f67950b2SNasf-Fan 78*f67950b2SNasf-Fan# log_must chattr -p $PRJID1 $PRJFILE 79*f67950b2SNasf-Fanlog_must zfs project -s -p $PRJID1 $PRJFILE 80*f67950b2SNasf-Fansync_pool 81*f67950b2SNasf-Fantypeset prj_aft=$(project_obj_count $QFS $PRJID1) 82*f67950b2SNasf-Fan 83*f67950b2SNasf-Fan[[ $prj_aft -ge $((prj_bef + 5)) ]] || 84*f67950b2SNasf-Fan log_fail "new value ($prj_aft) is NOT 5 largr than old one ($prj_bef)" 85*f67950b2SNasf-Fan 86*f67950b2SNasf-Fanlog_pass "Changing project ID with directory-based extended attributes pass" 87