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. All 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# 37*f67950b2SNasf-Fan# DESCRIPTION: 38*f67950b2SNasf-Fan# Check project ID/flags can be set/inherited properly 39*f67950b2SNasf-Fan# 40*f67950b2SNasf-Fan# 41*f67950b2SNasf-Fan# STRATEGY: 42*f67950b2SNasf-Fan# 1. Create a regular file and a directroy. 43*f67950b2SNasf-Fan# 2. Set project ID on both directroy and regular file. 44*f67950b2SNasf-Fan# 3. New created subdir or regular file should inherit its parent's 45*f67950b2SNasf-Fan# project ID if its parent has project inherit flag. 46*f67950b2SNasf-Fan# 4. New created subdir should inherit its parent project's inherit flag. 47*f67950b2SNasf-Fan# 48*f67950b2SNasf-Fan 49*f67950b2SNasf-Fanfunction cleanup 50*f67950b2SNasf-Fan{ 51*f67950b2SNasf-Fan log_must rm -f $PRJFILE 52*f67950b2SNasf-Fan log_must rm -rf $PRJDIR 53*f67950b2SNasf-Fan} 54*f67950b2SNasf-Fan 55*f67950b2SNasf-Fanlog_onexit cleanup 56*f67950b2SNasf-Fan 57*f67950b2SNasf-Fanlog_assert "Check project ID/flags can be set/inherited properly" 58*f67950b2SNasf-Fan 59*f67950b2SNasf-Fanlog_must touch $PRJFILE 60*f67950b2SNasf-Fanlog_must mkdir $PRJDIR 61*f67950b2SNasf-Fan 62*f67950b2SNasf-Fan# log_must chattr -p $PRJID1 $PRJFILE 63*f67950b2SNasf-Fanlog_must zfs project -s -p $PRJID1 $PRJFILE 64*f67950b2SNasf-Fan# log_must eval "lsattr -p $PRJFILE | grep $PRJID1 | grep -v '\-P[- ]* '" 65*f67950b2SNasf-Fanlog_must eval "zfs project $PRJFILE | grep $PRJID1" 66*f67950b2SNasf-Fan# log_must chattr -p $PRJID1 $PRJDIR 67*f67950b2SNasf-Fanlog_must zfs project -s -p $PRJID1 $PRJDIR 68*f67950b2SNasf-Fan# log_must eval "lsattr -pd $PRJDIR | grep $PRJID1 | grep -v '\-P[- ]* '" 69*f67950b2SNasf-Fanlog_must eval "zfs project $PRJDIR | grep $PRJID1" 70*f67950b2SNasf-Fan 71*f67950b2SNasf-Fan# "-1" is invalid project ID, should be denied 72*f67950b2SNasf-Fan# log_mustnot chattr -p -1 $PRJFILE 73*f67950b2SNasf-Fanlog_mustnot zfs project -s -p -1 $PRJFILE 74*f67950b2SNasf-Fan# log_must eval "lsattr -p $PRJFILE | grep $PRJID1 | grep -v '\-P[- ]* '" 75*f67950b2SNasf-Fanlog_must eval "zfs project $PRJFILE | grep $PRJID1" 76*f67950b2SNasf-Fan 77*f67950b2SNasf-Fanlog_must mkdir $PRJDIR/dchild 78*f67950b2SNasf-Fan# log_must eval "lsattr -pd $PRJDIR/dchild | grep $PRJID1 | grep '\-P[- ]* '" 79*f67950b2SNasf-Fanlog_must eval "zfs project -d $PRJDIR/dchild | grep $PRJID1" 80*f67950b2SNasf-Fanlog_must touch $PRJDIR/fchild 81*f67950b2SNasf-Fan# log_must eval "lsattr -p $PRJDIR/fchild | grep $PRJID1" 82*f67950b2SNasf-Fanlog_must eval "zfs project $PRJDIR/fchild | grep $PRJID1" 83*f67950b2SNasf-Fan 84*f67950b2SNasf-Fanlog_must touch $PRJDIR/dchild/foo 85*f67950b2SNasf-Fan# log_must eval "lsattr -p $PRJDIR/dchild/foo | grep $PRJID1" 86*f67950b2SNasf-Fanlog_must eval "zfs project $PRJDIR/dchild/foo | grep $PRJID1" 87*f67950b2SNasf-Fan 88*f67950b2SNasf-Fan# do not support project ID/flag on block special file 89*f67950b2SNasf-Fanlog_must mknod $PRJDIR/dchild/b_foo b 124 124 90*f67950b2SNasf-Fan# log_mustnot lsattr -p $PRJDIR/dchild/b_foo 91*f67950b2SNasf-Fan# log_mustnot chattr -p 123 $PRJDIR/dchild/b_foo 92*f67950b2SNasf-Fanlog_mustnot zfs project -s -p 123 $PRJDIR/dchild/b_foo 93*f67950b2SNasf-Fan 94*f67950b2SNasf-Fan# do not support project ID/flag on character special file 95*f67950b2SNasf-Fanlog_must mknod $PRJDIR/dchild/c_foo c 125 125 96*f67950b2SNasf-Fan# log_mustnot lsattr -p $PRJDIR/dchild/c_foo 97*f67950b2SNasf-Fan# log_mustnot chattr -p 123 $PRJDIR/dchild/c_foo 98*f67950b2SNasf-Fanlog_mustnot zfs project -s -p 123 $PRJDIR/dchild/c_foo 99*f67950b2SNasf-Fan 100*f67950b2SNasf-Fanlog_pass "Check project ID/flags can be set/inherited properly" 101