1 # $NetBSD: t_check_quotas.sh,v 1.2 2011/03/06 17:08:41 bouyer Exp $
3 # Copyright (c) 2011 Manuel Bouyer
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 # POSSIBILITY OF SUCH DAMAGE.
30 test_case corrupt_list_
${e}_
${v} corrupt_list \
31 "recovery of corrupted free list in" ${e} ${v}
32 test_case expand1_list_
${e}_
${v} expand_list \
33 "allocation of direct block in" 40 ${e} ${v}
34 test_case expand2_list_
${e}_
${v} expand_list \
35 "allocation of indirect block in" 1000 ${e} ${v}
42 local blkno
=$
(printf "inode 3\nblks\n" |
/sbin
/fsdb
-nF -f ${IMG} |
awk '$1 == "0:" {print $2}')
43 blkno
=$
(($blkno * 512 + 104))
45 atf_check
-o ignore
-e ignore
dd if=/dev
/zero of
=${IMG} bs
=1 \
46 count
=8 seek
=${blkno} conv
=notrunc
48 -o "match:QUOTA ENTRY NOT IN LIST \(FIXED\)" \
49 fsck_ffs
-fp -F ${IMG}
50 atf_check
-s exit:0 -o "match:3 files" fsck_ffs
-nf -F ${IMG}
56 local expected_files
=$
((nuid
+ 2))
57 echo "/set uid=0 gid=0" > spec
58 echo ". type=dir mode=0755" >> spec
60 for i
in $
(seq ${nuid}); do
62 echo "./f$i type=file mode=0600 uid=$i gid=$i" >> spec
65 atf_check
-o ignore
-e ignore makefs
-B $1 -o version
=$2 \
66 -F spec
-s 4000b
${IMG} ${DIR}
67 atf_check
-o ignore
-e ignore tunefs
-q user
-F ${IMG}
68 atf_check
-s exit:0 -o 'match:NO USER QUOTA INODE \(CREATED\)' \
69 -o 'match:USER QUOTA MISMATCH FOR ID 10: 0/0 SHOULD BE 0/1' \
71 atf_check
-s exit:0 -o "match:${expected_files} files" \
72 fsck_ffs
-nf -F ${IMG}