Subject: bin/5257: newlfs problem
To: None <gnats-bugs@gnats.netbsd.org>
From: None <jam@pobox.com>
List: netbsd-bugs
Date: 04/05/1998 22:18:21
>Number:         5257
>Category:       bin
>Synopsis:       newlfs doesn't work
>Confidential:   no
>Severity:       critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Apr  5 22:20:00 1998
>Last-Modified:
>Originator:     Kazushi (Jam) Marukawa
>Organization:
>Release:        1.3E 891708217
>Environment:
System: NetBSD sou.nerv.org 1.3E NetBSD 1.3E (sou) #3: Sun Apr 5 15:40:36 CDT 1998 jam@sou.nerv.org:/usr/src/sys/arch/i386/compile/sou i386


>Description:
newlfs doesn't work.
>How-To-Repeat:
Run newlfs on an enought large partition.
There are 2 problems in newfs. One is the writing not aligned data to
character device.  The other is the using "int" instead of "off_t".
>Fix:
I made following dirty patch to fix it.  I hope someone fix it correctly.


diff -au newlfs/lfs.c.orig newlfs/lfs.c
--- newlfs/lfs.c.orig	Thu Apr  2 06:17:46 1998
+++ newlfs/lfs.c	Sun Apr  5 23:24:58 1998
@@ -210,9 +210,9 @@
 	int fsize;		/* Fragment size */
 	int db_per_fb;		/* Disk blocks per file block */
 	int i, j;
-	int off;		/* Offset at which to write */
+	off_t off;		/* Offset at which to write */
 	int sb_interval;	/* number of segs between super blocks */
-	int seg_seek;		/* Seek offset for a segment */
+	off_t seg_seek;		/* Seek offset for a segment */
 	int ssize;		/* Segment size */
 	int sum_size;		/* Size of the summary block */
 
@@ -618,6 +618,14 @@
 
 	if (lseek(fd, off, SEEK_SET) < 0)
 		fatal("%s: %s", special, strerror(errno));
+#if 1
+	/*
+	 * The sizeof(struct lfs) is not matched to the size of sector.
+	 * I add following codes, but 512 is a magic number.
+	 */
+	if (len != (len / 512) * 512)
+	    len = (len + 511) / 512 * 512;
+#endif
 	if ((wbytes = write(fd, p, len)) < 0)
 		fatal("%s: %s", special, strerror(errno));
 	if (wbytes != len)
>Audit-Trail:
>Unformatted: