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 https://opensource.org/licenses/CDDL-1.0. 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# 31 32. $STF_SUITE/tests/functional/projectquota/projectquota_common.kshlib 33 34# 35# DESCRIPTION: 36# Check the zfs projectspace with kinds of parameters 37# 38# 39# STRATEGY: 40# 1. set zfs projectspace to a fs 41# 2. write some data to the fs with specified project ID 42# 3. use zfs projectspace with all possible parameters to check the result 43# 4. use zfs projectspace with some bad parameters to check the result 44# 45 46function cleanup 47{ 48 datasetexists $snap_fs && destroy_dataset $snap_fs 49 50 log_must cleanup_projectquota 51} 52 53if ! lsattr -pd > /dev/null 2>&1; then 54 log_unsupported "Current e2fsprogs does not support set/show project ID" 55fi 56 57log_onexit cleanup 58 59log_assert "Check the zfs projectspace with all possible parameters" 60 61set -A good_params -- "-H" "-p" "-o type,name,used,quota" "-o name,used,quota" \ 62 "-o used,quota" "-o objused" "-o quota" "-s type" "-s name" "-s used" \ 63 "-s quota" "-S type" "-S name" "-S used" "-S quota" 64 65typeset snap_fs=$QFS@snap 66 67log_must zfs set projectquota@$PRJID1=100m $QFS 68log_must zfs set projectobjquota@$PRJID1=100 $QFS 69mkmount_writable $QFS 70log_must user_run $PUSER mkdir $PRJDIR 71log_must chattr +P -p $PRJID1 $PRJDIR 72log_must user_run $PUSER mkfile 50m $PRJDIR/qf 73sync_all_pools 74 75log_must zfs snapshot $snap_fs 76 77for param in "${good_params[@]}"; do 78 log_must eval "zfs projectspace $param $QFS >/dev/null 2>&1" 79 log_must eval "zfs projectspace $param $snap_fs >/dev/null 2>&1" 80done 81 82log_assert "Check the zfs projectspace with some bad parameters" 83 84set -A bad_params -- "-i" "-n" "-P" "-t posixuser" 85 86for param in "${bad_params[@]}"; do 87 log_mustnot eval "zfs projectspace $param $QFS >/dev/null 2>&1" 88 log_mustnot eval "zfs projectspace $param $snap_fs >/dev/null 2>&1" 89done 90 91log_pass "zfs projectspace with kinds of parameters pass" 92