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