Index: usr.sbin/makefs/ffs.c =================================================================== --- usr.sbin/makefs/ffs.c +++ usr.sbin/makefs/ffs.c @@ -882,6 +882,7 @@ 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); @@ -894,6 +895,7 @@ p = NULL; in.i_fs = (struct fs *)fsopts->superblock; + in.i_vnode = &vp; if (debug & DEBUG_FS_WRITE_FILE) { printf( @@ -914,7 +916,6 @@ 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: usr.sbin/makefs/ffs/buf.h =================================================================== --- usr.sbin/makefs/ffs/buf.h +++ usr.sbin/makefs/ffs/buf.h @@ -43,25 +43,23 @@ #include #include +struct makefs_fsinfo; struct ucred; struct vnode { - int fd; - void *fs; + struct makefs_fsinfo *v_fsinfo; void *v_data; - int offset; }; struct buf { - void * b_data; - long b_bufsize; - long b_bcount; - daddr_t b_blkno; - daddr_t b_lblkno; - int b_fd; - void * b_fs; + void *b_data; + long b_bufsize; + long b_bcount; + daddr_t b_blkno; + daddr_t b_lblkno; + struct makefs_fsinfo *b_fsinfo; - TAILQ_ENTRY(buf) b_tailq; + TAILQ_ENTRY(buf) b_tailq; }; void bcleanup(void); Index: usr.sbin/makefs/ffs/buf.c =================================================================== --- usr.sbin/makefs/ffs/buf.c +++ usr.sbin/makefs/ffs/buf.c @@ -60,7 +60,7 @@ { off_t offset; ssize_t rv; - fsinfo_t *fs = vp->fs; + fsinfo_t *fsinfo = vp->v_fsinfo; assert (bpp != NULL); @@ -68,15 +68,15 @@ printf("%s: blkno %lld size %d\n", __func__, (long long)blkno, size); *bpp = getblk(vp, blkno, size, 0, 0, 0); - offset = (*bpp)->b_blkno * fs->sectorsize + fs->offset; + offset = (*bpp)->b_blkno * fsinfo->sectorsize + fsinfo->offset; if (debug & DEBUG_BUF_BREAD) printf("%s: blkno %lld offset %lld bcount %ld\n", __func__, (long long)(*bpp)->b_blkno, (long long) offset, (*bpp)->b_bcount); - if (lseek((*bpp)->b_fd, offset, SEEK_SET) == -1) + if (lseek((*bpp)->b_fsinfo->fd, offset, SEEK_SET) == -1) err(1, "%s: lseek %lld (%lld)", __func__, (long long)(*bpp)->b_blkno, (long long)offset); - rv = read((*bpp)->b_fd, (*bpp)->b_data, (*bpp)->b_bcount); + rv = read((*bpp)->b_fsinfo->fd, (*bpp)->b_data, (*bpp)->b_bcount); if (debug & DEBUG_BUF_BREAD) printf("%s: read %ld (%lld) returned %d\n", __func__, (*bpp)->b_bcount, (long long)offset, (int)rv); @@ -125,7 +125,7 @@ { off_t offset; ssize_t rv; - fsinfo_t *fs = bp->b_fs; + fsinfo_t *fs = bp->b_fsinfo; assert (bp != NULL); offset = bp->b_blkno * fs->sectorsize + fs->offset; @@ -133,9 +133,9 @@ printf("bwrite: blkno %lld offset %lld bcount %ld\n", (long long)bp->b_blkno, (long long) offset, bp->b_bcount); - if (lseek(bp->b_fd, offset, SEEK_SET) == -1) + if (lseek(bp->b_fsinfo->fd, offset, SEEK_SET) == -1) return (errno); - rv = write(bp->b_fd, bp->b_data, bp->b_bcount); + rv = write(bp->b_fsinfo->fd, bp->b_data, bp->b_bcount); if (debug & DEBUG_BUF_BWRITE) printf("bwrite: write %ld (offset %lld) returned %lld\n", bp->b_bcount, (long long)offset, (long long)rv); @@ -198,8 +198,7 @@ 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_fsinfo = vp->v_fsinfo; bp->b_data = NULL; TAILQ_INSERT_HEAD(&buftail, bp, b_tailq); } Index: usr.sbin/makefs/ffs/ffs_alloc.c =================================================================== --- usr.sbin/makefs/ffs/ffs_alloc.c +++ usr.sbin/makefs/ffs/ffs_alloc.c @@ -298,11 +298,10 @@ 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, 0 }; 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, + error = bread(ip->i_vnode, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, NULL, &bp); if (error) { brelse(bp, 0); @@ -434,7 +433,6 @@ 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, 0 }; if (size > fs->fs_bsize || ffs_fragoff(fs, size) != 0 || ffs_fragnum(fs, bno) + ffs_numfrags(fs, size) > fs->fs_frag) { @@ -447,7 +445,7 @@ (uintmax_t)ip->i_number); return; } - error = bread(&vp, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, + error = bread(ip->i_vnode, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, NULL, &bp); if (error) { brelse(bp, 0); Index: usr.sbin/makefs/ffs/ffs_balloc.c =================================================================== --- usr.sbin/makefs/ffs/ffs_balloc.c +++ usr.sbin/makefs/ffs/ffs_balloc.c @@ -89,7 +89,6 @@ 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, 0 }; lbn = ffs_lblkno(fs, offset); size = ffs_blkoff(fs, offset) + bufsize; @@ -133,7 +132,7 @@ */ if (bpp != NULL) { - error = bread(&vp, lbn, fs->fs_bsize, NULL, + error = bread(ip->i_vnode, lbn, fs->fs_bsize, NULL, bpp); if (error) { brelse(*bpp, 0); @@ -159,7 +158,7 @@ */ if (bpp != NULL) { - error = bread(&vp, lbn, osize, NULL, + error = bread(ip->i_vnode, lbn, osize, NULL, bpp); if (error) { brelse(*bpp, 0); @@ -189,7 +188,7 @@ if (error) return (error); if (bpp != NULL) { - bp = getblk(&vp, lbn, nsize, 0, 0, 0); + bp = getblk(ip->i_vnode, lbn, nsize, 0, 0, 0); bp->b_blkno = fsbtodb(fs, newb); clrbuf(bp); *bpp = bp; @@ -227,7 +226,7 @@ return error; nb = newb; *allocblk++ = nb; - bp = getblk(&vp, indirs[1].in_lbn, fs->fs_bsize, 0, 0, 0); + bp = getblk(ip->i_vnode, indirs[1].in_lbn, fs->fs_bsize, 0, 0, 0); bp->b_blkno = fsbtodb(fs, nb); clrbuf(bp); /* @@ -245,7 +244,7 @@ */ for (i = 1;;) { - error = bread(&vp, indirs[i].in_lbn, fs->fs_bsize, NULL, &bp); + error = bread(ip->i_vnode, indirs[i].in_lbn, fs->fs_bsize, NULL, &bp); if (error) { brelse(bp, 0); return error; @@ -268,7 +267,7 @@ } nb = newb; *allocblk++ = nb; - nbp = getblk(&vp, indirs[i].in_lbn, fs->fs_bsize, 0, 0, 0); + nbp = getblk(ip->i_vnode, indirs[i].in_lbn, fs->fs_bsize, 0, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); clrbuf(nbp); /* @@ -299,7 +298,7 @@ nb = newb; *allocblk++ = nb; if (bpp != NULL) { - nbp = getblk(&vp, lbn, fs->fs_bsize, 0, 0, 0); + nbp = getblk(ip->i_vnode, lbn, fs->fs_bsize, 0, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); clrbuf(nbp); *bpp = nbp; @@ -315,7 +314,7 @@ } brelse(bp, 0); if (bpp != NULL) { - error = bread(&vp, lbn, (int)fs->fs_bsize, NULL, &nbp); + error = bread(ip->i_vnode, lbn, (int)fs->fs_bsize, NULL, &nbp); if (error) { brelse(nbp, 0); return error; @@ -340,7 +339,6 @@ 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, 0 }; lbn = ffs_lblkno(fs, offset); size = ffs_blkoff(fs, offset) + bufsize; @@ -384,7 +382,7 @@ */ if (bpp != NULL) { - error = bread(&vp, lbn, fs->fs_bsize, NULL, + error = bread(ip->i_vnode, lbn, fs->fs_bsize, NULL, bpp); if (error) { brelse(*bpp, 0); @@ -410,7 +408,7 @@ */ if (bpp != NULL) { - error = bread(&vp, lbn, osize, NULL, + error = bread(ip->i_vnode, lbn, osize, NULL, bpp); if (error) { brelse(*bpp, 0); @@ -440,7 +438,7 @@ if (error) return (error); if (bpp != NULL) { - bp = getblk(&vp, lbn, nsize, 0, 0, 0); + bp = getblk(ip->i_vnode, lbn, nsize, 0, 0, 0); bp->b_blkno = fsbtodb(fs, newb); clrbuf(bp); *bpp = bp; @@ -478,7 +476,7 @@ return error; nb = newb; *allocblk++ = nb; - bp = getblk(&vp, indirs[1].in_lbn, fs->fs_bsize, 0, 0, 0); + bp = getblk(ip->i_vnode, indirs[1].in_lbn, fs->fs_bsize, 0, 0, 0); bp->b_blkno = fsbtodb(fs, nb); clrbuf(bp); /* @@ -496,7 +494,7 @@ */ for (i = 1;;) { - error = bread(&vp, indirs[i].in_lbn, fs->fs_bsize, NULL, &bp); + error = bread(ip->i_vnode, indirs[i].in_lbn, fs->fs_bsize, NULL, &bp); if (error) { brelse(bp, 0); return error; @@ -519,7 +517,7 @@ } nb = newb; *allocblk++ = nb; - nbp = getblk(&vp, indirs[i].in_lbn, fs->fs_bsize, 0, 0, 0); + nbp = getblk(ip->i_vnode, indirs[i].in_lbn, fs->fs_bsize, 0, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); clrbuf(nbp); /* @@ -550,7 +548,7 @@ nb = newb; *allocblk++ = nb; if (bpp != NULL) { - nbp = getblk(&vp, lbn, fs->fs_bsize, 0, 0, 0); + nbp = getblk(ip->i_vnode, lbn, fs->fs_bsize, 0, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); clrbuf(nbp); *bpp = nbp; @@ -566,7 +564,7 @@ } brelse(bp, 0); if (bpp != NULL) { - error = bread(&vp, lbn, (int)fs->fs_bsize, NULL, &nbp); + error = bread(ip->i_vnode, lbn, (int)fs->fs_bsize, NULL, &nbp); if (error) { brelse(nbp, 0); return error; Index: usr.sbin/makefs/ffs/ufs_inode.h =================================================================== --- usr.sbin/makefs/ffs/ufs_inode.h +++ usr.sbin/makefs/ffs/ufs_inode.h @@ -45,9 +45,9 @@ struct inode { ino_t i_number; /* The identity of the inode. */ + struct vnode *i_vnode; /* vnode pointer (contains fsopts) */ struct fs *i_fs; /* File system */ union dinode i_din; - int i_fd; /* File descriptor */ uint64_t i_size; };