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. All rights reserved. 30# 31 32. $STF_SUITE/tests/functional/projectquota/projectquota_common.kshlib 33 34# 35# 36# DESCRIPTION: 37# Check the basic function of the project{obj}quota 38# 39# 40# STRATEGY: 41# 1. Set projectquota and overwrite the quota size. 42# 2. The write operation should fail with Disc quota exceeded 43# 3. Set projectobjquota and overcreate the quota size. 44# 4. More create should fail with Disc quota exceeded 45# 5. More chattr to such project should fail with Disc quota exceeded 46# 47 48function cleanup 49{ 50 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 "If operation overwrite project{obj}quota size, it will fail" 60 61mkmount_writable $QFS 62 63log_note "Check the projectquota@$PRJID1" 64log_must user_run $PUSER mkdir $PRJDIR 65log_must chattr +P -p $PRJID1 $PRJDIR 66 67log_must zfs set projectquota@$PRJID1=$PQUOTA_LIMIT $QFS 68log_must user_run $PUSER mkfile $PQUOTA_LIMIT $PRJDIR/qf 69sync_pool 70log_mustnot user_run $PUSER mkfile 1 $PRJDIR/of 71 72log_must rm -rf $PRJDIR 73 74log_note "Check the projectobjquota@$PRJID2" 75log_must zfs set xattr=sa $QFS 76log_must user_run $PUSER mkdir $PRJDIR 77log_must chattr +P -p $PRJID2 $PRJDIR 78 79log_must zfs set projectobjquota@$PRJID2=$PQUOTA_OBJLIMIT $QFS 80log_must user_run $PUSER mkfiles $PRJDIR/qf_ $((PQUOTA_OBJLIMIT - 1)) 81sync_pool 82log_mustnot user_run $PUSER mkfile 1 $PRJDIR/of 83 84log_must user_run $PUSER touch $PRJFILE 85log_must user_run $PUSER chattr -p 123 $PRJFILE 86log_mustnot user_run $PUSER chattr -p $PRJID2 $PRJFILE 87 88log_pass "Operation overwrite project{obj}quota size failed as expect" 89