Author: emaste
Date: Wed May  3 14:21:18 2017
New Revision: 317744
URL: https://svnweb.freebsd.org/changeset/base/317744

Log:
  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

Modified:
  head/usr.sbin/makefs/ffs.c
  head/usr.sbin/makefs/ffs/buf.c
  head/usr.sbin/makefs/ffs/buf.h

Modified: head/usr.sbin/makefs/ffs.c
==============================================================================
--- head/usr.sbin/makefs/ffs.c  Wed May  3 14:03:46 2017        (r317743)
+++ head/usr.sbin/makefs/ffs.c  Wed May  3 14:21:18 2017        (r317744)
@@ -144,7 +144,6 @@ static  void        *ffs_build_dinode2(struct u
 
 
 
-int    sectorsize;             /* XXX: for buf.c::getblk() */
        /* publicly visible functions */
 
 void
@@ -427,8 +426,6 @@ ffs_validate(const char *dir, fsnode *ro
                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.",

Modified: head/usr.sbin/makefs/ffs/buf.c
==============================================================================
--- head/usr.sbin/makefs/ffs/buf.c      Wed May  3 14:03:46 2017        
(r317743)
+++ head/usr.sbin/makefs/ffs/buf.c      Wed May  3 14:21:18 2017        
(r317744)
@@ -50,14 +50,7 @@ __FBSDID("$FreeBSD$");
 #include <util.h>
 
 #include "makefs.h"
-
-#include <ufs/ufs/dinode.h>
-#include <ufs/ffs/fs.h>
-
-#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, i
 {
        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, 
        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, 
                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);
        }

Modified: head/usr.sbin/makefs/ffs/buf.h
==============================================================================
--- head/usr.sbin/makefs/ffs/buf.h      Wed May  3 14:03:46 2017        
(r317743)
+++ head/usr.sbin/makefs/ffs/buf.h      Wed May  3 14:21:18 2017        
(r317744)
@@ -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;
 };
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to