Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/makefs This works well enough to populate plain fil...



details:   https://anonhg.NetBSD.org/src/rev/bb3f0ebf8b03
branches:  trunk
changeset: 784399:bb3f0ebf8b03
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Jan 27 20:05:46 2013 +0000

description:
This works well enough to populate plain files in the root dir. creating
directories fails.

diffstat:

 usr.sbin/makefs/Makefile               |   4 +-
 usr.sbin/makefs/ffs.c                  |   5 +-
 usr.sbin/makefs/ffs/buf.c              |   6 +-
 usr.sbin/makefs/ffs/buf.h              |   3 +-
 usr.sbin/makefs/ffs/ffs_alloc.c        |  11 +--
 usr.sbin/makefs/ffs/ffs_balloc.c       |   8 +-
 usr.sbin/makefs/msdos.c                |   7 +-
 usr.sbin/makefs/msdos/msdosfs_vfsops.c |   8 ++-
 usr.sbin/makefs/msdos/msdosfs_vnops.c  |  93 +++++++++++++++++++--------------
 9 files changed, 81 insertions(+), 64 deletions(-)

diffs (truncated from 435 to 300 lines):

diff -r bcabda753a39 -r bb3f0ebf8b03 usr.sbin/makefs/Makefile
--- a/usr.sbin/makefs/Makefile  Sun Jan 27 19:58:04 2013 +0000
+++ b/usr.sbin/makefs/Makefile  Sun Jan 27 20:05:46 2013 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.34 2013/01/26 00:31:49 christos Exp $
+#      $NetBSD: Makefile,v 1.35 2013/01/27 20:05:46 christos Exp $
 #
 
 WARNS?=        5
@@ -18,7 +18,7 @@
 MTREESRC=      ${NETBSDSRCDIR}/usr.sbin/mtree
 
 CPPFLAGS+=     -I${.CURDIR} -I${MKNODSRC} -I${MTREESRC} -DMAKEFS
-CPPFLAGS+=     -DMSDOSFS_DEBUG
+#CPPFLAGS+=    -DMSDOSFS_DEBUG
 .PATH:         ${MKNODSRC} ${MTREESRC}
 
 .include "${.CURDIR}/cd9660/Makefile.inc"
diff -r bcabda753a39 -r bb3f0ebf8b03 usr.sbin/makefs/ffs.c
--- a/usr.sbin/makefs/ffs.c     Sun Jan 27 19:58:04 2013 +0000
+++ b/usr.sbin/makefs/ffs.c     Sun Jan 27 20:05:46 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ffs.c,v 1.54 2013/01/26 00:19:39 christos Exp $        */
+/*     $NetBSD: ffs.c,v 1.55 2013/01/27 20:05:46 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.54 2013/01/26 00:19:39 christos Exp $");
+__RCSID("$NetBSD: ffs.c,v 1.55 2013/01/27 20:05:46 christos Exp $");
 #endif /* !__lint */
 
 #include <sys/param.h>
@@ -945,7 +945,6 @@
                errno = bwrite(bp);
                if (errno != 0)
                        goto bad_ffs_write_file;
-               brelse(bp, 0);
                if (!isfile)
                        p += chunk;
        }
diff -r bcabda753a39 -r bb3f0ebf8b03 usr.sbin/makefs/ffs/buf.c
--- a/usr.sbin/makefs/ffs/buf.c Sun Jan 27 19:58:04 2013 +0000
+++ b/usr.sbin/makefs/ffs/buf.c Sun Jan 27 20:05:46 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: buf.c,v 1.14 2013/01/27 14:10:03 christos Exp $        */
+/*     $NetBSD: buf.c,v 1.15 2013/01/27 20:05:46 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.14 2013/01/27 14:10:03 christos Exp $");
+__RCSID("$NetBSD: buf.c,v 1.15 2013/01/27 20:05:46 christos Exp $");
 #endif /* !__lint */
 
 #include <sys/param.h>
@@ -148,6 +148,7 @@
        if (debug & DEBUG_BUF_BWRITE)
                printf("bwrite: write %ld (offset %lld) returned %lld\n",
                    bp->b_bcount, (long long)offset, (long long)rv);
+       brelse(bp, 0);
        if (rv == bp->b_bcount)
                return (0);
        else if (rv == -1)              /* write error */
@@ -189,7 +190,6 @@
        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);
diff -r bcabda753a39 -r bb3f0ebf8b03 usr.sbin/makefs/ffs/buf.h
--- a/usr.sbin/makefs/ffs/buf.h Sun Jan 27 19:58:04 2013 +0000
+++ b/usr.sbin/makefs/ffs/buf.h Sun Jan 27 20:05:46 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: buf.h,v 1.5 2013/01/27 14:10:22 christos Exp $ */
+/*     $NetBSD: buf.h,v 1.6 2013/01/27 20:05:46 christos Exp $ */
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -58,7 +58,6 @@
        int fd;
        void *fs;
        void *v_data;
-       int offset;
 };
 
 #define vput(a) ((void)(a))
diff -r bcabda753a39 -r bb3f0ebf8b03 usr.sbin/makefs/ffs/ffs_alloc.c
--- a/usr.sbin/makefs/ffs/ffs_alloc.c   Sun Jan 27 19:58:04 2013 +0000
+++ b/usr.sbin/makefs/ffs/ffs_alloc.c   Sun Jan 27 20:05:46 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ffs_alloc.c,v 1.21 2013/01/26 00:19:39 christos Exp $  */
+/*     $NetBSD: ffs_alloc.c,v 1.22 2013/01/27 20:05:46 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.21 2013/01/26 00:19:39 christos Exp $");
+__RCSID("$NetBSD: ffs_alloc.c,v 1.22 2013/01/27 20:05:46 christos Exp $");
 #endif /* !__lint */
 
 #include <sys/param.h>
@@ -304,14 +304,13 @@
        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 };
+       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);
        if (error) {
-               brelse(bp, 0);
                return (0);
        }
        cgp = (struct cg *)bp->b_data;
@@ -322,7 +321,7 @@
        }
        if (size == fs->fs_bsize) {
                bno = ffs_alloccgblk(ip, bp, bpref);
-               bdwrite(bp);
+               bwrite(bp);
                return (bno);
        }
        /*
@@ -440,7 +439,7 @@
        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 };
+       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) {
diff -r bcabda753a39 -r bb3f0ebf8b03 usr.sbin/makefs/ffs/ffs_balloc.c
--- a/usr.sbin/makefs/ffs/ffs_balloc.c  Sun Jan 27 19:58:04 2013 +0000
+++ b/usr.sbin/makefs/ffs/ffs_balloc.c  Sun Jan 27 20:05:46 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ffs_balloc.c,v 1.15 2013/01/26 00:19:39 christos Exp $ */
+/*     $NetBSD: ffs_balloc.c,v 1.16 2013/01/27 20:05:46 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.15 2013/01/26 00:19:39 christos Exp $");
+__RCSID("$NetBSD: ffs_balloc.c,v 1.16 2013/01/27 20:05:46 christos Exp $");
 #endif /* !__lint */
 
 #include <sys/param.h>
@@ -95,7 +95,7 @@
        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 };
+       struct vnode vp = { ip->i_fd, ip->i_fs, NULL };
 
        lbn = lblkno(fs, offset);
        size = blkoff(fs, offset) + bufsize;
@@ -346,7 +346,7 @@
        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 };
+       struct vnode vp = { ip->i_fd, ip->i_fs, NULL };
 
        lbn = lblkno(fs, offset);
        size = blkoff(fs, offset) + bufsize;
diff -r bcabda753a39 -r bb3f0ebf8b03 usr.sbin/makefs/msdos.c
--- a/usr.sbin/makefs/msdos.c   Sun Jan 27 19:58:04 2013 +0000
+++ b/usr.sbin/makefs/msdos.c   Sun Jan 27 20:05:46 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msdos.c,v 1.7 2013/01/27 15:35:45 christos Exp $       */
+/*     $NetBSD: msdos.c,v 1.8 2013/01/27 20:05:46 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.7 2013/01/27 15:35:45 christos Exp $");
+__RCSID("$NetBSD: msdos.c,v 1.8 2013/01/27 20:05:46 christos Exp $");
 #endif /* !__lint */
 
 #include <sys/param.h>
@@ -162,7 +162,6 @@
 
        vp.fd = open(image, O_RDWR);
        vp.fs = msdos_opt;
-       vp.offset = 0;
 
        if ((pmp = msdosfs_mount(&vp, 0)) == NULL)
                err(1, "msdosfs_mount");
@@ -237,7 +236,7 @@
                        continue;
                }
                if (msdosfs_mkfile(pbuf, dir, cur) == NULL)
-                       err(1, "msdosfs_mkfile");
+                       err(1, "msdosfs_mkfile %s", pbuf);
        }
        return 0;
 }
diff -r bcabda753a39 -r bb3f0ebf8b03 usr.sbin/makefs/msdos/msdosfs_vfsops.c
--- a/usr.sbin/makefs/msdos/msdosfs_vfsops.c    Sun Jan 27 19:58:04 2013 +0000
+++ b/usr.sbin/makefs/msdos/msdosfs_vfsops.c    Sun Jan 27 20:05:46 2013 +0000
@@ -50,7 +50,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.4 2013/01/27 15:35:45 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vfsops.c,v 1.5 2013/01/27 20:05:46 christos Exp $");
 
 #include <sys/param.h>
 
@@ -301,6 +301,12 @@
        pmp->pm_crbomask = pmp->pm_bpcluster - 1;
        pmp->pm_cnshift = ffs(pmp->pm_bpcluster) - 1;
 
+       DPRINTF(("%s(fatmask=%lu, fatmult=%u, fatdiv=%u, fatblocksize=%lu, "
+           "fatblocksec=%lu, bnshift=%lu, pbcluster=%lu, crbomask=%lu, "
+           "cnshift=%lu)\n",
+           __func__, pmp->pm_fatmask, pmp->pm_fatmult, pmp->pm_fatdiv,
+           pmp->pm_fatblocksize, pmp->pm_fatblocksec, pmp->pm_bnshift,
+           pmp->pm_bpcluster, pmp->pm_crbomask, pmp->pm_cnshift));
        /*
         * Check for valid cluster size
         * must be a power of 2
diff -r bcabda753a39 -r bb3f0ebf8b03 usr.sbin/makefs/msdos/msdosfs_vnops.c
--- a/usr.sbin/makefs/msdos/msdosfs_vnops.c     Sun Jan 27 19:58:04 2013 +0000
+++ b/usr.sbin/makefs/msdos/msdosfs_vnops.c     Sun Jan 27 20:05:46 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: msdosfs_vnops.c,v 1.8 2013/01/27 16:03:15 christos Exp $ */
+/*     $NetBSD: msdosfs_vnops.c,v 1.9 2013/01/27 20:05:46 christos Exp $ */
 
 /*-
  * Copyright (C) 1994, 1995, 1997 Wolfgang Solfrank.
@@ -51,7 +51,7 @@
 #endif
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.8 2013/01/27 16:03:15 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: msdosfs_vnops.c,v 1.9 2013/01/27 20:05:46 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/mman.h>
@@ -70,6 +70,11 @@
 #include "makefs.h"
 #include "msdos.h"
 
+#ifdef MSDOSFS_DEBUG
+#define DPRINTF(a) printf a
+#else
+#define DPRINTF(a)
+#endif
 /*
  * Some general notes:
  *
@@ -169,9 +174,7 @@
         * case it doesn't already exist.
         */
        slotcount = 0;
-#ifdef MSDOSFS_DEBUG
-       printf("%s(): dos filename: %s\n", __func__, dosfilename);
-#endif
+       DPRINTF(("%s(): dos filename: %s\n", __func__, dosfilename));
        /*
         * Search the directory pointed at by vdp for the name pointed at
         * by cnp->cn_nameptr.
@@ -264,10 +267,8 @@
                                        chksum = -1;
                                        continue;
                                }
-#ifdef MSDOSFS_DEBUG
-                               printf("%s(): match blkoff %d, diroff %d\n",
-                                   __func__, blkoff, diroff);
-#endif
+                               DPRINTF(("%s(): match blkoff %d, diroff %d\n",
+                                   __func__, blkoff, diroff));
                                /*
                                 * Remember where this directory
                                 * entry came from for whoever did
@@ -296,10 +297,8 @@
         * that's ok if we are creating or renaming and are at the end of
         * the pathname and the directory hasn't been removed.



Home | Main Index | Thread Index | Old Index