1 #!/usr/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 2007 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
26 #
27
28 . ${STF_SUITE}/include/libtest.shlib
29
30 # create a truckload of files with ACLS and destroy them.
31 # Theoretically this test case should also verify that the storage
32 # pool space has not been diminished by this operation.
33 # @parameter: $1 the storage pool from which it draws the file systems.
34 # @return: 0 if all the work completed OK.
35 # @use: TEST_BASE_DIR TOTAL_COUNT
36
37 typeset -i runat=0
38 typeset -i scaledcount
39 typeset dataset=$1
40 typeset ddirb=${TEST_BASE_DIR%%/}/acld.$$
41 typeset runpids=
42 typeset tfilesys=
43 typeset tmountpoint=
44
45 if [[ -z $dataset ]]; then
46 NOTE "$fn: Insufficient parameters (need 1, got $#)"
47 exit 1
48 fi
49
50 (( scaledcount = TOTAL_COUNT * 100 ))
51
52 function clean_entities
53 {
54 [[ -n $runpids ]] && kill -9 $runpids
55 [[ -d $tmountpoint ]] && zfs umount -f $tmountpoint
56 [[ -n $tfilesys ]] && zfs destroy -f $tfilesys
57 rm -rf $tmountpoint $ddirb
58 }
59
60 log_onexit clean_entities
61
62 USE_F=""
63 while (( runat < scaledcount )); do
64 typeset -i pid=
65 typeset file=
66 typeset group=
67 typeset user=
68
69 tfilesys=$dataset/$runat
70 file=$mountpoint/file.$runat
71
72 log_must mkdir -p $tmountpoint
73 log_must zfs create $tfilesys
74 log_must zfs mountpoint=$tmountpoint $tfilesys
75 log_must cp /etc/passwd $file
76
77 for user in $(getent passwd | nawk -F: '{print $1}'); do
78 chmod A=user:$user:r--,user::rwx,group::r--,other::r--,mask:r--\
79 $file &
80 runpids="$runpids $!"
81 done
82 for pid in $runpids; do
83 wait $pid
84 status=$?
85 if (( status != 0 )); then
86 log_note "chmod users: failed on $file [$status]"
87 fi
88 done
89 runpids=
90 for group in $(getent groups | nawk -F: '{print $1}'); do
91 chmod A=user::rwx,group:$group:r--,group::r--,other::r--,mask:r--\
92 $file &
93 runpids="$runpids $!"
94 done
95 for pid in $runpids; do
96 wait $pid
97 status=$?
98 if (( status != 0 )); then
99 log_note "chmod groups: failed on $file [$status]"
100 fi
101 done
102 runpids=
103
104 log_must rm -f $file
105 # Does a forced unmount every second iteration
106 if [[ -n $USE_F ]] ; then
107 USE_F=""
108 else
109 USE_F="-f"
110 fi
111
112 log_must zfs umount $USE_F $tmountpoint
113 log_must zfs destroy $tfilesys
114 log_must rm -rf $tmountpoint
115
116 tmountpoint=
117 (( runat = runat + 1 ))
118 done