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# Project ID affects POSIX behavior 38# 39# 40# STRATEGY: 41# 1. Create three directories 42# 2. Set tdir1 and tdir3 project ID as PRJID1, 43# set tdir2 project ID as PRJID2. 44# 3. Create regular file under tdir1. It inherits tdir1 project ID. 45# 4. Hardlink from tdir1's child to tdir2 should be denied, 46# move tdir1's child to tdir2 will be object recreated. 47# 5. Hardlink from tdir1's child to tdir3 should succeed. 48# 49 50function cleanup 51{ 52 log_must rm -rf $PRJDIR1 53 log_must rm -rf $PRJDIR2 54 log_must rm -rf $PRJDIR3 55} 56 57if ! lsattr -pd > /dev/null 2>&1; then 58 log_unsupported "Current e2fsprogs does not support set/show project ID" 59fi 60 61log_onexit cleanup 62 63log_assert "Project ID affects POSIX behavior" 64 65log_must mkdir $PRJDIR1 66log_must mkdir $PRJDIR2 67log_must mkdir $PRJDIR3 68log_must mkdir $PRJDIR3/dir 69 70log_must chattr +P -p $PRJID1 $PRJDIR1 71log_must chattr +P -p $PRJID2 $PRJDIR2 72 73log_must touch $PRJDIR1/tfile1 74log_must touch $PRJDIR1/tfile2 75log_must eval "lsattr -p $PRJDIR1/tfile1 | grep $PRJID1" 76 77log_mustnot ln $PRJDIR1/tfile1 $PRJDIR2/tfile2 78 79log_must mv $PRJDIR1/tfile1 $PRJDIR2/tfile2 80log_must eval "lsattr -p $PRJDIR2/tfile2 | grep $PRJID2" 81 82log_must mv $PRJDIR3/dir $PRJDIR2/ 83log_must eval "lsattr -dp $PRJDIR2/dir | grep $PRJID2" 84 85log_must chattr +P -p $PRJID1 $PRJDIR3 86log_must ln $PRJDIR1/tfile2 $PRJDIR3/tfile3 87 88log_pass "Project ID affects POSIX behavior" 89