From owner-svn-src-all@FreeBSD.ORG Thu Feb 12 15:28:15 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D33121065672; Thu, 12 Feb 2009 15:28:15 +0000 (UTC) (envelope-from cognet@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A74148FC0A; Thu, 12 Feb 2009 15:28:15 +0000 (UTC) (envelope-from cognet@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n1CFSFSc059564; Thu, 12 Feb 2009 15:28:15 GMT (envelope-from cognet@svn.freebsd.org) Received: (from cognet@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n1CFSF9n059562; Thu, 12 Feb 2009 15:28:15 GMT (envelope-from cognet@svn.freebsd.org) Message-Id: <200902121528.n1CFSF9n059562@svn.freebsd.org> From: Olivier Houchard Date: Thu, 12 Feb 2009 15:28:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188520 - head/sbin/newfs X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Feb 2009 15:28:16 -0000 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[]) {