1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
# $NetBSD: t_miscquota.sh,v 1.8 2013/01/22 06:24:11 dholland Exp $
#
# Copyright (c) 2011 Manuel Bouyer
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
test_case_root walk_list_user quota_walk_list \
"walk user quota list over several disk blocks" -b le 1 user
test_case_root psnapshot_user quota_snap \
"create a persistent shapshot of quota-enabled fs, and do some writes" \
-b le 1 user
test_case_root npsnapshot_user quota_snap \
"create a non-persistent shapshot of quota-enabled fs, and do some writes" \
-boL le 1 user
test_case_root psnapshot_unconf_user quota_snap \
"create a persistent shapshot of quota-enabled fs, and do some writes and unconf" \
-boC le 1 user
test_case_root npsnapshot_unconf_user quota_snap \
"create a non-persistent shapshot of quota-enabled fs, and do some writes and unconf" \
-boLC le 1 user
test_case log_unlink quota_log \
"an unlinked file cleaned by the log replay should update quota" \
-l le 1 user
test_case log_unlink_remount quota_log \
"an unlinked file cleaned by the log replay after remount" \
-oRL le 1 user
test_case_root default_deny_user quota_default_deny \
"new quota entry denied by default entry" 5 -b le 1 user
test_case_root default_deny_user_big quota_default_deny \
"new quota entry denied by default entry, with list on more than one block" 5000 -b le 1 user
quota_walk_list()
{
create_ffs_server $*
local q=$4
local expect
case ${q} in
user)
expect=u
fail=g
;;
group)
expect=g
fail=u
;;
*)
atf_fail "wrong quota type"
;;
esac
# create 100 users, all in the same hash list
local i=1;
while [ $i -lt 101 ]; do
atf_check -s exit:0 \
env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -${expect} \
-s10k/20 -h40M/50k -t 2W/3D $((i * 4096))
i=$((i + 1))
done
# do a repquota
atf_check -s exit:0 -o 'match:user 409600 block *81920 20 0' \
env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -x -${expect} /mnt
rump_quota_shutdown
}
quota_snap()
{
local flag=$1; shift
create_ffs $*
local q=$3
local expect
case ${q} in
user)
expect=u
fail=g
;;
group)
expect=g
fail=u
;;
*)
atf_fail "wrong quota type"
;;
esac
#start our server which takes a snapshot
atf_check -s exit:0 -o ignore \
$(atf_get_srcdir)/h_quota2_tests ${flag} 4 ${IMG} ${RUMP_SERVER}
# create a few users
local i=1;
while [ $i -lt 11 ]; do
atf_check -s exit:0 \
env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt edquota -${expect} \
-s10k/20 -h40M/50k -t 2W/3D $i
i=$((i + 1))
done
# we should have 5 files (root + 4 regular files)
atf_check -s exit:0 \
-o 'match:- - 7days 5 - - 7days' \
env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt repquota -av
#shutdown and check filesystem
rump_quota_shutdown
}
quota_log()
{
local srv2args=$1; shift
create_ffs $*
local q=$3
local expect
case ${q} in
user)
expect=u
fail=g
;;
group)
expect=g
fail=u
;;
*)
atf_fail "wrong quota type"
;;
esac
#start our server which create a file and unlink while keeping
# it open. The server halts itself without flush
atf_check -s exit:0 -o ignore \
$(atf_get_srcdir)/h_quota2_tests -loU 5 ${IMG} ${RUMP_SERVER}
# we should have one unlinked file, but the log covers it.
atf_check -s exit:0 -o match:'3 files' -e ignore \
fsck_ffs -nf -F ${IMG}
# have a kernel mount the fs again; it should cleanup the
# unlinked file
atf_check -o ignore -e ignore $(atf_get_srcdir)/h_quota2_tests \
${srv2args} -b 5 ${IMG} ${RUMP_SERVER}
#shutdown and check filesystem
rump_quota_shutdown
}
quota_default_deny()
{
local nusers=$1; shift
create_ffs_server $*
local q=$4
local expect
case ${q} in
user)
expect=u
fail=g
;;
group)
expect=g
fail=u
;;
*)
atf_fail "wrong quota type"
;;
esac
# create $nusers users, so we are sure the free list has entries
# from block 1. Start from 10, as non-root id is 1.
# set default to deny all
( echo "@format netbsd-quota-dump v1"
echo "# idtype id objtype hard soft usage expire grace"
echo "$q default block 0 0 0 0 0"
echo "$q default file 0 0 0 0 0"
local i=10;
while [ $i -lt $(($nusers + 10)) ]; do
echo "$q $i block 0 0 0 0 0"
echo "$q $i file 0 0 0 0 0"
i=$((i + 1))
done
) | atf_check -s exit:0 \
env LD_PRELOAD=/usr/lib/librumphijack.so RUMPHIJACK=vfs=getvfsstat,blanket=/mnt quotarestore -d /mnt
atf_check -s exit:0 rump.halt
#now start the server which does the limits tests
$(atf_get_srcdir)/h_quota2_tests -oC -b 0 ${IMG} ${RUMP_SERVER}
rump_quota_shutdown
}
|