xref: /illumos-gate/usr/src/test/zfs-tests/tests/functional/projectquota/projectid_001_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#	Check project ID/flags can be set/inherited properly
39#
40#
41# STRATEGY:
42#	1. Create a regular file and a directroy.
43#	2. Set project ID on both directroy and regular file.
44#	3. New created subdir or regular file should inherit its parent's
45#	   project ID if its parent has project inherit flag.
46#	4. New created subdir should inherit its parent project's inherit flag.
47#
48
49function cleanup
50{
51	log_must rm -f $PRJFILE
52	log_must rm -rf $PRJDIR
53}
54
55log_onexit cleanup
56
57log_assert "Check project ID/flags can be set/inherited properly"
58
59log_must touch $PRJFILE
60log_must mkdir $PRJDIR
61
62# log_must chattr -p $PRJID1 $PRJFILE
63log_must zfs project -s -p $PRJID1 $PRJFILE
64# log_must eval "lsattr -p $PRJFILE | grep $PRJID1 | grep -v '\-P[- ]* '"
65log_must eval "zfs project $PRJFILE | grep $PRJID1"
66# log_must chattr -p $PRJID1 $PRJDIR
67log_must zfs project -s -p $PRJID1 $PRJDIR
68# log_must eval "lsattr -pd $PRJDIR | grep $PRJID1 | grep -v '\-P[- ]* '"
69log_must eval "zfs project $PRJDIR | grep $PRJID1"
70
71# "-1" is invalid project ID, should be denied
72# log_mustnot chattr -p -1 $PRJFILE
73log_mustnot zfs project -s -p -1 $PRJFILE
74# log_must eval "lsattr -p $PRJFILE | grep $PRJID1 | grep -v '\-P[- ]* '"
75log_must eval "zfs project $PRJFILE | grep $PRJID1"
76
77log_must mkdir $PRJDIR/dchild
78# log_must eval "lsattr -pd $PRJDIR/dchild | grep $PRJID1 | grep '\-P[- ]* '"
79log_must eval "zfs project -d $PRJDIR/dchild | grep $PRJID1"
80log_must touch $PRJDIR/fchild
81# log_must eval "lsattr -p $PRJDIR/fchild | grep $PRJID1"
82log_must eval "zfs project $PRJDIR/fchild | grep $PRJID1"
83
84log_must touch $PRJDIR/dchild/foo
85# log_must eval "lsattr -p $PRJDIR/dchild/foo | grep $PRJID1"
86log_must eval "zfs project $PRJDIR/dchild/foo | grep $PRJID1"
87
88# do not support project ID/flag on block special file
89log_must mknod $PRJDIR/dchild/b_foo b 124 124
90# log_mustnot lsattr -p $PRJDIR/dchild/b_foo
91# log_mustnot chattr -p 123 $PRJDIR/dchild/b_foo
92log_mustnot zfs project -s -p 123 $PRJDIR/dchild/b_foo
93
94# do not support project ID/flag on character special file
95log_must mknod $PRJDIR/dchild/c_foo c 125 125
96# log_mustnot lsattr -p $PRJDIR/dchild/c_foo
97# log_mustnot chattr -p 123 $PRJDIR/dchild/c_foo
98log_mustnot zfs project -s -p 123 $PRJDIR/dchild/c_foo
99
100log_pass "Check project ID/flags can be set/inherited properly"
101