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# 31*f67950b2SNasf-Fan 32*f67950b2SNasf-Fan. $STF_SUITE/tests/functional/projectquota/projectquota_common.kshlib 33*f67950b2SNasf-Fan 34*f67950b2SNasf-Fan# 35*f67950b2SNasf-Fan# 36*f67950b2SNasf-Fan# DESCRIPTION: 37*f67950b2SNasf-Fan# Check project ID/flag can be operated via "zfs project" 38*f67950b2SNasf-Fan# 39*f67950b2SNasf-Fan# 40*f67950b2SNasf-Fan# STRATEGY: 41*f67950b2SNasf-Fan# 1. Create a tree with 4 level directories. 42*f67950b2SNasf-Fan# 2. Set project ID on both directory and regular file via 43*f67950b2SNasf-Fan# "zfs project -p". 44*f67950b2SNasf-Fan# 3. Check the project ID via "zfs project". 45*f67950b2SNasf-Fan# 4. Set project inherit flag on kinds of level directories (and its 46*f67950b2SNasf-Fan# descendants for some)) via "zfs project -s [-r]". 47*f67950b2SNasf-Fan# 5. Check the project ID and inherit flag via "zfs project -r". 48*f67950b2SNasf-Fan# 6. Clear the project inherit flag from some directories (and its 49*f67950b2SNasf-Fan# descendants for some) via "zfs project -C [-r]". 50*f67950b2SNasf-Fan# 7. Check the project ID and inherit flag via "zfs project -r". 51*f67950b2SNasf-Fan# 52*f67950b2SNasf-Fan 53*f67950b2SNasf-Fanfunction cleanup 54*f67950b2SNasf-Fan{ 55*f67950b2SNasf-Fan log_must rm -rf $PRJDIR 56*f67950b2SNasf-Fan} 57*f67950b2SNasf-Fan 58*f67950b2SNasf-Fanlog_onexit cleanup 59*f67950b2SNasf-Fan 60*f67950b2SNasf-Fanlog_assert "Check project ID/flag can be operated via 'zfs project'" 61*f67950b2SNasf-Fan 62*f67950b2SNasf-Fanlog_must mkdir $PRJDIR 63*f67950b2SNasf-Fan 64*f67950b2SNasf-Fanlog_must mkdir $PRJDIR/a1 65*f67950b2SNasf-Fanlog_must mkdir $PRJDIR/b1 66*f67950b2SNasf-Fanlog_must touch $PRJDIR/c1 67*f67950b2SNasf-Fan 68*f67950b2SNasf-Fanlog_must mkdir $PRJDIR/a1/a2 69*f67950b2SNasf-Fanlog_must mkdir $PRJDIR/a1/b2 70*f67950b2SNasf-Fanlog_must touch $PRJDIR/a1/c2 71*f67950b2SNasf-Fan 72*f67950b2SNasf-Fanlog_must mkdir $PRJDIR/b1/a2 73*f67950b2SNasf-Fanlog_must mkdir $PRJDIR/b1/b2 74*f67950b2SNasf-Fanlog_must touch $PRJDIR/b1/c2 75*f67950b2SNasf-Fan 76*f67950b2SNasf-Fanlog_must mkdir $PRJDIR/a1/a2/a3 77*f67950b2SNasf-Fanlog_must mkdir $PRJDIR/a1/a2/b3 78*f67950b2SNasf-Fanlog_must touch $PRJDIR/a1/a2/c3 79*f67950b2SNasf-Fan 80*f67950b2SNasf-Fanlog_must mkdir $PRJDIR/b1/a2/a3 81*f67950b2SNasf-Fan 82*f67950b2SNasf-Fanlog_must touch $PRJDIR/a1/a2/a3/c4 83*f67950b2SNasf-Fanlog_must touch $PRJDIR/a1/a2/a3/d4 84*f67950b2SNasf-Fan 85*f67950b2SNasf-Fanlog_must zfs project -p $PRJID1 $PRJDIR/a1/c2 86*f67950b2SNasf-Fanlog_must eval "zfs project $PRJDIR/a1/c2 | grep $PRJID1" 87*f67950b2SNasf-Fan 88*f67950b2SNasf-Fanlog_must zfs project -p $PRJID2 $PRJDIR/a1/a2/a3 89*f67950b2SNasf-Fanlog_must eval "zfs project -d $PRJDIR/a1/a2/a3 | grep $PRJID2" 90*f67950b2SNasf-Fan 91*f67950b2SNasf-Fanlog_must zfs project -s $PRJDIR/b1/a2 92*f67950b2SNasf-Fanlog_must eval "zfs project -d $PRJDIR/b1/a2 | grep ' P '" 93*f67950b2SNasf-Fanlog_must eval "zfs project -d $PRJDIR/b1/a2/a3 | grep ' \- '" 94*f67950b2SNasf-Fan 95*f67950b2SNasf-Fanlog_must zfs project -s -r -p $PRJID2 $PRJDIR/a1/a2 96*f67950b2SNasf-Fanlog_must zfs project -c -r $PRJDIR/a1/a2 97*f67950b2SNasf-Fanlog_must eval "zfs project -d $PRJDIR/a1/a2/a3 | grep ' P '" 98*f67950b2SNasf-Fanlog_must eval "zfs project $PRJDIR/a1/a2/a3/c4 | grep $PRJID2" 99*f67950b2SNasf-Fan 100*f67950b2SNasf-Fanlog_must zfs project -C $PRJDIR/a1/a2/a3 101*f67950b2SNasf-Fanlog_must eval "zfs project -cr $PRJDIR/a1/a2 | grep 'inherit flag is not set'" 102*f67950b2SNasf-Fanlog_must eval "zfs project $PRJDIR/a1/a2/a3/c4 | grep $PRJID2 | grep -v not" 103*f67950b2SNasf-Fanlog_must zfs project -p 123 $PRJDIR/a1/a2/a3/c4 104*f67950b2SNasf-Fanlog_must eval "zfs project -c -r $PRJDIR/a1/a2 | grep 123 | grep 'not set'" 105*f67950b2SNasf-Fanlog_mustnot eval "zfs project -cr -p 123 $PRJDIR/a1/a2 | grep c4 | grep -v not" 106*f67950b2SNasf-Fan 107*f67950b2SNasf-Fanlog_must zfs project -C -r $PRJDIR/a1/a2/a3 108*f67950b2SNasf-Fanlog_must eval "zfs project -cr $PRJDIR/a1/a2 | grep a3 | grep 'not set'" 109*f67950b2SNasf-Fanlog_must eval "zfs project -cr $PRJDIR/a1/a2 | grep d4 | grep 'not set'" 110*f67950b2SNasf-Fanlog_must eval "zfs project $PRJDIR/a1/a2/a3/d4 | grep '0 \-'" 111*f67950b2SNasf-Fan 112*f67950b2SNasf-Fanlog_must eval \ 113*f67950b2SNasf-Fan "zfs project -cr -0 $PRJDIR/a1/a2 | xargs -0 zfs project -s -p $PRJID2" 114*f67950b2SNasf-Fanlog_mustnot eval "zfs project -cr $PRJDIR/a1/a2 | grep a3 | grep 'not set'" 115*f67950b2SNasf-Fanlog_mustnot eval "zfs project -cr $PRJDIR/a1/a2 | grep d4 | grep 'not set'" 116*f67950b2SNasf-Fan 117*f67950b2SNasf-Fanlog_must zfs project -C -r -k $PRJDIR/a1/a2 118*f67950b2SNasf-Fanlog_must eval "zfs project -d $PRJDIR/a1/a2/b3 | grep '$PRJID2 \- '" 119*f67950b2SNasf-Fan 120*f67950b2SNasf-Fanlog_pass "Check project ID/flag can be operated via 'zfs project'" 121