Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Feb 2009 15:28:15 +0000 (UTC)
From:      Olivier Houchard <cognet@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r188520 - head/sbin/newfs
Message-ID:  <200902121528.n1CFSF9n059562@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: cognet
Date: Thu Feb 12 15:28:15 2009
New Revision: 188520
URL: http://svn.freebsd.org/changeset/base/188520

Log:
  Don't add a bwrite() symbol, it breaks the build when building newfs
  statically.
  Instead, bring in a stripped down version of sbwrite(), and add the offset
  to every bwrite() calls.

Modified:
  head/sbin/newfs/mkfs.c
  head/sbin/newfs/newfs.c

Modified: head/sbin/newfs/mkfs.c
==============================================================================
--- head/sbin/newfs/mkfs.c	Thu Feb 12 15:26:27 2009	(r188519)
+++ head/sbin/newfs/mkfs.c	Thu Feb 12 15:28:15 2009	(r188520)
@@ -101,6 +101,15 @@ static void setblock(struct fs *, unsign
 static void wtfs(ufs2_daddr_t, int, char *);
 static u_int32_t newfs_random(void);
 
+static int
+do_sbwrite(struct uufsd *disk)
+{
+	if (!disk->d_sblock)
+		disk->d_sblock = disk->d_fs.fs_sblockloc / disk->d_bsize;
+	return (pwrite(disk->d_fd, &disk->d_fs, SBLOCKSIZE, (off_t)((part_ofs +
+	    disk->d_sblock) * disk->d_bsize)));
+}
+
 void
 mkfs(struct partition *pp, char *fsys)
 {
@@ -465,14 +474,15 @@ mkfs(struct partition *pp, char *fsys)
 
 		if (fsdummy.fs_magic == FS_UFS1_MAGIC) {
 			fsdummy.fs_magic = 0;
-			bwrite(&disk, SBLOCK_UFS1 / disk.d_bsize, chdummy, SBLOCKSIZE);
+			bwrite(&disk, part_ofs + SBLOCK_UFS1 / disk.d_bsize,
+			    chdummy, SBLOCKSIZE);
 			for (i = 0; i < fsdummy.fs_ncg; i++)
-				bwrite(&disk, fsbtodb(&fsdummy, cgsblock(&fsdummy, i)),
-	                    chdummy, SBLOCKSIZE);
+				bwrite(&disk, part_ofs + fsbtodb(&fsdummy,
+				    cgsblock(&fsdummy, i)), chdummy, SBLOCKSIZE);
 		}
 	}
 	if (!Nflag)
-		sbwrite(&disk, 0);
+		do_sbwrite(&disk);
 	if (Xflag == 1) {
 		printf("** Exiting on Xflag 1\n");
 		exit(0);
@@ -540,7 +550,7 @@ mkfs(struct partition *pp, char *fsys)
 		exit(0);
 	}
 	if (!Nflag)
-		sbwrite(&disk, 0);
+		do_sbwrite(&disk);
 	for (i = 0; i < sblock.fs_cssize; i += sblock.fs_bsize)
 		wtfs(fsbtodb(&sblock, sblock.fs_csaddr + numfrags(&sblock, i)),
 			sblock.fs_cssize - i < sblock.fs_bsize ?
@@ -960,7 +970,7 @@ wtfs(ufs2_daddr_t bno, int size, char *b
 {
 	if (Nflag)
 		return;
-	if (bwrite(&disk, bno, bf, size) < 0)
+	if (bwrite(&disk, part_ofs + bno, bf, size) < 0)
 		err(36, "wtfs: %d bytes at sector %jd", size, (intmax_t)bno);
 }
 

Modified: head/sbin/newfs/newfs.c
==============================================================================
--- head/sbin/newfs/newfs.c	Thu Feb 12 15:26:27 2009	(r188519)
+++ head/sbin/newfs/newfs.c	Thu Feb 12 15:28:15 2009	(r188520)
@@ -152,16 +152,6 @@ static void usage(void);
 
 ufs2_daddr_t part_ofs; /* partition offset in blocks, used with files */
 
-/*
- * need to replace the library's bwrite so that sbwrite uses this one
- */
-ssize_t
-bwrite(struct uufsd *disk, ufs2_daddr_t blockno, const void *data, size_t size)
-{
-	return pwrite(disk->d_fd, data, size,
-		(off_t)((part_ofs + blockno) * disk->d_bsize));
-}
-
 int
 main(int argc, char *argv[])
 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902121528.n1CFSF9n059562>