From 15fc093acc2cba78e947b68d4a0f30cf15a15587 Mon Sep 17 00:00:00 2001 From: Ed Maste Date: Wed, 3 May 2017 14:21:18 +0000 Subject: [PATCH] makefs: make buf generic it has nothing to do with ffs and will eventually be moved. gc sectorsize. NetBSD versions: ffs.c 1.58 ffs/buf.c 1.14 1.18 ffs/buf.h 1.8 Obtained from: NetBSD Sponsored by: The FreeBSD Foundation --- usr.sbin/makefs/ffs.c | 3 --- usr.sbin/makefs/ffs/buf.c | 25 +++++++------------------ usr.sbin/makefs/ffs/buf.h | 2 +- 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/usr.sbin/makefs/ffs.c b/usr.sbin/makefs/ffs.c index 5e38f7ace6ff..8c6d12b4f201 100644 --- a/usr.sbin/makefs/ffs.c +++ b/usr.sbin/makefs/ffs.c @@ -144,7 +144,6 @@ static void *ffs_build_dinode2(struct ufs2_dinode *, dirbuf_t *, fsnode *, -int sectorsize; /* XXX: for buf.c::getblk() */ /* publicly visible functions */ void @@ -427,8 +426,6 @@ ffs_validate(const char *dir, fsnode *root, fsinfo_t *fsopts) printf("ffs_validate: dir %s; %lld bytes, %lld inodes\n", dir, (long long)fsopts->size, (long long)fsopts->inodes); } - sectorsize = fsopts->sectorsize; /* XXX - see earlier */ - /* now check calculated sizes vs requested sizes */ if (fsopts->maxsize > 0 && fsopts->size > fsopts->maxsize) { errx(1, "`%s' size of %lld is larger than the maxsize of %lld.", diff --git a/usr.sbin/makefs/ffs/buf.c b/usr.sbin/makefs/ffs/buf.c index c2d561ae2b99..325d59b4a337 100644 --- a/usr.sbin/makefs/ffs/buf.c +++ b/usr.sbin/makefs/ffs/buf.c @@ -50,14 +50,7 @@ __FBSDID("$FreeBSD$"); #include #include "makefs.h" - -#include -#include - -#include "ffs/buf.h" -#include "ffs/ufs_inode.h" - -extern int sectorsize; /* XXX: from ffs.c & mkfs.c */ +#include "buf.h" TAILQ_HEAD(buftailhead,buf) buftail; @@ -67,16 +60,15 @@ bread(struct vnode *vp, daddr_t blkno, int size, struct ucred *u1 __unused, { off_t offset; ssize_t rv; - struct fs *fs = vp->fs; + fsinfo_t *fs = vp->fs; - assert (fs != NULL); assert (bpp != NULL); if (debug & DEBUG_BUF_BREAD) printf("%s: blkno %lld size %d\n", __func__, (long long)blkno, size); *bpp = getblk(vp, blkno, size, 0, 0, 0); - offset = (*bpp)->b_blkno * sectorsize; /* XXX */ + offset = (*bpp)->b_blkno * fs->sectorsize; if (debug & DEBUG_BUF_BREAD) printf("%s: blkno %lld offset %lld bcount %ld\n", __func__, (long long)(*bpp)->b_blkno, (long long) offset, @@ -133,9 +125,10 @@ bwrite(struct buf *bp) { off_t offset; ssize_t rv; + fsinfo_t *fs = bp->b_fs; assert (bp != NULL); - offset = bp->b_blkno * sectorsize; /* XXX */ + offset = bp->b_blkno * fs->sectorsize; if (debug & DEBUG_BUF_BWRITE) printf("bwrite: blkno %lld offset %lld bcount %ld\n", (long long)bp->b_blkno, (long long) offset, @@ -184,11 +177,7 @@ getblk(struct vnode *vp, daddr_t blkno, int size, int u1 __unused, static int buftailinitted; struct buf *bp; void *n; - int fd = vp->fd; - struct fs *fs = vp->fs; - blkno += vp->offset; - assert (fs != NULL); if (debug & DEBUG_BUF_GETBLK) printf("getblk: blkno %lld size %d\n", (long long)blkno, size); @@ -209,8 +198,8 @@ getblk(struct vnode *vp, daddr_t blkno, int size, int u1 __unused, bp = ecalloc(1, sizeof(*bp)); bp->b_bufsize = 0; bp->b_blkno = bp->b_lblkno = blkno; - bp->b_fd = fd; - bp->b_fs = fs; + bp->b_fd = vp->fd; + bp->b_fs = vp->fs; bp->b_data = NULL; TAILQ_INSERT_HEAD(&buftail, bp, b_tailq); } diff --git a/usr.sbin/makefs/ffs/buf.h b/usr.sbin/makefs/ffs/buf.h index b082f48650ea..16149c67fbbd 100644 --- a/usr.sbin/makefs/ffs/buf.h +++ b/usr.sbin/makefs/ffs/buf.h @@ -59,7 +59,7 @@ struct buf { daddr_t b_blkno; daddr_t b_lblkno; int b_fd; - struct fs * b_fs; + void * b_fs; TAILQ_ENTRY(buf) b_tailq; };