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