Module Name: src Committed By: christos Date: Wed Jan 30 19:19:20 UTC 2013
Modified Files: src/usr.sbin/makefs: ffs.c makefs.h msdos.c src/usr.sbin/makefs/ffs: buf.c buf.h ffs_alloc.c ffs_balloc.c ufs_inode.h src/usr.sbin/makefs/msdos: msdosfs_vfsops.c Log Message: - don't abuse vp->fs to mean struct fs for ffs and struct msdos_opts; make it always fsinfo_t and change void * to that. - kill unused structure members. To generate a diff of this commit: cvs rdiff -u -r1.58 -r1.59 src/usr.sbin/makefs/ffs.c cvs rdiff -u -r1.31 -r1.32 src/usr.sbin/makefs/makefs.h cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/makefs/msdos.c cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/makefs/ffs/buf.c cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/makefs/ffs/buf.h cvs rdiff -u -r1.22 -r1.23 src/usr.sbin/makefs/ffs/ffs_alloc.c cvs rdiff -u -r1.16 -r1.17 src/usr.sbin/makefs/ffs/ffs_balloc.c cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/makefs/ffs/ufs_inode.h cvs rdiff -u -r1.6 -r1.7 src/usr.sbin/makefs/msdos/msdosfs_vfsops.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.sbin/makefs/ffs.c diff -u src/usr.sbin/makefs/ffs.c:1.58 src/usr.sbin/makefs/ffs.c:1.59 --- src/usr.sbin/makefs/ffs.c:1.58 Wed Jan 30 12:29:25 2013 +++ src/usr.sbin/makefs/ffs.c Wed Jan 30 14:19:19 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs.c,v 1.58 2013/01/30 17:29:25 christos Exp $ */ +/* $NetBSD: ffs.c,v 1.59 2013/01/30 19:19:19 christos Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -71,7 +71,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(__lint) -__RCSID("$NetBSD: ffs.c,v 1.58 2013/01/30 17:29:25 christos Exp $"); +__RCSID("$NetBSD: ffs.c,v 1.59 2013/01/30 19:19:19 christos Exp $"); #endif /* !__lint */ #include <sys/param.h> @@ -853,6 +853,7 @@ ffs_write_file(union dinode *din, uint32 struct inode in; struct buf * bp; ffs_opt_t *ffs_opts = fsopts->fs_specific; + struct vnode vp = { fsopts, NULL }; assert (din != NULL); assert (buf != NULL); @@ -865,6 +866,7 @@ ffs_write_file(union dinode *din, uint32 p = NULL; in.i_fs = (struct fs *)fsopts->superblock; + in.i_devvp = &vp; if (debug & DEBUG_FS_WRITE_FILE) { printf( @@ -885,7 +887,6 @@ ffs_write_file(union dinode *din, uint32 else memcpy(&in.i_din.ffs2_din, &din->ffs2_din, sizeof(in.i_din.ffs2_din)); - in.i_fd = fsopts->fd; if (DIP(din, size) == 0) goto write_inode_and_leave; /* mmm, cheating */ Index: src/usr.sbin/makefs/makefs.h diff -u src/usr.sbin/makefs/makefs.h:1.31 src/usr.sbin/makefs/makefs.h:1.32 --- src/usr.sbin/makefs/makefs.h:1.31 Tue Jan 29 10:52:25 2013 +++ src/usr.sbin/makefs/makefs.h Wed Jan 30 14:19:19 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: makefs.h,v 1.31 2013/01/29 15:52:25 christos Exp $ */ +/* $NetBSD: makefs.h,v 1.32 2013/01/30 19:19:19 christos Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -141,7 +141,7 @@ typedef struct { * the image, including current settings, global options, and fs * specific options */ -typedef struct { +typedef struct makefs_fsinfo { /* current settings */ off_t size; /* total size */ off_t inodes; /* number of inodes */ Index: src/usr.sbin/makefs/msdos.c diff -u src/usr.sbin/makefs/msdos.c:1.12 src/usr.sbin/makefs/msdos.c:1.13 --- src/usr.sbin/makefs/msdos.c:1.12 Wed Jan 30 12:29:25 2013 +++ src/usr.sbin/makefs/msdos.c Wed Jan 30 14:19:19 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: msdos.c,v 1.12 2013/01/30 17:29:25 christos Exp $ */ +/* $NetBSD: msdos.c,v 1.13 2013/01/30 19:19:19 christos Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. @@ -37,7 +37,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(__lint) -__RCSID("$NetBSD: msdos.c,v 1.12 2013/01/30 17:29:25 christos Exp $"); +__RCSID("$NetBSD: msdos.c,v 1.13 2013/01/30 19:19:19 christos Exp $"); #endif /* !__lint */ #include <sys/param.h> @@ -150,10 +150,10 @@ msdos_makefs(const char *image, const ch */ msdos_opt->create_size = MAX(msdos_opt->create_size, fsopts->minsize); if (msdos_opt->bytes_per_sector == 0) { - if (fsopts->sectorsize == 0) + if (fsopts->sectorsize == -1) fsopts->sectorsize = 512; msdos_opt->bytes_per_sector = fsopts->sectorsize; - } else if (fsopts->sectorsize == 0) { + } else if (fsopts->sectorsize == -1) { fsopts->sectorsize = msdos_opt->bytes_per_sector; } else if (fsopts->sectorsize != msdos_opt->bytes_per_sector) { err(1, "inconsistent sectorsize -S %u" @@ -168,8 +168,8 @@ msdos_makefs(const char *image, const ch return; TIMER_RESULTS(start, "mkfs_msdos"); - vp.fd = open(image, O_RDWR); - vp.fs = msdos_opt; + fsopts->fd = open(image, O_RDWR); + vp.fs = fsopts; if ((pmp = msdosfs_mount(&vp, 0)) == NULL) err(1, "msdosfs_mount"); Index: src/usr.sbin/makefs/ffs/buf.c diff -u src/usr.sbin/makefs/ffs/buf.c:1.18 src/usr.sbin/makefs/ffs/buf.c:1.19 --- src/usr.sbin/makefs/ffs/buf.c:1.18 Wed Jan 30 12:29:05 2013 +++ src/usr.sbin/makefs/ffs/buf.c Wed Jan 30 14:19:19 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: buf.c,v 1.18 2013/01/30 17:29:05 christos Exp $ */ +/* $NetBSD: buf.c,v 1.19 2013/01/30 19:19:19 christos Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -41,7 +41,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(__lint) -__RCSID("$NetBSD: buf.c,v 1.18 2013/01/30 17:29:05 christos Exp $"); +__RCSID("$NetBSD: buf.c,v 1.19 2013/01/30 19:19:19 christos Exp $"); #endif /* !__lint */ #include <sys/param.h> @@ -77,10 +77,10 @@ bread(struct vnode *vp, daddr_t blkno, i printf("bread: blkno %lld offset %lld bcount %ld\n", (long long)(*bpp)->b_blkno, (long long) offset, (*bpp)->b_bcount); - if (lseek((*bpp)->b_fd, offset, SEEK_SET) == -1) + if (lseek((*bpp)->b_fs->fd, offset, SEEK_SET) == -1) err(1, "bread: lseek %lld (%lld)", (long long)(*bpp)->b_blkno, (long long)offset); - rv = read((*bpp)->b_fd, (*bpp)->b_data, (*bpp)->b_bcount); + rv = read((*bpp)->b_fs->fd, (*bpp)->b_data, (*bpp)->b_bcount); if (debug & DEBUG_BUF_BREAD) printf("bread: read %ld (%lld) returned %d\n", (*bpp)->b_bcount, (long long)offset, (int)rv); @@ -138,9 +138,9 @@ bwrite(struct buf *bp) if (debug & DEBUG_BUF_BWRITE) printf("bwrite: blkno %lld offset %lld bcount %d\n", (long long)bp->b_blkno, (long long) offset, bytes); - if (lseek(bp->b_fd, offset, SEEK_SET) == -1) + if (lseek(bp->b_fs->fd, offset, SEEK_SET) == -1) return (errno); - rv = write(bp->b_fd, bp->b_data, bytes); + rv = write(bp->b_fs->fd, bp->b_data, bytes); if (debug & DEBUG_BUF_BWRITE) printf("bwrite: write %ld (offset %lld) returned %lld\n", bp->b_bcount, (long long)offset, (long long)rv); @@ -204,7 +204,6 @@ getblk(struct vnode *vp, daddr_t blkno, bp = ecalloc(1, sizeof(*bp)); bp->b_bufsize = 0; bp->b_blkno = bp->b_lblkno = blkno; - bp->b_fd = vp->fd; bp->b_fs = vp->fs; bp->b_data = NULL; TAILQ_INSERT_HEAD(&buftail, bp, b_tailq); Index: src/usr.sbin/makefs/ffs/buf.h diff -u src/usr.sbin/makefs/ffs/buf.h:1.8 src/usr.sbin/makefs/ffs/buf.h:1.9 --- src/usr.sbin/makefs/ffs/buf.h:1.8 Wed Jan 30 12:29:05 2013 +++ src/usr.sbin/makefs/ffs/buf.h Wed Jan 30 14:19:19 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: buf.h,v 1.8 2013/01/30 17:29:05 christos Exp $ */ +/* $NetBSD: buf.h,v 1.9 2013/01/30 19:19:19 christos Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -54,9 +54,9 @@ struct componentname { size_t cn_namelen; }; +struct makefs_fsinfo; struct vnode { - int fd; - void *fs; + struct makefs_fsinfo *fs; void *v_data; }; @@ -68,8 +68,7 @@ struct buf { long b_bcount; daddr_t b_blkno; daddr_t b_lblkno; - int b_fd; - void * b_fs; + struct makefs_fsinfo * b_fs; TAILQ_ENTRY(buf) b_tailq; }; Index: src/usr.sbin/makefs/ffs/ffs_alloc.c diff -u src/usr.sbin/makefs/ffs/ffs_alloc.c:1.22 src/usr.sbin/makefs/ffs/ffs_alloc.c:1.23 --- src/usr.sbin/makefs/ffs/ffs_alloc.c:1.22 Sun Jan 27 15:05:46 2013 +++ src/usr.sbin/makefs/ffs/ffs_alloc.c Wed Jan 30 14:19:19 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_alloc.c,v 1.22 2013/01/27 20:05:46 christos Exp $ */ +/* $NetBSD: ffs_alloc.c,v 1.23 2013/01/30 19:19:19 christos Exp $ */ /* From: NetBSD: ffs_alloc.c,v 1.50 2001/09/06 02:16:01 lukem Exp */ /* @@ -47,7 +47,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(__lint) -__RCSID("$NetBSD: ffs_alloc.c,v 1.22 2013/01/27 20:05:46 christos Exp $"); +__RCSID("$NetBSD: ffs_alloc.c,v 1.23 2013/01/30 19:19:19 christos Exp $"); #endif /* !__lint */ #include <sys/param.h> @@ -304,12 +304,11 @@ ffs_alloccg(struct inode *ip, int cg, da int error, frags, allocsiz, i; struct fs *fs = ip->i_fs; const int needswap = UFS_FSNEEDSWAP(fs); - struct vnode vp = { ip->i_fd, ip->i_fs, NULL }; if (fs->fs_cs(fs, cg).cs_nbfree == 0 && size == fs->fs_bsize) return (0); - error = bread(&vp, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, - NULL, 0, &bp); + error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), + (int)fs->fs_cgsize, NULL, 0, &bp); if (error) { return (0); } @@ -439,7 +438,6 @@ ffs_blkfree(struct inode *ip, daddr_t bn int i, error, cg, blk, frags, bbase; struct fs *fs = ip->i_fs; const int needswap = UFS_FSNEEDSWAP(fs); - struct vnode vp = { ip->i_fd, ip->i_fs, NULL }; if (size > fs->fs_bsize || fragoff(fs, size) != 0 || fragnum(fs, bno) + numfrags(fs, size) > fs->fs_frag) { @@ -452,8 +450,8 @@ ffs_blkfree(struct inode *ip, daddr_t bn (unsigned long long)ip->i_number); return; } - error = bread(&vp, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, - NULL, 0, &bp); + error = bread(ip->i_devvp, fsbtodb(fs, cgtod(fs, cg)), + (int)fs->fs_cgsize, NULL, 0, &bp); if (error) { brelse(bp, 0); return; Index: src/usr.sbin/makefs/ffs/ffs_balloc.c diff -u src/usr.sbin/makefs/ffs/ffs_balloc.c:1.16 src/usr.sbin/makefs/ffs/ffs_balloc.c:1.17 --- src/usr.sbin/makefs/ffs/ffs_balloc.c:1.16 Sun Jan 27 15:05:46 2013 +++ src/usr.sbin/makefs/ffs/ffs_balloc.c Wed Jan 30 14:19:19 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_balloc.c,v 1.16 2013/01/27 20:05:46 christos Exp $ */ +/* $NetBSD: ffs_balloc.c,v 1.17 2013/01/30 19:19:19 christos Exp $ */ /* From NetBSD: ffs_balloc.c,v 1.25 2001/08/08 08:36:36 lukem Exp */ /* @@ -38,7 +38,7 @@ #include <sys/cdefs.h> #if defined(__RCSID) && !defined(__lint) -__RCSID("$NetBSD: ffs_balloc.c,v 1.16 2013/01/27 20:05:46 christos Exp $"); +__RCSID("$NetBSD: ffs_balloc.c,v 1.17 2013/01/30 19:19:19 christos Exp $"); #endif /* !__lint */ #include <sys/param.h> @@ -95,7 +95,6 @@ ffs_balloc_ufs1(struct inode *ip, off_t int32_t *allocblk, allociblk[UFS_NIADDR + 1]; int32_t *allocib; const int needswap = UFS_FSNEEDSWAP(fs); - struct vnode vp = { ip->i_fd, ip->i_fs, NULL }; lbn = lblkno(fs, offset); size = blkoff(fs, offset) + bufsize; @@ -139,8 +138,8 @@ ffs_balloc_ufs1(struct inode *ip, off_t */ if (bpp != NULL) { - error = bread(&vp, lbn, fs->fs_bsize, NULL, 0, - bpp); + error = bread(ip->i_devvp, lbn, fs->fs_bsize, + NULL, 0, bpp); if (error) { brelse(*bpp, 0); return (error); @@ -165,8 +164,8 @@ ffs_balloc_ufs1(struct inode *ip, off_t */ if (bpp != NULL) { - error = bread(&vp, lbn, osize, NULL, 0, - bpp); + error = bread(ip->i_devvp, lbn, osize, + NULL, 0, bpp); if (error) { brelse(*bpp, 0); return (error); @@ -195,7 +194,7 @@ ffs_balloc_ufs1(struct inode *ip, off_t if (error) return (error); if (bpp != NULL) { - bp = getblk(&vp, lbn, nsize, 0, 0); + bp = getblk(ip->i_devvp, lbn, nsize, 0, 0); bp->b_blkno = fsbtodb(fs, newb); clrbuf(bp); *bpp = bp; @@ -233,7 +232,7 @@ ffs_balloc_ufs1(struct inode *ip, off_t return error; nb = newb; *allocblk++ = nb; - bp = getblk(&vp, indirs[1].in_lbn, fs->fs_bsize, 0, 0); + bp = getblk(ip->i_devvp, indirs[1].in_lbn, fs->fs_bsize, 0, 0); bp->b_blkno = fsbtodb(fs, nb); clrbuf(bp); /* @@ -251,8 +250,8 @@ ffs_balloc_ufs1(struct inode *ip, off_t */ for (i = 1;;) { - error = bread(&vp, indirs[i].in_lbn, fs->fs_bsize, NULL, 0, - &bp); + error = bread(ip->i_devvp, indirs[i].in_lbn, fs->fs_bsize, + NULL, 0, &bp); if (error) { brelse(bp, 0); return error; @@ -275,7 +274,7 @@ ffs_balloc_ufs1(struct inode *ip, off_t } nb = newb; *allocblk++ = nb; - nbp = getblk(&vp, indirs[i].in_lbn, fs->fs_bsize, 0, 0); + nbp = getblk(ip->i_devvp, indirs[i].in_lbn, fs->fs_bsize, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); clrbuf(nbp); /* @@ -306,7 +305,7 @@ ffs_balloc_ufs1(struct inode *ip, off_t nb = newb; *allocblk++ = nb; if (bpp != NULL) { - nbp = getblk(&vp, lbn, fs->fs_bsize, 0, 0); + nbp = getblk(ip->i_devvp, lbn, fs->fs_bsize, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); clrbuf(nbp); *bpp = nbp; @@ -322,7 +321,8 @@ ffs_balloc_ufs1(struct inode *ip, off_t } brelse(bp, 0); if (bpp != NULL) { - error = bread(&vp, lbn, (int)fs->fs_bsize, NULL, 0, &nbp); + error = bread(ip->i_devvp, lbn, (int)fs->fs_bsize, NULL, 0, + &nbp); if (error) { brelse(nbp, 0); return error; @@ -346,7 +346,6 @@ ffs_balloc_ufs2(struct inode *ip, off_t int64_t *allocblk, allociblk[UFS_NIADDR + 1]; int64_t *allocib; const int needswap = UFS_FSNEEDSWAP(fs); - struct vnode vp = { ip->i_fd, ip->i_fs, NULL }; lbn = lblkno(fs, offset); size = blkoff(fs, offset) + bufsize; @@ -390,8 +389,8 @@ ffs_balloc_ufs2(struct inode *ip, off_t */ if (bpp != NULL) { - error = bread(&vp, lbn, fs->fs_bsize, NULL, 0, - bpp); + error = bread(ip->i_devvp, lbn, fs->fs_bsize, + NULL, 0, bpp); if (error) { brelse(*bpp, 0); return (error); @@ -416,8 +415,8 @@ ffs_balloc_ufs2(struct inode *ip, off_t */ if (bpp != NULL) { - error = bread(&vp, lbn, osize, NULL, 0, - bpp); + error = bread(ip->i_devvp, lbn, osize, + NULL, 0, bpp); if (error) { brelse(*bpp, 0); return (error); @@ -446,7 +445,7 @@ ffs_balloc_ufs2(struct inode *ip, off_t if (error) return (error); if (bpp != NULL) { - bp = getblk(&vp, lbn, nsize, 0, 0); + bp = getblk(ip->i_devvp, lbn, nsize, 0, 0); bp->b_blkno = fsbtodb(fs, newb); clrbuf(bp); *bpp = bp; @@ -484,7 +483,7 @@ ffs_balloc_ufs2(struct inode *ip, off_t return error; nb = newb; *allocblk++ = nb; - bp = getblk(&vp, indirs[1].in_lbn, fs->fs_bsize, 0, 0); + bp = getblk(ip->i_devvp, indirs[1].in_lbn, fs->fs_bsize, 0, 0); bp->b_blkno = fsbtodb(fs, nb); clrbuf(bp); /* @@ -502,8 +501,8 @@ ffs_balloc_ufs2(struct inode *ip, off_t */ for (i = 1;;) { - error = bread(&vp, indirs[i].in_lbn, fs->fs_bsize, NULL, 0, - &bp); + error = bread(ip->i_devvp, indirs[i].in_lbn, fs->fs_bsize, + NULL, 0, &bp); if (error) { brelse(bp, 0); return error; @@ -526,7 +525,7 @@ ffs_balloc_ufs2(struct inode *ip, off_t } nb = newb; *allocblk++ = nb; - nbp = getblk(&vp, indirs[i].in_lbn, fs->fs_bsize, 0, 0); + nbp = getblk(ip->i_devvp, indirs[i].in_lbn, fs->fs_bsize, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); clrbuf(nbp); /* @@ -557,7 +556,7 @@ ffs_balloc_ufs2(struct inode *ip, off_t nb = newb; *allocblk++ = nb; if (bpp != NULL) { - nbp = getblk(&vp, lbn, fs->fs_bsize, 0, 0); + nbp = getblk(ip->i_devvp, lbn, fs->fs_bsize, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); clrbuf(nbp); *bpp = nbp; @@ -573,7 +572,8 @@ ffs_balloc_ufs2(struct inode *ip, off_t } brelse(bp, 0); if (bpp != NULL) { - error = bread(&vp, lbn, (int)fs->fs_bsize, NULL, 0, &nbp); + error = bread(ip->i_devvp, lbn, (int)fs->fs_bsize, NULL, 0, + &nbp); if (error) { brelse(nbp, 0); return error; Index: src/usr.sbin/makefs/ffs/ufs_inode.h diff -u src/usr.sbin/makefs/ffs/ufs_inode.h:1.4 src/usr.sbin/makefs/ffs/ufs_inode.h:1.5 --- src/usr.sbin/makefs/ffs/ufs_inode.h:1.4 Wed Jun 22 20:53:16 2005 +++ src/usr.sbin/makefs/ffs/ufs_inode.h Wed Jan 30 14:19:19 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_inode.h,v 1.4 2005/06/23 00:53:16 fvdl Exp $ */ +/* $NetBSD: ufs_inode.h,v 1.5 2013/01/30 19:19:19 christos Exp $ */ /* From: NetBSD: inode.h,v 1.27 2001/12/18 10:57:23 fvdl Exp $ */ /* @@ -44,9 +44,9 @@ union dinode { struct inode { ino_t i_number; /* The identity of the inode. */ + struct vnode *i_devvp; /* device vnode for block I/O */ struct fs *i_fs; /* File system */ union dinode i_din; - int i_fd; /* File descriptor */ uint64_t i_size; }; Index: src/usr.sbin/makefs/msdos/msdosfs_vfsops.c diff -u src/usr.sbin/makefs/msdos/msdosfs_vfsops.c:1.6 src/usr.sbin/makefs/msdos/msdosfs_vfsops.c:1.7 --- src/usr.sbin/makefs/msdos/msdosfs_vfsops.c:1.6 Mon Jan 28 16:03:29 2013 +++ src/usr.sbin/makefs/msdos/msdosfs_vfsops.c Wed Jan 30 14:19:19 2013 @@ -50,7 +50,7 @@ #endif #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.6 2013/01/28 21:03:29 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.7 2013/01/30 19:19:19 christos Exp $"); #include <sys/param.h> @@ -91,7 +91,7 @@ msdosfs_mount(struct vnode *devvp, int f uint8_t SecPerClust; int ronly = 0, error, tmp; int bsize; - struct msdos_options *m = devvp->fs; + struct msdos_options *m = devvp->fs->fs_specific; uint64_t psize = m->create_size; unsigned secsize = 512;