Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Oct 2000 12:54:29 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Tor.Egge@fast.no
Cc:        jwd@FreeBSD.ORG, freebsd-current@FreeBSD.ORG, peter@FreeBSD.ORG
Subject:   Re: newfs/fsck problem (bad superblocks)
Message-ID:  <Pine.BSF.4.21.0010241241280.2027-100000@besplex.bde.org>
In-Reply-To: <200010220822.KAA59278@midten.fast.no>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 22 Oct 2000 Tor.Egge@fast.no wrote:

> > Reverting src/sbin/newfs/mkfs.c to revision 1.29 fixes
> > the problem.
> > 
> > With just a quick review of the patch, I'm not sure I
> > understand what forces the last dirty buffer to be
> > written.

This worried me too.

> Try the enclosed patch.  It flushes the dirty buffer before
> program exit and before reading blocks.

There are still some serious (?) overflow bugs.

Index: mkfs.c
===================================================================
RCS file: /home/ncvs/src/sbin/newfs/mkfs.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -c -2 -r1.29 -r1.30
*** mkfs.c	1999/08/28 00:13:50	1.29
--- mkfs.c	2000/10/17 00:41:36	1.30
...
***************
*** 1341,1344 ****
--- 1347,1381 ----
  	}
  	if (Nflag)
+ 		return;
+ 	done = 0;
+ 	if (wc_end == 0 && size <= WCSIZE) {
+ 		wc_sect = bno;
+ 		bcopy(bf, wc, size);
+ 		wc_end = size;
+ 		if (wc_end < WCSIZE)
+ 			return;
+ 		done = 1;
+ 	}
+ 	if (wc_sect * sectorsize + wc_end == bno * sectorsize &&
 	            ^ overflow                   ^ overflow
+ 	    wc_end + size <= WCSIZE) {
+ 		bcopy(bf, wc + wc_end, size);
+ 		wc_end += size;
+ 		if (wc_end < WCSIZE)
+ 			return;
+ 		done = 1;
+ 	}
+ 	if (wc_end) {
+ 		if (lseek(fso, (off_t)wc_sect * sectorsize, SEEK_SET) < 0) {
 		               ^^^^^^^ must cast like this to prevent overflow
+ 			printf("seek error: %ld\n", (long)wc_sect);
+ 			err(35, "wtfs - writecombine");
+ 		}
+ 		n = write(fso, wc, wc_end);
+ 		if (n != wc_end) {
+ 			printf("write error: %ld\n", (long)wc_sect);
+ 			err(36, "wtfs - writecombine");
+ 		}
+ 		wc_end = 0;
+ 	}
+ 	if (done)
  		return;
  	if (lseek(fso, (off_t)bno * sectorsize, SEEK_SET) < 0) {

Bruce



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0010241241280.2027-100000>