pass5.c revision 1.29 1 1.29 lukem /* $NetBSD: pass5.c,v 1.29 2002/05/06 03:17:43 lukem Exp $ */
2 1.13 cgd
3 1.1 cgd /*
4 1.6 mycroft * Copyright (c) 1980, 1986, 1993
5 1.6 mycroft * The Regents of the University of California. All rights reserved.
6 1.1 cgd *
7 1.1 cgd * Redistribution and use in source and binary forms, with or without
8 1.1 cgd * modification, are permitted provided that the following conditions
9 1.1 cgd * are met:
10 1.1 cgd * 1. Redistributions of source code must retain the above copyright
11 1.1 cgd * notice, this list of conditions and the following disclaimer.
12 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 cgd * notice, this list of conditions and the following disclaimer in the
14 1.1 cgd * documentation and/or other materials provided with the distribution.
15 1.1 cgd * 3. All advertising materials mentioning features or use of this software
16 1.1 cgd * must display the following acknowledgement:
17 1.1 cgd * This product includes software developed by the University of
18 1.1 cgd * California, Berkeley and its contributors.
19 1.1 cgd * 4. Neither the name of the University nor the names of its contributors
20 1.1 cgd * may be used to endorse or promote products derived from this software
21 1.1 cgd * without specific prior written permission.
22 1.1 cgd *
23 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.1 cgd * SUCH DAMAGE.
34 1.1 cgd */
35 1.1 cgd
36 1.17 lukem #include <sys/cdefs.h>
37 1.1 cgd #ifndef lint
38 1.13 cgd #if 0
39 1.18 lukem static char sccsid[] = "@(#)pass5.c 8.9 (Berkeley) 4/28/95";
40 1.13 cgd #else
41 1.29 lukem __RCSID("$NetBSD: pass5.c,v 1.29 2002/05/06 03:17:43 lukem Exp $");
42 1.13 cgd #endif
43 1.1 cgd #endif /* not lint */
44 1.1 cgd
45 1.1 cgd #include <sys/param.h>
46 1.5 cgd #include <sys/time.h>
47 1.18 lukem
48 1.6 mycroft #include <ufs/ufs/dinode.h>
49 1.6 mycroft #include <ufs/ffs/fs.h>
50 1.19 bouyer #include <ufs/ffs/ffs_extern.h>
51 1.19 bouyer #include <ufs/ufs/ufs_bswap.h>
52 1.18 lukem
53 1.18 lukem #include <err.h>
54 1.1 cgd #include <string.h>
55 1.19 bouyer #include <malloc.h>
56 1.15 christos
57 1.16 christos #include "fsutil.h"
58 1.1 cgd #include "fsck.h"
59 1.10 cgd #include "extern.h"
60 1.1 cgd
61 1.19 bouyer void print_bmap __P((u_char *,u_int32_t));
62 1.19 bouyer
63 1.10 cgd void
64 1.1 cgd pass5()
65 1.1 cgd {
66 1.17 lukem int c, blk, frags, basesize, sumsize, mapsize, savednrpos = 0;
67 1.21 fvdl int inomapsize, blkmapsize;
68 1.19 bouyer struct fs *fs = sblock;
69 1.18 lukem ufs_daddr_t dbase, dmax;
70 1.18 lukem ufs_daddr_t d;
71 1.21 fvdl long i, j, k;
72 1.1 cgd struct csum *cs;
73 1.1 cgd struct csum cstotal;
74 1.26 thorpej struct inodesc idesc[4];
75 1.1 cgd char buf[MAXBSIZE];
76 1.17 lukem struct cg *newcg = (struct cg *)buf;
77 1.1 cgd struct ocg *ocg = (struct ocg *)buf;
78 1.21 fvdl struct cg *cg = cgrp;
79 1.1 cgd
80 1.12 mycroft statemap[WINO] = USTATE;
81 1.7 mycroft memset(newcg, 0, (size_t)fs->fs_cgsize);
82 1.1 cgd newcg->cg_niblk = fs->fs_ipg;
83 1.12 mycroft if (cvtlevel >= 3) {
84 1.6 mycroft if (fs->fs_maxcontig < 2 && fs->fs_contigsumsize > 0) {
85 1.6 mycroft if (preen)
86 1.6 mycroft pwarn("DELETING CLUSTERING MAPS\n");
87 1.6 mycroft if (preen || reply("DELETE CLUSTERING MAPS")) {
88 1.6 mycroft fs->fs_contigsumsize = 0;
89 1.6 mycroft doinglevel1 = 1;
90 1.6 mycroft sbdirty();
91 1.6 mycroft }
92 1.6 mycroft }
93 1.6 mycroft if (fs->fs_maxcontig > 1) {
94 1.6 mycroft char *doit = 0;
95 1.6 mycroft
96 1.6 mycroft if (fs->fs_contigsumsize < 1) {
97 1.6 mycroft doit = "CREAT";
98 1.6 mycroft } else if (fs->fs_contigsumsize < fs->fs_maxcontig &&
99 1.6 mycroft fs->fs_contigsumsize < FS_MAXCONTIG) {
100 1.6 mycroft doit = "EXPAND";
101 1.6 mycroft }
102 1.6 mycroft if (doit) {
103 1.6 mycroft i = fs->fs_contigsumsize;
104 1.6 mycroft fs->fs_contigsumsize =
105 1.6 mycroft MIN(fs->fs_maxcontig, FS_MAXCONTIG);
106 1.6 mycroft if (CGSIZE(fs) > fs->fs_bsize) {
107 1.6 mycroft pwarn("CANNOT %s CLUSTER MAPS\n", doit);
108 1.6 mycroft fs->fs_contigsumsize = i;
109 1.6 mycroft } else if (preen ||
110 1.6 mycroft reply("CREATE CLUSTER MAPS")) {
111 1.6 mycroft if (preen)
112 1.6 mycroft pwarn("%sING CLUSTER MAPS\n",
113 1.6 mycroft doit);
114 1.6 mycroft fs->fs_cgsize =
115 1.6 mycroft fragroundup(fs, CGSIZE(fs));
116 1.21 fvdl cg = cgrp =
117 1.21 fvdl realloc(cgrp, fs->fs_cgsize);
118 1.21 fvdl if (cg == NULL)
119 1.21 fvdl errx(EEXIT,
120 1.21 fvdl "cannot reallocate cg space");
121 1.6 mycroft doinglevel1 = 1;
122 1.6 mycroft sbdirty();
123 1.6 mycroft }
124 1.6 mycroft }
125 1.6 mycroft }
126 1.6 mycroft }
127 1.1 cgd switch ((int)fs->fs_postblformat) {
128 1.1 cgd
129 1.1 cgd case FS_42POSTBLFMT:
130 1.11 cgd basesize = (char *)(&ocg->cg_btot[0]) -
131 1.11 cgd (char *)(&ocg->cg_firstfield);
132 1.12 mycroft sumsize = &ocg->cg_iused[0] - (u_int8_t *)(&ocg->cg_btot[0]);
133 1.1 cgd mapsize = &ocg->cg_free[howmany(fs->fs_fpg, NBBY)] -
134 1.1 cgd (u_char *)&ocg->cg_iused[0];
135 1.21 fvdl blkmapsize = howmany(fs->fs_fpg, NBBY);
136 1.21 fvdl inomapsize = &ocg->cg_free[0] - (u_char *)&ocg->cg_iused[0];
137 1.1 cgd ocg->cg_magic = CG_MAGIC;
138 1.1 cgd savednrpos = fs->fs_nrpos;
139 1.1 cgd fs->fs_nrpos = 8;
140 1.1 cgd break;
141 1.1 cgd
142 1.1 cgd case FS_DYNAMICPOSTBLFMT:
143 1.1 cgd newcg->cg_btotoff =
144 1.11 cgd &newcg->cg_space[0] - (u_char *)(&newcg->cg_firstfield);
145 1.1 cgd newcg->cg_boff =
146 1.14 cgd newcg->cg_btotoff + fs->fs_cpg * sizeof(int32_t);
147 1.1 cgd newcg->cg_iusedoff = newcg->cg_boff +
148 1.14 cgd fs->fs_cpg * fs->fs_nrpos * sizeof(int16_t);
149 1.1 cgd newcg->cg_freeoff =
150 1.6 mycroft newcg->cg_iusedoff + howmany(fs->fs_ipg, NBBY);
151 1.21 fvdl inomapsize = newcg->cg_freeoff - newcg->cg_iusedoff;
152 1.21 fvdl newcg->cg_nextfreeoff = newcg->cg_freeoff +
153 1.21 fvdl howmany(fs->fs_cpg * fs->fs_spc / NSPF(fs), NBBY);
154 1.21 fvdl blkmapsize = newcg->cg_nextfreeoff - newcg->cg_freeoff;
155 1.21 fvdl if (fs->fs_contigsumsize > 0) {
156 1.21 fvdl newcg->cg_clustersumoff = newcg->cg_nextfreeoff -
157 1.14 cgd sizeof(int32_t);
158 1.6 mycroft newcg->cg_clustersumoff =
159 1.14 cgd roundup(newcg->cg_clustersumoff, sizeof(int32_t));
160 1.6 mycroft newcg->cg_clusteroff = newcg->cg_clustersumoff +
161 1.14 cgd (fs->fs_contigsumsize + 1) * sizeof(int32_t);
162 1.6 mycroft newcg->cg_nextfreeoff = newcg->cg_clusteroff +
163 1.6 mycroft howmany(fs->fs_cpg * fs->fs_spc / NSPB(fs), NBBY);
164 1.6 mycroft }
165 1.1 cgd newcg->cg_magic = CG_MAGIC;
166 1.11 cgd basesize = &newcg->cg_space[0] -
167 1.11 cgd (u_char *)(&newcg->cg_firstfield);
168 1.1 cgd sumsize = newcg->cg_iusedoff - newcg->cg_btotoff;
169 1.1 cgd mapsize = newcg->cg_nextfreeoff - newcg->cg_iusedoff;
170 1.1 cgd break;
171 1.1 cgd
172 1.1 cgd default:
173 1.21 fvdl inomapsize = blkmapsize = sumsize = 0; /* keep lint happy */
174 1.18 lukem errx(EEXIT, "UNKNOWN ROTATIONAL TABLE FORMAT %d",
175 1.1 cgd fs->fs_postblformat);
176 1.1 cgd }
177 1.7 mycroft memset(&idesc[0], 0, sizeof idesc);
178 1.26 thorpej for (i = 0; i < 4; i++) {
179 1.1 cgd idesc[i].id_type = ADDR;
180 1.6 mycroft if (doinglevel2)
181 1.6 mycroft idesc[i].id_fix = FIX;
182 1.6 mycroft }
183 1.7 mycroft memset(&cstotal, 0, sizeof(struct csum));
184 1.1 cgd j = blknum(fs, fs->fs_size + fs->fs_frag - 1);
185 1.1 cgd for (i = fs->fs_size; i < j; i++)
186 1.1 cgd setbmap(i);
187 1.1 cgd for (c = 0; c < fs->fs_ncg; c++) {
188 1.29 lukem if (got_siginfo) {
189 1.29 lukem fprintf(stderr,
190 1.29 lukem "%s: phase 5: cyl group %d of %d (%d%%)\n",
191 1.29 lukem cdevname(), c, fs->fs_ncg,
192 1.29 lukem c * 100 / fs->fs_ncg);
193 1.29 lukem got_siginfo = 0;
194 1.29 lukem }
195 1.1 cgd getblk(&cgblk, cgtod(fs, c), fs->fs_cgsize);
196 1.19 bouyer memcpy(cg, cgblk.b_un.b_cg, fs->fs_cgsize);
197 1.19 bouyer if((doswap && !needswap) || (!doswap && needswap))
198 1.19 bouyer swap_cg(cgblk.b_un.b_cg, cg);
199 1.19 bouyer if (!cg_chkmagic(cg, 0))
200 1.21 fvdl pfatal("CG %d: PASS5: BAD MAGIC NUMBER\n", c);
201 1.19 bouyer if(doswap)
202 1.19 bouyer cgdirty();
203 1.26 thorpej /*
204 1.26 thorpej * While we have the disk head where we want it,
205 1.26 thorpej * write back the superblock to the spare at this
206 1.26 thorpej * cylinder group.
207 1.26 thorpej */
208 1.26 thorpej if ((cvtlevel && sblk.b_dirty) || doswap) {
209 1.26 thorpej bwrite(fswritefd, sblk.b_un.b_buf,
210 1.26 thorpej fsbtodb(sblock, cgsblock(sblock, c)),
211 1.26 thorpej sblock->fs_sbsize);
212 1.26 thorpej } else {
213 1.26 thorpej /*
214 1.26 thorpej * Read in the current alternate superblock,
215 1.26 thorpej * and compare it to the master. If it's
216 1.26 thorpej * wrong, fix it up.
217 1.26 thorpej */
218 1.26 thorpej getblk(&asblk, cgsblock(sblock, c), sblock->fs_sbsize);
219 1.26 thorpej if (asblk.b_errs)
220 1.26 thorpej pfatal("CG %d: UNABLE TO READ ALTERNATE "
221 1.26 thorpej "SUPERBLK\n", c);
222 1.26 thorpej else {
223 1.26 thorpej memmove(altsblock, asblk.b_un.b_fs,
224 1.26 thorpej sblock->fs_sbsize);
225 1.26 thorpej if (needswap)
226 1.27 lukem ffs_sb_swap(asblk.b_un.b_fs, altsblock);
227 1.26 thorpej }
228 1.26 thorpej if ((asblk.b_errs || cmpsblks(sblock, altsblock)) &&
229 1.26 thorpej dofix(&idesc[3],
230 1.26 thorpej "ALTERNATE SUPERBLK(S) ARE INCORRECT")) {
231 1.26 thorpej bwrite(fswritefd, sblk.b_un.b_buf,
232 1.26 thorpej fsbtodb(sblock, cgsblock(sblock, c)),
233 1.26 thorpej sblock->fs_sbsize);
234 1.26 thorpej }
235 1.26 thorpej }
236 1.1 cgd dbase = cgbase(fs, c);
237 1.1 cgd dmax = dbase + fs->fs_fpg;
238 1.1 cgd if (dmax > fs->fs_size)
239 1.1 cgd dmax = fs->fs_size;
240 1.6 mycroft newcg->cg_time = cg->cg_time;
241 1.1 cgd newcg->cg_cgx = c;
242 1.1 cgd if (c == fs->fs_ncg - 1)
243 1.1 cgd newcg->cg_ncyl = fs->fs_ncyl % fs->fs_cpg;
244 1.1 cgd else
245 1.1 cgd newcg->cg_ncyl = fs->fs_cpg;
246 1.1 cgd newcg->cg_ndblk = dmax - dbase;
247 1.6 mycroft if (fs->fs_contigsumsize > 0)
248 1.6 mycroft newcg->cg_nclusterblks = newcg->cg_ndblk / fs->fs_frag;
249 1.1 cgd newcg->cg_cs.cs_ndir = 0;
250 1.1 cgd newcg->cg_cs.cs_nffree = 0;
251 1.1 cgd newcg->cg_cs.cs_nbfree = 0;
252 1.1 cgd newcg->cg_cs.cs_nifree = fs->fs_ipg;
253 1.25 mycroft if (cg->cg_rotor >= 0 && cg->cg_rotor < newcg->cg_ndblk)
254 1.1 cgd newcg->cg_rotor = cg->cg_rotor;
255 1.1 cgd else
256 1.1 cgd newcg->cg_rotor = 0;
257 1.25 mycroft if (cg->cg_frotor >= 0 && cg->cg_frotor < newcg->cg_ndblk)
258 1.1 cgd newcg->cg_frotor = cg->cg_frotor;
259 1.1 cgd else
260 1.1 cgd newcg->cg_frotor = 0;
261 1.25 mycroft if (cg->cg_irotor >= 0 && cg->cg_irotor < newcg->cg_niblk)
262 1.1 cgd newcg->cg_irotor = cg->cg_irotor;
263 1.1 cgd else
264 1.1 cgd newcg->cg_irotor = 0;
265 1.7 mycroft memset(&newcg->cg_frsum[0], 0, sizeof newcg->cg_frsum);
266 1.19 bouyer memset(&cg_blktot(newcg, 0)[0], 0,
267 1.1 cgd (size_t)(sumsize + mapsize));
268 1.1 cgd if (fs->fs_postblformat == FS_42POSTBLFMT)
269 1.1 cgd ocg->cg_magic = CG_MAGIC;
270 1.1 cgd j = fs->fs_ipg * c;
271 1.1 cgd for (i = 0; i < fs->fs_ipg; j++, i++) {
272 1.1 cgd switch (statemap[j]) {
273 1.1 cgd
274 1.1 cgd case USTATE:
275 1.1 cgd break;
276 1.1 cgd
277 1.1 cgd case DSTATE:
278 1.1 cgd case DCLEAR:
279 1.1 cgd case DFOUND:
280 1.1 cgd newcg->cg_cs.cs_ndir++;
281 1.1 cgd /* fall through */
282 1.1 cgd
283 1.1 cgd case FSTATE:
284 1.1 cgd case FCLEAR:
285 1.1 cgd newcg->cg_cs.cs_nifree--;
286 1.19 bouyer setbit(cg_inosused(newcg, 0), i);
287 1.1 cgd break;
288 1.1 cgd
289 1.1 cgd default:
290 1.1 cgd if (j < ROOTINO)
291 1.1 cgd break;
292 1.18 lukem errx(EEXIT, "BAD STATE %d FOR INODE I=%ld",
293 1.18 lukem statemap[j], (long)j);
294 1.1 cgd }
295 1.1 cgd }
296 1.1 cgd if (c == 0)
297 1.1 cgd for (i = 0; i < ROOTINO; i++) {
298 1.19 bouyer setbit(cg_inosused(newcg, 0), i);
299 1.1 cgd newcg->cg_cs.cs_nifree--;
300 1.1 cgd }
301 1.1 cgd for (i = 0, d = dbase;
302 1.1 cgd d < dmax;
303 1.1 cgd d += fs->fs_frag, i += fs->fs_frag) {
304 1.1 cgd frags = 0;
305 1.1 cgd for (j = 0; j < fs->fs_frag; j++) {
306 1.1 cgd if (testbmap(d + j))
307 1.1 cgd continue;
308 1.19 bouyer setbit(cg_blksfree(newcg, 0), i + j);
309 1.1 cgd frags++;
310 1.1 cgd }
311 1.1 cgd if (frags == fs->fs_frag) {
312 1.1 cgd newcg->cg_cs.cs_nbfree++;
313 1.1 cgd j = cbtocylno(fs, i);
314 1.19 bouyer cg_blktot(newcg, 0)[j]++;
315 1.19 bouyer cg_blks(fs, newcg, j, 0)[cbtorpos(fs, i)]++;
316 1.6 mycroft if (fs->fs_contigsumsize > 0)
317 1.19 bouyer setbit(cg_clustersfree(newcg, 0),
318 1.28 mycroft fragstoblks(fs, i));
319 1.1 cgd } else if (frags > 0) {
320 1.1 cgd newcg->cg_cs.cs_nffree += frags;
321 1.19 bouyer blk = blkmap(fs, cg_blksfree(newcg, 0), i);
322 1.19 bouyer ffs_fragacct(fs, blk, newcg->cg_frsum, 1, 0);
323 1.6 mycroft }
324 1.6 mycroft }
325 1.6 mycroft if (fs->fs_contigsumsize > 0) {
326 1.19 bouyer int32_t *sump = cg_clustersum(newcg, 0);
327 1.19 bouyer u_char *mapp = cg_clustersfree(newcg, 0);
328 1.6 mycroft int map = *mapp++;
329 1.6 mycroft int bit = 1;
330 1.6 mycroft int run = 0;
331 1.6 mycroft
332 1.6 mycroft for (i = 0; i < newcg->cg_nclusterblks; i++) {
333 1.6 mycroft if ((map & bit) != 0) {
334 1.6 mycroft run++;
335 1.6 mycroft } else if (run != 0) {
336 1.6 mycroft if (run > fs->fs_contigsumsize)
337 1.6 mycroft run = fs->fs_contigsumsize;
338 1.6 mycroft sump[run]++;
339 1.6 mycroft run = 0;
340 1.6 mycroft }
341 1.6 mycroft if ((i & (NBBY - 1)) != (NBBY - 1)) {
342 1.6 mycroft bit <<= 1;
343 1.6 mycroft } else {
344 1.6 mycroft map = *mapp++;
345 1.6 mycroft bit = 1;
346 1.6 mycroft }
347 1.6 mycroft }
348 1.6 mycroft if (run != 0) {
349 1.6 mycroft if (run > fs->fs_contigsumsize)
350 1.6 mycroft run = fs->fs_contigsumsize;
351 1.6 mycroft sump[run]++;
352 1.1 cgd }
353 1.1 cgd }
354 1.1 cgd cstotal.cs_nffree += newcg->cg_cs.cs_nffree;
355 1.1 cgd cstotal.cs_nbfree += newcg->cg_cs.cs_nbfree;
356 1.1 cgd cstotal.cs_nifree += newcg->cg_cs.cs_nifree;
357 1.1 cgd cstotal.cs_ndir += newcg->cg_cs.cs_ndir;
358 1.1 cgd cs = &fs->fs_cs(fs, c);
359 1.20 ross if (memcmp(&newcg->cg_cs, cs, sizeof *cs) != 0) {
360 1.19 bouyer if (dofix(&idesc[0], "FREE BLK COUNT(S) WRONG IN SUPERBLK")) {
361 1.18 lukem memmove(cs, &newcg->cg_cs, sizeof *cs);
362 1.1 cgd sbdirty();
363 1.19 bouyer } else
364 1.19 bouyer markclean = 0;
365 1.20 ross }
366 1.6 mycroft if (doinglevel1) {
367 1.18 lukem memmove(cg, newcg, (size_t)fs->fs_cgsize);
368 1.1 cgd cgdirty();
369 1.1 cgd continue;
370 1.1 cgd }
371 1.19 bouyer if (memcmp(newcg, cg, basesize) != 0 ||
372 1.19 bouyer memcmp(&cg_blktot(newcg, 0)[0],
373 1.20 ross &cg_blktot(cg, 0)[0], sumsize) != 0) {
374 1.19 bouyer if (dofix(&idesc[2], "SUMMARY INFORMATION BAD")) {
375 1.18 lukem memmove(cg, newcg, (size_t)basesize);
376 1.19 bouyer memmove(&cg_blktot(cg, 0)[0],
377 1.19 bouyer &cg_blktot(newcg, 0)[0], (size_t)sumsize);
378 1.1 cgd cgdirty();
379 1.21 fvdl } else
380 1.21 fvdl markclean = 0;
381 1.20 ross }
382 1.21 fvdl if (usedsoftdep) {
383 1.21 fvdl for (i = 0; i < inomapsize; i++) {
384 1.21 fvdl j = cg_inosused(newcg, 0)[i];
385 1.21 fvdl if ((cg_inosused(cg, 0)[i] & j) == j)
386 1.21 fvdl continue;
387 1.21 fvdl for (k = 0; k < NBBY; k++) {
388 1.21 fvdl if ((j & (1 << k)) == 0)
389 1.21 fvdl continue;
390 1.21 fvdl if (cg_inosused(cg, 0)[i] & (1 << k))
391 1.21 fvdl continue;
392 1.23 bouyer pwarn("ALLOCATED INODE %ld "
393 1.23 bouyer "MARKED FREE\n",
394 1.21 fvdl c * fs->fs_ipg + i * 8 + k);
395 1.21 fvdl }
396 1.21 fvdl }
397 1.21 fvdl for (i = 0; i < blkmapsize; i++) {
398 1.21 fvdl j = cg_blksfree(cg, 0)[i];
399 1.21 fvdl if ((cg_blksfree(newcg, 0)[i] & j) == j)
400 1.21 fvdl continue;
401 1.21 fvdl for (k = 0; k < NBBY; k++) {
402 1.21 fvdl if ((j & (1 << k)) == 0)
403 1.21 fvdl continue;
404 1.21 fvdl if (cg_inosused(cg, 0)[i] & (1 << k))
405 1.21 fvdl continue;
406 1.24 mycroft pwarn("ALLOCATED FRAG %ld "
407 1.24 mycroft "MARKED FREE\n",
408 1.21 fvdl c * fs->fs_fpg + i * 8 + k);
409 1.21 fvdl }
410 1.21 fvdl }
411 1.21 fvdl }
412 1.21 fvdl if (memcmp(cg_inosused(newcg, 0), cg_inosused(cg, 0), mapsize)
413 1.21 fvdl != 0 && dofix(&idesc[1], "BLK(S) MISSING IN BIT MAPS")) {
414 1.21 fvdl memmove(cg_inosused(cg, 0), cg_inosused(newcg, 0),
415 1.21 fvdl (size_t)mapsize);
416 1.21 fvdl cgdirty();
417 1.21 fvdl }
418 1.1 cgd }
419 1.1 cgd if (fs->fs_postblformat == FS_42POSTBLFMT)
420 1.1 cgd fs->fs_nrpos = savednrpos;
421 1.20 ross if (memcmp(&cstotal, &fs->fs_cstotal, sizeof *cs) != 0) {
422 1.26 thorpej if (dofix(&idesc[0], "FREE BLK COUNT(S) WRONG IN SUPERBLK")) {
423 1.26 thorpej memmove(&fs->fs_cstotal, &cstotal, sizeof *cs);
424 1.26 thorpej fs->fs_ronly = 0;
425 1.26 thorpej fs->fs_fmod = 0;
426 1.26 thorpej sbdirty();
427 1.19 bouyer } else
428 1.19 bouyer markclean = 0;
429 1.20 ross }
430 1.19 bouyer }
431 1.19 bouyer
432 1.19 bouyer void
433 1.19 bouyer print_bmap(map, size)
434 1.19 bouyer u_char *map;
435 1.19 bouyer u_int32_t size;
436 1.19 bouyer {
437 1.19 bouyer int i, j;
438 1.19 bouyer
439 1.19 bouyer i = 0;
440 1.19 bouyer while (i < size) {
441 1.19 bouyer printf("%u: ",i);
442 1.19 bouyer for (j = 0; j < 16; j++, i++)
443 1.19 bouyer printf("%2x ", (u_int)map[i] & 0xff);
444 1.19 bouyer printf("\n");
445 1.1 cgd }
446 1.1 cgd }
447