Source-Changes-HG archive

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

[src/trunk]: src/sys using chtype on media instead of vtype



details:   https://anonhg.NetBSD.org/src/rev/ac9a592a3e4e
branches:  trunk
changeset: 778749:ac9a592a3e4e
user:      ttoth <ttoth%NetBSD.org@localhost>
date:      Thu Apr 12 15:31:01 2012 +0000

description:
using chtype on media instead of vtype
debug.c deleted

diffstat:

 sys/modules/chfs/Makefile  |   4 +-
 sys/ufs/chfs/chfs.h        |  13 +++++------
 sys/ufs/chfs/chfs_build.c  |   6 ++--
 sys/ufs/chfs/chfs_inode.h  |  27 ++++++++++++++++++++++++-
 sys/ufs/chfs/chfs_subr.c   |  34 ++++++++++++++++----------------
 sys/ufs/chfs/chfs_vfsops.c |  28 ++++++++++++++------------
 sys/ufs/chfs/chfs_vnode.c  |  21 +++++++++++++++----
 sys/ufs/chfs/chfs_vnops.c  |  18 +++++++++-------
 sys/ufs/chfs/chfs_write.c  |   8 +++---
 sys/ufs/chfs/debug.c       |  48 ----------------------------------------------
 sys/ufs/chfs/debug.h       |  15 +-------------
 11 files changed, 100 insertions(+), 122 deletions(-)

diffs (truncated from 581 to 300 lines):

diff -r 405f495cc03a -r ac9a592a3e4e sys/modules/chfs/Makefile
--- a/sys/modules/chfs/Makefile Thu Apr 12 12:52:58 2012 +0000
+++ b/sys/modules/chfs/Makefile Thu Apr 12 15:31:01 2012 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.2 2012/02/04 18:35:56 christos Exp $
+#      $NetBSD: Makefile,v 1.3 2012/04/12 15:31:01 ttoth Exp $
 
 .include "../Makefile.inc"
 
@@ -7,7 +7,7 @@
 CPPFLAGS+=     -DDIAGNOSTIC -DDEBUG -DLOCKDEBUG
 
 KMOD=  chfs
-SRCS=  ebh.c debug.c chfs_wbuf.c chfs_vnode_cache.c chfs_ihash.c
+SRCS=  ebh.c chfs_wbuf.c chfs_vnode_cache.c chfs_ihash.c
 SRCS+=  chfs_gc.c
 SRCS+=  chfs_vnode.c chfs_erase.c chfs_write.c chfs_readinode.c
 SRCS+=  chfs_build.c chfs_scan.c chfs_nodeops.c chfs_malloc.c
diff -r 405f495cc03a -r ac9a592a3e4e sys/ufs/chfs/chfs.h
--- a/sys/ufs/chfs/chfs.h       Thu Apr 12 12:52:58 2012 +0000
+++ b/sys/ufs/chfs/chfs.h       Thu Apr 12 15:31:01 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: chfs.h,v 1.4 2011/11/28 12:50:07 ahoka Exp $   */
+/*     $NetBSD: chfs.h,v 1.5 2012/04/12 15:31:01 ttoth Exp $   */
 
 /*-
  * Copyright (c) 2010 Department of Software Engineering,
@@ -79,8 +79,6 @@
 #define MOUNT_CHFS "chfs"
 #endif
 
-#define CHFS_ROOTINO ROOTINO    /* ROOTINO == 2 */
-
 enum {
        VNO_STATE_UNCHECKED,    /* CRC checks not yet done */
        VNO_STATE_CHECKING,     /* CRC checks in progress */
@@ -91,6 +89,7 @@
        VNO_STATE_CLEARING      /* In clear_inode() */
 };
 
+
 #define VNODECACHE_SIZE 128
 
 #define MAX_READ_FREE(chmp) (((chmp)->chm_ebh)->eb_size / 8)
@@ -185,7 +184,7 @@
        uint64_t version;
        ino_t vno;
        uint32_t nhash;
-       enum vtype type;
+       enum chtype type;
        uint8_t  nsize;
        uint8_t  name[0];
 
@@ -631,7 +630,7 @@
 int chfs_readdirent(struct mount *, struct chfs_node_ref *,
     struct chfs_inode *);
 int chfs_makeinode(int, struct vnode *, struct vnode **,
-    struct componentname *, int );
+    struct componentname *, enum vtype );
 void chfs_set_vnode_size(struct vnode *, size_t);
 void chfs_change_size_free(struct chfs_mount *,
        struct chfs_eraseblock *, int);
@@ -665,7 +664,7 @@
 int chfs_write_flash_dnode(struct chfs_mount *, struct vnode *,
     struct buf *, struct chfs_full_dnode *);
 int chfs_do_link(struct chfs_inode *,
-    struct chfs_inode *, const char *, int, enum vtype);
+    struct chfs_inode *, const char *, int, enum chtype);
 int chfs_do_unlink(struct chfs_inode *,
     struct chfs_inode *, const char *, int);
 
@@ -673,7 +672,7 @@
 size_t chfs_mem_info(bool);
 struct chfs_dirent * chfs_dir_lookup(struct chfs_inode *,
     struct componentname *);
-int chfs_filldir (struct uio *, ino_t, const char *, int, enum vtype);
+int chfs_filldir (struct uio *, ino_t, const char *, int, enum chtype);
 int chfs_chsize(struct vnode *, u_quad_t, kauth_cred_t);
 int chfs_chflags(struct vnode *, int, kauth_cred_t);
 void chfs_itimes(struct chfs_inode *, const struct timespec *,
diff -r 405f495cc03a -r ac9a592a3e4e sys/ufs/chfs/chfs_build.c
--- a/sys/ufs/chfs/chfs_build.c Thu Apr 12 12:52:58 2012 +0000
+++ b/sys/ufs/chfs/chfs_build.c Thu Apr 12 15:31:01 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: chfs_build.c,v 1.2 2011/11/24 21:22:39 agc Exp $       */
+/*     $NetBSD: chfs_build.c,v 1.3 2012/04/12 15:31:01 ttoth Exp $     */
 
 /*-
  * Copyright (c) 2010 Department of Software Engineering,
@@ -84,7 +84,7 @@
                        chfs_mark_node_obsolete(chmp, fd->nref);
                        continue;
                }
-               if (fd->type == VDIR) {
+               if (fd->type == CHT_DIR) {
                        if (child_vc->nlink < 1)
                                child_vc->nlink = 1;
 
@@ -372,7 +372,7 @@
                                        nref = &fd->nref;
                                        *nref = fd->nref->nref_next;
                                        //fd->nref->nref_next = NULL;
-                               } else if (fd->type == VDIR) {
+                               } else if (fd->type == CHT_DIR) {
                                        //set state every non-VREG file's vc
                                        mutex_enter(&chmp->chm_lock_vnocache);
                                        notregvc =
diff -r 405f495cc03a -r ac9a592a3e4e sys/ufs/chfs/chfs_inode.h
--- a/sys/ufs/chfs/chfs_inode.h Thu Apr 12 12:52:58 2012 +0000
+++ b/sys/ufs/chfs/chfs_inode.h Thu Apr 12 15:31:01 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: chfs_inode.h,v 1.2 2012/02/28 02:48:39 christos Exp $  */
+/*     $NetBSD: chfs_inode.h,v 1.3 2012/04/12 15:31:01 ttoth Exp $     */
 
 /*-
  * Copyright (c) 2010 Department of Software Engineering,
@@ -40,6 +40,30 @@
 #include <ufs/ufs/ufsmount.h>
 #include <miscfs/genfs/genfs_node.h>
 
+#define CHFS_ROOTINO 2
+
+/* chfs file types */
+enum chtype {
+       CHT_BLANK,      /* empty type */
+       CHT_REG,        /* regular file */
+       CHT_DIR,        /* directory */
+       CHT_BLK,        /* block device */
+       CHT_CHR,        /* character device */
+       CHT_LNK,        /* link */
+       CHT_SOCK,       /* socket */
+       CHT_FIFO,       /* fifo */
+       CHT_BAD         /* bad type */
+};
+
+/* these macros are needed because the compatibility */
+#define CHTTOVT(ch_type)       ch_type
+#define VTTOCHT(v_type)                v_type
+
+extern const enum chtype iftocht_tab[16];
+
+#define        IFTOCHT(mode)   (iftocht_tab[((mode) & S_IFMT) >> 12])
+
+
 struct chfs_inode
 {
        struct genfs_node       gnode;
@@ -68,6 +92,7 @@
        //uint64_t highest_version;     /* highest vers. num. (used at data nodes) */
        
        uint32_t mode;          /* mode */
+       enum chtype ch_type;            /* chfs file type */
        //int16_t nlink;                /* link count */
        uint64_t size;          /* file byte count */
        uint64_t write_size;    /* increasing while write the file out to the flash */
diff -r 405f495cc03a -r ac9a592a3e4e sys/ufs/chfs/chfs_subr.c
--- a/sys/ufs/chfs/chfs_subr.c  Thu Apr 12 12:52:58 2012 +0000
+++ b/sys/ufs/chfs/chfs_subr.c  Thu Apr 12 15:31:01 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: chfs_subr.c,v 1.3 2012/03/13 18:41:03 elad Exp $       */
+/*     $NetBSD: chfs_subr.c,v 1.4 2012/04/12 15:31:01 ttoth Exp $      */
 
 /*-
  * Copyright (c) 2010 Department of Software Engineering,
@@ -150,7 +150,7 @@
 
 int
 chfs_filldir(struct uio* uio, ino_t ino, const char *name,
-    int namelen, enum vtype type)
+    int namelen, enum chtype type)
 {
        struct dirent dent;
        int error;
@@ -159,31 +159,31 @@
 
        dent.d_fileno = ino;
        switch (type) {
-       case VBLK:
+       case CHT_BLK:
                dent.d_type = DT_BLK;
                break;
 
-       case VCHR:
+       case CHT_CHR:
                dent.d_type = DT_CHR;
                break;
 
-       case VDIR:
+       case CHT_DIR:
                dent.d_type = DT_DIR;
                break;
 
-       case VFIFO:
+       case CHT_FIFO:
                dent.d_type = DT_FIFO;
                break;
 
-       case VLNK:
+       case CHT_LNK:
                dent.d_type = DT_LNK;
                break;
 
-       case VREG:
+       case CHT_REG:
                dent.d_type = DT_REG;
                break;
 
-       case VSOCK:
+       case CHT_SOCK:
                dent.d_type = DT_SOCK;
                break;
 
@@ -227,17 +227,17 @@
 
        dbg("chfs_chsize\n");
 
-       switch (vp->v_type) {
-       case VDIR:
+       switch (ip->ch_type) {
+       case CHT_DIR:
                return EISDIR;
-       case VLNK:
-       case VREG:
+       case CHT_LNK:
+       case CHT_REG:
                if (vp->v_mount->mnt_flag & MNT_RDONLY)
                        return EROFS;
                break;
-       case VBLK:
-       case VCHR:
-       case VFIFO:
+       case CHT_BLK:
+       case CHT_CHR:
+       case CHT_FIFO:
                return 0;
        default:
                return EOPNOTSUPP; /* XXX why not ENODEV? */
@@ -422,7 +422,7 @@
        }
 
        error = kauth_authorize_vnode(cred, action, vp, NULL,
-           genfs_can_chflags(cred, vp->v_type, ip->uid, changing_sysflags));
+           genfs_can_chflags(cred, CHTTOVT(ip->ch_type), ip->uid, changing_sysflags));
        if (error)
                return error;
 
diff -r 405f495cc03a -r ac9a592a3e4e sys/ufs/chfs/chfs_vfsops.c
--- a/sys/ufs/chfs/chfs_vfsops.c        Thu Apr 12 12:52:58 2012 +0000
+++ b/sys/ufs/chfs/chfs_vfsops.c        Thu Apr 12 15:31:01 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: chfs_vfsops.c,v 1.2 2011/11/24 21:09:37 agc Exp $      */
+/*     $NetBSD: chfs_vfsops.c,v 1.3 2012/04/12 15:31:01 ttoth Exp $    */
 
 /*-
  * Copyright (c) 2010 Department of Software Engineering,
@@ -511,6 +511,7 @@
        memset(ip, 0, sizeof(*ip));
        vp->v_data = ip;
        ip->vp = vp;
+       ip->ch_type = VTTOCHT(vp->v_type);
        ip->ump = ump;
        ip->chmp = chmp = ump->um_chfs;
        ip->dev = dev;
@@ -529,6 +530,7 @@
                dbg("SETROOT\n");
                vp->v_vflag |= VV_ROOT;
                vp->v_type = VDIR;
+               ip->ch_type = CHT_DIR;
                ip->mode = IFMT | IEXEC | IWRITE | IREAD;
                ip->iflag |= (IN_ACCESS | IN_CHANGE | IN_UPDATE);
                chfs_update(vp, NULL, NULL, UPDATE_WAIT);
@@ -570,8 +572,8 @@
 
                mutex_enter(&chmp->chm_lock_mountfields);
                // init type specific things
-               switch (vp->v_type) {
-               case VDIR:
+               switch (ip->ch_type) {
+               case CHT_DIR:
                        nref = chvc->dirents;
                        while (nref &&
                            (struct chfs_vnode_cache *)nref != chvc) {
@@ -580,8 +582,8 @@
                        }
                        chfs_set_vnode_size(vp, 512);
                        break;
-               case VREG:
-               case VSOCK:
+               case CHT_REG:
+               case CHT_SOCK:
                        //build the fragtree of the vnode
                        dbg("read_inode_internal | ino: %llu\n",
                                (unsigned long long)ip->ino);
@@ -593,7 +595,7 @@
                                return (error);
                        }
                        break;
-               case VLNK:
+               case CHT_LNK:
                        //build the fragtree of the vnode



Home | Main Index | Thread Index | Old Index