Index: usr.sbin/makefs/ffs.c =================================================================== --- usr.sbin/makefs/ffs.c +++ usr.sbin/makefs/ffs.c @@ -875,6 +875,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); @@ -887,6 +888,7 @@ p = NULL; in.i_fs = (struct fs *)fsopts->superblock; + in.i_devvp = &vp; if (debug & DEBUG_FS_WRITE_FILE) { printf( @@ -907,7 +909,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,13 +43,12 @@ #include #include +struct makefs_fsinfo; struct ucred; struct vnode { - int fd; - void *fs; - void *v_data; - int offset; + struct makefs_fsinfo *fs; + void *v_data; }; struct buf { @@ -58,8 +57,7 @@ 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: 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->fs; 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; + offset = (*bpp)->b_blkno * fsinfo->sectorsize; 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_fs->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_fs->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); @@ -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_fs->fd, offset, SEEK_SET) == -1) return (errno); - rv = write(bp->b_fd, bp->b_data, bp->b_bcount); + rv = write(bp->b_fs->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,7 +198,6 @@ 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: usr.sbin/makefs/ffs/ffs_alloc.c =================================================================== --- usr.sbin/makefs/ffs/ffs_alloc.c +++ usr.sbin/makefs/ffs/ffs_alloc.c @@ -297,11 +297,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_devvp, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, NULL, &bp); if (error) { brelse(bp, 0); @@ -433,7 +432,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 || fragoff(fs, size) != 0 || fragnum(fs, bno) + numfrags(fs, size) > fs->fs_frag) { @@ -446,7 +444,7 @@ (uintmax_t)ip->i_number); return; } - error = bread(&vp, fsbtodb(fs, cgtod(fs, cg)), (int)fs->fs_cgsize, + error = bread(ip->i_devvp, 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 = lblkno(fs, offset); size = blkoff(fs, offset) + bufsize; @@ -134,7 +133,7 @@ */ if (bpp != NULL) { - error = bread(&vp, lbn, fs->fs_bsize, NULL, + error = bread(ip->i_devvp, lbn, fs->fs_bsize, NULL, bpp); if (error) { brelse(*bpp, 0); @@ -160,7 +159,7 @@ */ if (bpp != NULL) { - error = bread(&vp, lbn, osize, NULL, + error = bread(ip->i_devvp, lbn, osize, NULL, bpp); if (error) { brelse(*bpp, 0); @@ -190,7 +189,7 @@ if (error) return (error); if (bpp != NULL) { - bp = getblk(&vp, lbn, nsize, 0, 0, 0); + bp = getblk(ip->i_devvp, lbn, nsize, 0, 0, 0); bp->b_blkno = fsbtodb(fs, newb); clrbuf(bp); *bpp = bp; @@ -228,7 +227,7 @@ return error; nb = newb; *allocblk++ = nb; - bp = getblk(&vp, indirs[1].in_lbn, fs->fs_bsize, 0, 0, 0); + bp = getblk(ip->i_devvp, indirs[1].in_lbn, fs->fs_bsize, 0, 0, 0); bp->b_blkno = fsbtodb(fs, nb); clrbuf(bp); /* @@ -246,7 +245,7 @@ */ for (i = 1;;) { - error = bread(&vp, indirs[i].in_lbn, fs->fs_bsize, NULL, &bp); + error = bread(ip->i_devvp, indirs[i].in_lbn, fs->fs_bsize, NULL, &bp); if (error) { brelse(bp, 0); return error; @@ -269,7 +268,7 @@ } nb = newb; *allocblk++ = nb; - nbp = getblk(&vp, indirs[i].in_lbn, fs->fs_bsize, 0, 0, 0); + nbp = getblk(ip->i_devvp, indirs[i].in_lbn, fs->fs_bsize, 0, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); clrbuf(nbp); /* @@ -300,7 +299,7 @@ nb = newb; *allocblk++ = nb; if (bpp != NULL) { - nbp = getblk(&vp, lbn, fs->fs_bsize, 0, 0, 0); + nbp = getblk(ip->i_devvp, lbn, fs->fs_bsize, 0, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); clrbuf(nbp); *bpp = nbp; @@ -316,7 +315,7 @@ } brelse(bp, 0); if (bpp != NULL) { - error = bread(&vp, lbn, (int)fs->fs_bsize, NULL, &nbp); + error = bread(ip->i_devvp, 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 = lblkno(fs, offset); size = blkoff(fs, offset) + bufsize; @@ -385,7 +383,7 @@ */ if (bpp != NULL) { - error = bread(&vp, lbn, fs->fs_bsize, NULL, + error = bread(ip->i_devvp, lbn, fs->fs_bsize, NULL, bpp); if (error) { brelse(*bpp, 0); @@ -411,7 +409,7 @@ */ if (bpp != NULL) { - error = bread(&vp, lbn, osize, NULL, + error = bread(ip->i_devvp, lbn, osize, NULL, bpp); if (error) { brelse(*bpp, 0); @@ -441,7 +439,7 @@ if (error) return (error); if (bpp != NULL) { - bp = getblk(&vp, lbn, nsize, 0, 0, 0); + bp = getblk(ip->i_devvp, lbn, nsize, 0, 0, 0); bp->b_blkno = fsbtodb(fs, newb); clrbuf(bp); *bpp = bp; @@ -479,7 +477,7 @@ return error; nb = newb; *allocblk++ = nb; - bp = getblk(&vp, indirs[1].in_lbn, fs->fs_bsize, 0, 0, 0); + bp = getblk(ip->i_devvp, indirs[1].in_lbn, fs->fs_bsize, 0, 0, 0); bp->b_blkno = fsbtodb(fs, nb); clrbuf(bp); /* @@ -497,7 +495,7 @@ */ for (i = 1;;) { - error = bread(&vp, indirs[i].in_lbn, fs->fs_bsize, NULL, &bp); + error = bread(ip->i_devvp, indirs[i].in_lbn, fs->fs_bsize, NULL, &bp); if (error) { brelse(bp, 0); return error; @@ -520,7 +518,7 @@ } nb = newb; *allocblk++ = nb; - nbp = getblk(&vp, indirs[i].in_lbn, fs->fs_bsize, 0, 0, 0); + nbp = getblk(ip->i_devvp, indirs[i].in_lbn, fs->fs_bsize, 0, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); clrbuf(nbp); /* @@ -551,7 +549,7 @@ nb = newb; *allocblk++ = nb; if (bpp != NULL) { - nbp = getblk(&vp, lbn, fs->fs_bsize, 0, 0, 0); + nbp = getblk(ip->i_devvp, lbn, fs->fs_bsize, 0, 0, 0); nbp->b_blkno = fsbtodb(fs, nb); clrbuf(nbp); *bpp = nbp; @@ -567,7 +565,7 @@ } brelse(bp, 0); if (bpp != NULL) { - error = bread(&vp, lbn, (int)fs->fs_bsize, NULL, &nbp); + error = bread(ip->i_devvp, 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_devvp; /* vnode pointer (contains fsopts) */ struct fs *i_fs; /* File system */ union dinode i_din; - int i_fd; /* File descriptor */ uint64_t i_size; };