xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/projectquota/projectid_002_pos.ksh (revision f67950b21e185934ccabe311516f4dcbdb00ef79)
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# Copyright 2019 Joyent, Inc.
31#
32
33. $STF_SUITE/tests/functional/projectquota/projectquota_common.kshlib
34
35#
36#
37# DESCRIPTION:
38#	Project ID affects POSIX behavior
39#
40#
41# STRATEGY:
42#	1. Create three directories
43#	2. Set tdir1 and tdir3 project ID as PRJID1,
44#	   set tdir2 project ID as PRJID2.
45#	3. Create regular file under tdir1. It inherits tdir1 proejct ID.
46#	4. Hardlink from tdir1's child to tdir2 should be denied,
47#	   move tdir1's child to tdir2 will be object recreated.
48#	5. Hardlink from tdir1's child to tdir3 should succeed.
49#
50
51function cleanup
52{
53	log_must rm -rf $PRJDIR1
54	log_must rm -rf $PRJDIR2
55	log_must rm -rf $PRJDIR3
56}
57
58log_onexit cleanup
59
60log_assert "Project ID affects POSIX behavior"
61
62log_must mkdir $PRJDIR1
63log_must mkdir $PRJDIR2
64log_must mkdir $PRJDIR3
65log_must mkdir $PRJDIR3/dir
66
67# log_must chattr +P -p $PRJID1 $PRJDIR1
68log_must zfs project -s -p $PRJID1 $PRJDIR1
69# log_must chattr +P -p $PRJID2 $PRJDIR2
70log_must zfs project -s -p $PRJID2 $PRJDIR2
71
72log_must touch $PRJDIR1/tfile1
73log_must touch $PRJDIR1/tfile2
74# log_must eval "lsattr -p $PRJDIR1/tfile1 | grep $PRJID1"
75log_must eval "zfs project $PRJDIR1/tfile1 | grep $PRJID1"
76
77log_mustnot ln $PRJDIR1/tfile1 $PRJDIR2/tfile2
78
79log_must mv $PRJDIR1/tfile1 $PRJDIR2/tfile2
80# log_must eval "lsattr -p $PRJDIR2/tfile2 | grep $PRJID2"
81log_must eval "zfs project $PRJDIR2/tfile2 | grep $PRJID2"
82
83log_must mv $PRJDIR3/dir $PRJDIR2/
84# log_must eval "lsattr -dp $PRJDIR2/dir | grep $PRJID2"
85log_must eval "zfs project -d $PRJDIR2/dir | grep $PRJID2"
86
87# log_must chattr +P -p $PRJID1 $PRJDIR3
88log_must zfs project -s -p $PRJID1 $PRJDIR3
89log_must ln $PRJDIR1/tfile2 $PRJDIR3/tfile3
90
91log_pass "Project ID affects POSIX behavior"
92