xref: /illumos-gate/usr/src/cmd/fs.d/ufs/fsck/pass5.c (revision 7c478bd95313f5f23a4c958a745db2134aa03244)
1*7c478bd9Sstevel@tonic-gate /*
2*7c478bd9Sstevel@tonic-gate  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
3*7c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
4*7c478bd9Sstevel@tonic-gate  */
5*7c478bd9Sstevel@tonic-gate 
6*7c478bd9Sstevel@tonic-gate /*	Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T	*/
7*7c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
8*7c478bd9Sstevel@tonic-gate 
9*7c478bd9Sstevel@tonic-gate /*
10*7c478bd9Sstevel@tonic-gate  * Copyright (c) 1980, 1986, 1990 The Regents of the University of California.
11*7c478bd9Sstevel@tonic-gate  * All rights reserved.
12*7c478bd9Sstevel@tonic-gate  *
13*7c478bd9Sstevel@tonic-gate  * Redistribution and use in source and binary forms are permitted
14*7c478bd9Sstevel@tonic-gate  * provided that: (1) source distributions retain this entire copyright
15*7c478bd9Sstevel@tonic-gate  * notice and comment, and (2) distributions including binaries display
16*7c478bd9Sstevel@tonic-gate  * the following acknowledgement:  ``This product includes software
17*7c478bd9Sstevel@tonic-gate  * developed by the University of California, Berkeley and its contributors''
18*7c478bd9Sstevel@tonic-gate  * in the documentation or other materials provided with the distribution
19*7c478bd9Sstevel@tonic-gate  * and in all advertising materials mentioning features or use of this
20*7c478bd9Sstevel@tonic-gate  * software. Neither the name of the University nor the names of its
21*7c478bd9Sstevel@tonic-gate  * contributors may be used to endorse or promote products derived
22*7c478bd9Sstevel@tonic-gate  * from this software without specific prior written permission.
23*7c478bd9Sstevel@tonic-gate  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
24*7c478bd9Sstevel@tonic-gate  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
25*7c478bd9Sstevel@tonic-gate  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
26*7c478bd9Sstevel@tonic-gate  */
27*7c478bd9Sstevel@tonic-gate 
28*7c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
29*7c478bd9Sstevel@tonic-gate 
30*7c478bd9Sstevel@tonic-gate #include <sys/param.h>
31*7c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
32*7c478bd9Sstevel@tonic-gate #include <sys/mntent.h>
33*7c478bd9Sstevel@tonic-gate 
34*7c478bd9Sstevel@tonic-gate #define	bcopy(f, t, n)    memcpy(t, f, n)
35*7c478bd9Sstevel@tonic-gate #define	bzero(s, n)	memset(s, 0, n)
36*7c478bd9Sstevel@tonic-gate #define	bcmp(s, d, n)	memcmp(s, d, n)
37*7c478bd9Sstevel@tonic-gate 
38*7c478bd9Sstevel@tonic-gate #define	index(s, r)	strchr(s, r)
39*7c478bd9Sstevel@tonic-gate #define	rindex(s, r)	strrchr(s, r)
40*7c478bd9Sstevel@tonic-gate 
41*7c478bd9Sstevel@tonic-gate #include <sys/fs/ufs_fs.h>
42*7c478bd9Sstevel@tonic-gate #include <sys/vnode.h>
43*7c478bd9Sstevel@tonic-gate #include <sys/fs/ufs_inode.h>
44*7c478bd9Sstevel@tonic-gate #include "fsck.h"
45*7c478bd9Sstevel@tonic-gate 
46*7c478bd9Sstevel@tonic-gate pass5()
47*7c478bd9Sstevel@tonic-gate {
48*7c478bd9Sstevel@tonic-gate 	int32_t c, blk, frags, savednrpos, savednpsect;
49*7c478bd9Sstevel@tonic-gate 	size_t	basesize, sumsize, mapsize;
50*7c478bd9Sstevel@tonic-gate 	struct fs *fs = &sblock;
51*7c478bd9Sstevel@tonic-gate 	struct cg *cg = &cgrp;
52*7c478bd9Sstevel@tonic-gate 	diskaddr_t dbase, dmax;
53*7c478bd9Sstevel@tonic-gate 	diskaddr_t d;
54*7c478bd9Sstevel@tonic-gate 	uint64_t i, j;
55*7c478bd9Sstevel@tonic-gate 	struct csum *cs;
56*7c478bd9Sstevel@tonic-gate 	time_t now;
57*7c478bd9Sstevel@tonic-gate 	struct csum cstotal;
58*7c478bd9Sstevel@tonic-gate 	struct inodesc idesc;
59*7c478bd9Sstevel@tonic-gate 	char buf[MAXBSIZE];
60*7c478bd9Sstevel@tonic-gate 	struct cg *newcg = (struct cg *)buf;
61*7c478bd9Sstevel@tonic-gate 	struct ocg *ocg = (struct ocg *)buf;
62*7c478bd9Sstevel@tonic-gate 
63*7c478bd9Sstevel@tonic-gate 	bzero((char *)newcg, (size_t)fs->fs_cgsize);
64*7c478bd9Sstevel@tonic-gate 	newcg->cg_niblk = fs->fs_ipg;
65*7c478bd9Sstevel@tonic-gate 	switch (fs->fs_postblformat) {
66*7c478bd9Sstevel@tonic-gate 
67*7c478bd9Sstevel@tonic-gate 	case FS_42POSTBLFMT:
68*7c478bd9Sstevel@tonic-gate 		basesize = (char *)(&ocg->cg_btot[0]) - (char *)(&ocg->cg_link);
69*7c478bd9Sstevel@tonic-gate 		sumsize = &ocg->cg_iused[0] - (char *)(&ocg->cg_btot[0]);
70*7c478bd9Sstevel@tonic-gate 		mapsize = &ocg->cg_free[howmany(fs->fs_fpg, NBBY)] -
71*7c478bd9Sstevel@tonic-gate 			(uchar_t *)&ocg->cg_iused[0];
72*7c478bd9Sstevel@tonic-gate 		ocg->cg_magic = CG_MAGIC;
73*7c478bd9Sstevel@tonic-gate 		savednrpos = fs->fs_nrpos;
74*7c478bd9Sstevel@tonic-gate 		fs->fs_nrpos = 8;
75*7c478bd9Sstevel@tonic-gate 		fs->fs_trackskew = 0;
76*7c478bd9Sstevel@tonic-gate 		if ((fs->fs_npsect < 0) || (fs->fs_npsect > fs->fs_spc)) {
77*7c478bd9Sstevel@tonic-gate 			/* Migration aid from fs_state */
78*7c478bd9Sstevel@tonic-gate 			fs->fs_npsect = fs->fs_nsect;
79*7c478bd9Sstevel@tonic-gate 		}
80*7c478bd9Sstevel@tonic-gate 		savednpsect = fs->fs_npsect;
81*7c478bd9Sstevel@tonic-gate 		fs->fs_npsect = fs->fs_nsect;
82*7c478bd9Sstevel@tonic-gate 		break;
83*7c478bd9Sstevel@tonic-gate 
84*7c478bd9Sstevel@tonic-gate 	case FS_DYNAMICPOSTBLFMT:
85*7c478bd9Sstevel@tonic-gate 		newcg->cg_btotoff =
86*7c478bd9Sstevel@tonic-gate 			&newcg->cg_space[0] - (uchar_t *)(&newcg->cg_link);
87*7c478bd9Sstevel@tonic-gate 		newcg->cg_boff =
88*7c478bd9Sstevel@tonic-gate 			newcg->cg_btotoff + fs->fs_cpg * sizeof (long);
89*7c478bd9Sstevel@tonic-gate 		newcg->cg_iusedoff = newcg->cg_boff +
90*7c478bd9Sstevel@tonic-gate 			fs->fs_cpg * fs->fs_nrpos * sizeof (short);
91*7c478bd9Sstevel@tonic-gate 		newcg->cg_freeoff =
92*7c478bd9Sstevel@tonic-gate 			newcg->cg_iusedoff + howmany(fs->fs_ipg, NBBY);
93*7c478bd9Sstevel@tonic-gate 		newcg->cg_nextfreeoff = newcg->cg_freeoff +
94*7c478bd9Sstevel@tonic-gate 			howmany(fs->fs_cpg * fs->fs_spc / NSPF(fs),
95*7c478bd9Sstevel@tonic-gate 				NBBY);
96*7c478bd9Sstevel@tonic-gate 		newcg->cg_magic = CG_MAGIC;
97*7c478bd9Sstevel@tonic-gate 		basesize = &newcg->cg_space[0] - (uchar_t *)(&newcg->cg_link);
98*7c478bd9Sstevel@tonic-gate 		sumsize = newcg->cg_iusedoff - newcg->cg_btotoff;
99*7c478bd9Sstevel@tonic-gate 		mapsize = newcg->cg_nextfreeoff - newcg->cg_iusedoff;
100*7c478bd9Sstevel@tonic-gate 		break;
101*7c478bd9Sstevel@tonic-gate 
102*7c478bd9Sstevel@tonic-gate 	default:
103*7c478bd9Sstevel@tonic-gate 		pfatal("UNKNOWN ROTATIONAL TABLE FORMAT %d\n",
104*7c478bd9Sstevel@tonic-gate 			fs->fs_postblformat);
105*7c478bd9Sstevel@tonic-gate 		errexit("");
106*7c478bd9Sstevel@tonic-gate 	}
107*7c478bd9Sstevel@tonic-gate 
108*7c478bd9Sstevel@tonic-gate 	bzero((char *)&idesc, sizeof (struct inodesc));
109*7c478bd9Sstevel@tonic-gate 	idesc.id_type = ADDR;
110*7c478bd9Sstevel@tonic-gate 	bzero((char *)&cstotal, sizeof (struct csum));
111*7c478bd9Sstevel@tonic-gate 	(void) time(&now);
112*7c478bd9Sstevel@tonic-gate 
113*7c478bd9Sstevel@tonic-gate 	/*
114*7c478bd9Sstevel@tonic-gate 	 * If the last fragments in the file system don't make up a
115*7c478bd9Sstevel@tonic-gate 	 * full file system block, mark the bits in the blockmap
116*7c478bd9Sstevel@tonic-gate 	 * that correspond to those missing fragments as "allocated",
117*7c478bd9Sstevel@tonic-gate 	 * so that the last block doesn't get counted as a free block
118*7c478bd9Sstevel@tonic-gate 	 * and those missing fragments don't get counted as free frags.
119*7c478bd9Sstevel@tonic-gate 	 */
120*7c478bd9Sstevel@tonic-gate 	j = blknum(fs, (uint64_t)fs->fs_size + fs->fs_frag - 1);
121*7c478bd9Sstevel@tonic-gate 	for (i = fs->fs_size; i < j; i++)
122*7c478bd9Sstevel@tonic-gate 		setbmap(i);
123*7c478bd9Sstevel@tonic-gate 	for (c = 0; c < fs->fs_ncg; c++) {
124*7c478bd9Sstevel@tonic-gate 		getblk(&cgblk, (diskaddr_t)cgtod(fs, c), fs->fs_cgsize);
125*7c478bd9Sstevel@tonic-gate 		if (!cg_chkmagic(cg))
126*7c478bd9Sstevel@tonic-gate 			pfatal("CG %d: BAD MAGIC NUMBER\n", c);
127*7c478bd9Sstevel@tonic-gate 		dbase = cgbase(fs, c);
128*7c478bd9Sstevel@tonic-gate 		dmax = dbase + fs->fs_fpg;
129*7c478bd9Sstevel@tonic-gate 		if (dmax > fs->fs_size)
130*7c478bd9Sstevel@tonic-gate 			dmax = fs->fs_size;
131*7c478bd9Sstevel@tonic-gate 		if (now > cg->cg_time)
132*7c478bd9Sstevel@tonic-gate 			newcg->cg_time = cg->cg_time;
133*7c478bd9Sstevel@tonic-gate 		else
134*7c478bd9Sstevel@tonic-gate 			newcg->cg_time = now;
135*7c478bd9Sstevel@tonic-gate 		newcg->cg_cgx = c;
136*7c478bd9Sstevel@tonic-gate 		if (c == fs->fs_ncg - 1)
137*7c478bd9Sstevel@tonic-gate 			newcg->cg_ncyl = fs->fs_ncyl % fs->fs_cpg;
138*7c478bd9Sstevel@tonic-gate 		else
139*7c478bd9Sstevel@tonic-gate 			newcg->cg_ncyl = fs->fs_cpg;
140*7c478bd9Sstevel@tonic-gate 		newcg->cg_niblk = sblock.fs_ipg;
141*7c478bd9Sstevel@tonic-gate 		newcg->cg_ndblk = dmax - dbase;
142*7c478bd9Sstevel@tonic-gate 		newcg->cg_cs.cs_ndir = 0;
143*7c478bd9Sstevel@tonic-gate 		newcg->cg_cs.cs_nffree = 0;
144*7c478bd9Sstevel@tonic-gate 		newcg->cg_cs.cs_nbfree = 0;
145*7c478bd9Sstevel@tonic-gate 		newcg->cg_cs.cs_nifree = fs->fs_ipg;
146*7c478bd9Sstevel@tonic-gate 		if ((cg->cg_rotor >= 0) && (cg->cg_rotor < newcg->cg_ndblk))
147*7c478bd9Sstevel@tonic-gate 			newcg->cg_rotor = cg->cg_rotor;
148*7c478bd9Sstevel@tonic-gate 		else
149*7c478bd9Sstevel@tonic-gate 			newcg->cg_rotor = 0;
150*7c478bd9Sstevel@tonic-gate 		if ((cg->cg_frotor >= 0) && (cg->cg_frotor < newcg->cg_ndblk))
151*7c478bd9Sstevel@tonic-gate 			newcg->cg_frotor = cg->cg_frotor;
152*7c478bd9Sstevel@tonic-gate 		else
153*7c478bd9Sstevel@tonic-gate 			newcg->cg_frotor = 0;
154*7c478bd9Sstevel@tonic-gate 		if ((cg->cg_irotor >= 0) && (cg->cg_irotor < newcg->cg_niblk))
155*7c478bd9Sstevel@tonic-gate 			newcg->cg_irotor = cg->cg_irotor;
156*7c478bd9Sstevel@tonic-gate 		else
157*7c478bd9Sstevel@tonic-gate 			newcg->cg_irotor = 0;
158*7c478bd9Sstevel@tonic-gate 		bzero((char *)&newcg->cg_frsum[0], sizeof (newcg->cg_frsum));
159*7c478bd9Sstevel@tonic-gate 		bzero((char *)&cg_blktot(newcg)[0], sumsize + mapsize);
160*7c478bd9Sstevel@tonic-gate 		if (fs->fs_postblformat == FS_42POSTBLFMT)
161*7c478bd9Sstevel@tonic-gate 			ocg->cg_magic = CG_MAGIC;
162*7c478bd9Sstevel@tonic-gate 		j = fs->fs_ipg * c;
163*7c478bd9Sstevel@tonic-gate 		for (i = 0; i < fs->fs_ipg; j++, i++) {
164*7c478bd9Sstevel@tonic-gate 			switch (statemap[j]) {
165*7c478bd9Sstevel@tonic-gate 
166*7c478bd9Sstevel@tonic-gate 			case USTATE:
167*7c478bd9Sstevel@tonic-gate 				break;
168*7c478bd9Sstevel@tonic-gate 
169*7c478bd9Sstevel@tonic-gate 			case DSTATE:
170*7c478bd9Sstevel@tonic-gate 			case DCLEAR:
171*7c478bd9Sstevel@tonic-gate 			case DFOUND:
172*7c478bd9Sstevel@tonic-gate 				newcg->cg_cs.cs_ndir++;
173*7c478bd9Sstevel@tonic-gate 				/* fall through */
174*7c478bd9Sstevel@tonic-gate 
175*7c478bd9Sstevel@tonic-gate 			case FSTATE:
176*7c478bd9Sstevel@tonic-gate 			case FCLEAR:
177*7c478bd9Sstevel@tonic-gate 			case SSTATE:
178*7c478bd9Sstevel@tonic-gate 			case SCLEAR:
179*7c478bd9Sstevel@tonic-gate 				newcg->cg_cs.cs_nifree--;
180*7c478bd9Sstevel@tonic-gate 				setbit(cg_inosused(newcg), i);
181*7c478bd9Sstevel@tonic-gate 				break;
182*7c478bd9Sstevel@tonic-gate 
183*7c478bd9Sstevel@tonic-gate 			default:
184*7c478bd9Sstevel@tonic-gate 				if (j < UFSROOTINO)
185*7c478bd9Sstevel@tonic-gate 					break;
186*7c478bd9Sstevel@tonic-gate 				errexit("BAD STATE %d FOR INODE I=%d",
187*7c478bd9Sstevel@tonic-gate 				    statemap[j], j);
188*7c478bd9Sstevel@tonic-gate 			}
189*7c478bd9Sstevel@tonic-gate 		}
190*7c478bd9Sstevel@tonic-gate 		if (c == 0)
191*7c478bd9Sstevel@tonic-gate 			for (i = 0; i < UFSROOTINO; i++) {
192*7c478bd9Sstevel@tonic-gate 				setbit(cg_inosused(newcg), i);
193*7c478bd9Sstevel@tonic-gate 				newcg->cg_cs.cs_nifree--;
194*7c478bd9Sstevel@tonic-gate 			}
195*7c478bd9Sstevel@tonic-gate 		for (i = 0, d = dbase;
196*7c478bd9Sstevel@tonic-gate 		    d < dmax;
197*7c478bd9Sstevel@tonic-gate 		    d += fs->fs_frag, i += fs->fs_frag) {
198*7c478bd9Sstevel@tonic-gate 			frags = 0;
199*7c478bd9Sstevel@tonic-gate 			for (j = 0; j < fs->fs_frag; j++) {
200*7c478bd9Sstevel@tonic-gate 				if (testbmap(d + j))
201*7c478bd9Sstevel@tonic-gate 					continue;
202*7c478bd9Sstevel@tonic-gate 				setbit(cg_blksfree(newcg), i + j);
203*7c478bd9Sstevel@tonic-gate 				frags++;
204*7c478bd9Sstevel@tonic-gate 			}
205*7c478bd9Sstevel@tonic-gate 			if (frags == fs->fs_frag) {
206*7c478bd9Sstevel@tonic-gate 				newcg->cg_cs.cs_nbfree++;
207*7c478bd9Sstevel@tonic-gate 				j = cbtocylno(fs, i);
208*7c478bd9Sstevel@tonic-gate 				cg_blktot(newcg)[j]++;
209*7c478bd9Sstevel@tonic-gate 				cg_blks(fs, newcg, j)[cbtorpos(fs, i)]++;
210*7c478bd9Sstevel@tonic-gate 			} else if (frags > 0) {
211*7c478bd9Sstevel@tonic-gate 				newcg->cg_cs.cs_nffree += frags;
212*7c478bd9Sstevel@tonic-gate 				blk = blkmap(fs, cg_blksfree(newcg), i);
213*7c478bd9Sstevel@tonic-gate 				fragacct(fs, blk, newcg->cg_frsum, 1);
214*7c478bd9Sstevel@tonic-gate 			}
215*7c478bd9Sstevel@tonic-gate 		}
216*7c478bd9Sstevel@tonic-gate /*
217*7c478bd9Sstevel@tonic-gate  *		for (frags = d; d < dmax; d++) {
218*7c478bd9Sstevel@tonic-gate  *			if (getbmap(d))
219*7c478bd9Sstevel@tonic-gate  *				continue;
220*7c478bd9Sstevel@tonic-gate  *			setbit(newcg->cg_free, d - dbase);
221*7c478bd9Sstevel@tonic-gate  *			newcg->cg_cs.cs_nffree++;
222*7c478bd9Sstevel@tonic-gate  *		}
223*7c478bd9Sstevel@tonic-gate  *		if (frags != d) {
224*7c478bd9Sstevel@tonic-gate  *			blk = blkmap(&sblock, newcg->cg_free, (frags - dbase));
225*7c478bd9Sstevel@tonic-gate  *			fragacct(&sblock, blk, newcg->cg_frsum, 1);
226*7c478bd9Sstevel@tonic-gate  *		}
227*7c478bd9Sstevel@tonic-gate  */
228*7c478bd9Sstevel@tonic-gate 		cstotal.cs_nffree += newcg->cg_cs.cs_nffree;
229*7c478bd9Sstevel@tonic-gate 		cstotal.cs_nbfree += newcg->cg_cs.cs_nbfree;
230*7c478bd9Sstevel@tonic-gate 		cstotal.cs_nifree += newcg->cg_cs.cs_nifree;
231*7c478bd9Sstevel@tonic-gate 		cstotal.cs_ndir += newcg->cg_cs.cs_ndir;
232*7c478bd9Sstevel@tonic-gate 
233*7c478bd9Sstevel@tonic-gate 		cs = &fs->fs_cs(fs, c);
234*7c478bd9Sstevel@tonic-gate 		if (bcmp((char *)&newcg->cg_cs, (char *)cs,
235*7c478bd9Sstevel@tonic-gate 		    sizeof (*cs)) != 0 &&
236*7c478bd9Sstevel@tonic-gate 		    dofix(&idesc, "FREE BLK COUNT(S) WRONG IN SUPERBLK")) {
237*7c478bd9Sstevel@tonic-gate 			bcopy((char *)&newcg->cg_cs, (char *)cs, sizeof (*cs));
238*7c478bd9Sstevel@tonic-gate 			sbdirty();
239*7c478bd9Sstevel@tonic-gate 		}
240*7c478bd9Sstevel@tonic-gate 		if (cvtflag) {
241*7c478bd9Sstevel@tonic-gate 			bcopy((char *)newcg, (char *)cg, (size_t)fs->fs_cgsize);
242*7c478bd9Sstevel@tonic-gate 			cgdirty();
243*7c478bd9Sstevel@tonic-gate 			continue;
244*7c478bd9Sstevel@tonic-gate 		}
245*7c478bd9Sstevel@tonic-gate 		if ((bcmp((char *)newcg, (char *)cg, (size_t)basesize) != 0 ||
246*7c478bd9Sstevel@tonic-gate 		    bcmp((char *)&cg_blktot(newcg)[0],
247*7c478bd9Sstevel@tonic-gate 			    (char *)&cg_blktot(cg)[0], sumsize) != 0) &&
248*7c478bd9Sstevel@tonic-gate 		    dofix(&idesc, "SUMMARY INFORMATION BAD")) {
249*7c478bd9Sstevel@tonic-gate 			bcopy((char *)newcg, (char *)cg, (size_t)basesize);
250*7c478bd9Sstevel@tonic-gate 			bcopy((char *)&cg_blktot(newcg)[0],
251*7c478bd9Sstevel@tonic-gate 			    (char *)&cg_blktot(cg)[0], sumsize);
252*7c478bd9Sstevel@tonic-gate 			cgdirty();
253*7c478bd9Sstevel@tonic-gate 		}
254*7c478bd9Sstevel@tonic-gate 		if (bcmp(cg_inosused(newcg),
255*7c478bd9Sstevel@tonic-gate 			    cg_inosused(cg), mapsize) != 0 &&
256*7c478bd9Sstevel@tonic-gate 		    dofix(&idesc, "BLK(S) MISSING IN BIT MAPS")) {
257*7c478bd9Sstevel@tonic-gate 			bcopy(cg_inosused(newcg), cg_inosused(cg), mapsize);
258*7c478bd9Sstevel@tonic-gate 			cgdirty();
259*7c478bd9Sstevel@tonic-gate 		}
260*7c478bd9Sstevel@tonic-gate 
261*7c478bd9Sstevel@tonic-gate 		cs = &sblock.fs_cs(&sblock, c);
262*7c478bd9Sstevel@tonic-gate 		if (bcmp((char *)&newcg->cg_cs, (char *)cs,
263*7c478bd9Sstevel@tonic-gate 		    sizeof (*cs)) != 0 &&
264*7c478bd9Sstevel@tonic-gate 		    dofix(&idesc, "FREE BLK COUNT(S) WRONG IN SUPERBLK")) {
265*7c478bd9Sstevel@tonic-gate 	/*
266*7c478bd9Sstevel@tonic-gate 	 *		bcopy((char *)&newcg->cg_cs, (char *)cs, sizeof (*cs));
267*7c478bd9Sstevel@tonic-gate 	 *		sbdirty();
268*7c478bd9Sstevel@tonic-gate 	 */
269*7c478bd9Sstevel@tonic-gate 		}
270*7c478bd9Sstevel@tonic-gate 
271*7c478bd9Sstevel@tonic-gate 	}
272*7c478bd9Sstevel@tonic-gate 	if (fs->fs_postblformat == FS_42POSTBLFMT) {
273*7c478bd9Sstevel@tonic-gate 		fs->fs_nrpos = savednrpos;
274*7c478bd9Sstevel@tonic-gate 		fs->fs_npsect = savednpsect;
275*7c478bd9Sstevel@tonic-gate 	}
276*7c478bd9Sstevel@tonic-gate 	if ((fflag || !(islog && islogok)) &&
277*7c478bd9Sstevel@tonic-gate 	    bcmp((char *)&cstotal, (char *)&fs->fs_cstotal,
278*7c478bd9Sstevel@tonic-gate 	    sizeof (struct csum)) != 0 &&
279*7c478bd9Sstevel@tonic-gate 	    dofix(&idesc, "FREE BLK COUNT(S) WRONG IN SUPERBLK")) {
280*7c478bd9Sstevel@tonic-gate 		bcopy((char *)&cstotal, (char *)&fs->fs_cstotal,
281*7c478bd9Sstevel@tonic-gate 			sizeof (struct csum));
282*7c478bd9Sstevel@tonic-gate 		fs->fs_ronly = 0;
283*7c478bd9Sstevel@tonic-gate 		fs->fs_fmod = 0;
284*7c478bd9Sstevel@tonic-gate 		sbdirty();
285*7c478bd9Sstevel@tonic-gate 	}
286*7c478bd9Sstevel@tonic-gate }
287