t_enable_quotas.sh revision 1.1.2.1 1 1.1.2.1 bouyer # $NetBSD: t_enable_quotas.sh,v 1.1.2.1 2011/01/20 14:25:04 bouyer Exp $
2 1.1.2.1 bouyer #
3 1.1.2.1 bouyer # Copyright (c) 2011 Manuel Bouyer
4 1.1.2.1 bouyer # All rights reserved.
5 1.1.2.1 bouyer #
6 1.1.2.1 bouyer # Redistribution and use in source and binary forms, with or without
7 1.1.2.1 bouyer # modification, are permitted provided that the following conditions
8 1.1.2.1 bouyer # are met:
9 1.1.2.1 bouyer # 1. Redistributions of source code must retain the above copyright
10 1.1.2.1 bouyer # notice, this list of conditions and the following disclaimer.
11 1.1.2.1 bouyer # 2. Redistributions in binary form must reproduce the above copyright
12 1.1.2.1 bouyer # notice, this list of conditions and the following disclaimer in the
13 1.1.2.1 bouyer # documentation and/or other materials provided with the distribution.
14 1.1.2.1 bouyer #
15 1.1.2.1 bouyer # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 1.1.2.1 bouyer # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 1.1.2.1 bouyer # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 1.1.2.1 bouyer # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 1.1.2.1 bouyer # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 1.1.2.1 bouyer # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 1.1.2.1 bouyer # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 1.1.2.1 bouyer # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 1.1.2.1 bouyer # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 1.1.2.1 bouyer # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 1.1.2.1 bouyer # POSSIBILITY OF SUCH DAMAGE.
26 1.1.2.1 bouyer #
27 1.1.2.1 bouyer
28 1.1.2.1 bouyer for e in le be; do
29 1.1.2.1 bouyer for v in 1 2; do
30 1.1.2.1 bouyer test_case disable_${e}_${v} disable_quotas "creation/removal of" ${e} ${v}
31 1.1.2.1 bouyer test_case corrupt_${e}_${v} corrupt_quotas "repair of corrupted" ${e} ${v}
32 1.1.2.1 bouyer test_case unallocated_${e}_${v} unallocated_quotas \
33 1.1.2.1 bouyer "recovery of unallocated" ${e} ${v}
34 1.1.2.1 bouyer test_case dir1_${e}_${v} dir1_quotas \
35 1.1.2.1 bouyer "successfull clear of wrong type of" ${e} ${v}
36 1.1.2.1 bouyer test_case notreg_${e}_${v} notreg_quotas \
37 1.1.2.1 bouyer "successfull clear of wrong type of" ${e} ${v}
38 1.1.2.1 bouyer done
39 1.1.2.1 bouyer done
40 1.1.2.1 bouyer
41 1.1.2.1 bouyer disable_quotas()
42 1.1.2.1 bouyer {
43 1.1.2.1 bouyer create_with_quotas $*
44 1.1.2.1 bouyer
45 1.1.2.1 bouyer # check that the quota inode creation didn't corrupt the filesystem
46 1.1.2.1 bouyer atf_check -s exit:0 -o "match:already clean" -o "match:3 files" \
47 1.1.2.1 bouyer fsck_ffs -nf -F ${IMG}
48 1.1.2.1 bouyer #now check fsck can properly clear the quota inode when quota flags are
49 1.1.2.1 bouyer # cleared
50 1.1.2.1 bouyer atf_check -o ignore -e ignore tunefs -q nouser -q nogroup -F ${IMG}
51 1.1.2.1 bouyer atf_check -s exit:0 -o "match:SUPERBLOCK QUOTA FLAG CLEARED" \
52 1.1.2.1 bouyer fsck_ffs -fp -F ${IMG}
53 1.1.2.1 bouyer atf_check -s exit:0 -o "match:1 files, 1 used" fsck_ffs -nf -F ${IMG}
54 1.1.2.1 bouyer }
55 1.1.2.1 bouyer
56 1.1.2.1 bouyer corrupt_quotas()
57 1.1.2.1 bouyer {
58 1.1.2.1 bouyer create_with_quotas $*
59 1.1.2.1 bouyer
60 1.1.2.1 bouyer local blkno=$(printf "inode 3\nblks\n" | /sbin/fsdb -nF -f ${IMG} | awk '$1 == "0:" {print $2}')
61 1.1.2.1 bouyer atf_check -o ignore -e ignore dd if=/dev/zero of=${IMG} bs=512 \
62 1.1.2.1 bouyer count=1 seek=${blkno} conv=notrunc
63 1.1.2.1 bouyer atf_check -s exit:0 \
64 1.1.2.1 bouyer -o "match:CORRUPTED USER QUOTA INODE 3 \(CLEARED\)" \
65 1.1.2.1 bouyer -o "match:NO USER QUOTA INODE \(CREATED\)" \
66 1.1.2.1 bouyer fsck_ffs -fp -F ${IMG}
67 1.1.2.1 bouyer atf_check -s exit:0 -o "match:3 files" fsck_ffs -nf -F ${IMG}
68 1.1.2.1 bouyer }
69 1.1.2.1 bouyer
70 1.1.2.1 bouyer unallocated_quotas()
71 1.1.2.1 bouyer {
72 1.1.2.1 bouyer create_with_quotas $*
73 1.1.2.1 bouyer
74 1.1.2.1 bouyer atf_check -o ignore -e ignore clri ${IMG} 3
75 1.1.2.1 bouyer atf_check -s exit:0 \
76 1.1.2.1 bouyer -o "match:UNALLOCATED USER QUOTA INODE 3 \(CLEARED\)" \
77 1.1.2.1 bouyer -o "match:NO USER QUOTA INODE \(CREATED\)" \
78 1.1.2.1 bouyer fsck_ffs -fp -F ${IMG}
79 1.1.2.1 bouyer atf_check -s exit:0 -o "match:3 files" fsck_ffs -nf -F ${IMG}
80 1.1.2.1 bouyer }
81 1.1.2.1 bouyer
82 1.1.2.1 bouyer dir1_quotas()
83 1.1.2.1 bouyer {
84 1.1.2.1 bouyer create_with_quotas $*
85 1.1.2.1 bouyer
86 1.1.2.1 bouyer atf_check -s exit:255 -o ignore -e ignore -x \
87 1.1.2.1 bouyer "printf 'inode 3\nchtype dir\nexit\n' | fsdb -F -f ${IMG}"
88 1.1.2.1 bouyer atf_check -s exit:0 \
89 1.1.2.1 bouyer -o "match:DIR I=3 CONNECTED. PARENT WAS I=0" \
90 1.1.2.1 bouyer -o "match:USER QUOTA INODE 3 IS A DIRECTORY" \
91 1.1.2.1 bouyer fsck_ffs -y -F ${IMG}
92 1.1.2.1 bouyer }
93 1.1.2.1 bouyer
94 1.1.2.1 bouyer notreg_quotas()
95 1.1.2.1 bouyer {
96 1.1.2.1 bouyer create_with_quotas $*
97 1.1.2.1 bouyer
98 1.1.2.1 bouyer atf_check -s exit:255 -o ignore -e ignore -x \
99 1.1.2.1 bouyer "printf 'inode 3\nchtype fifo\nexit\n' | fsdb -F -f ${IMG}"
100 1.1.2.1 bouyer atf_check -s exit:0 \
101 1.1.2.1 bouyer -o "match:WRONG TYPE 4096 for USER QUOTA INODE 3 \(CLEARED\)" \
102 1.1.2.1 bouyer -o "match:NO USER QUOTA INODE \(CREATED\)" \
103 1.1.2.1 bouyer fsck_ffs -p -F ${IMG}
104 1.1.2.1 bouyer atf_check -s exit:0 -o "match:3 files" fsck_ffs -nf -F ${IMG}
105 1.1.2.1 bouyer }
106