Source-Changes-HG archive

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

[src/trunk]: src/sys Add translation from vtype to dirent type. Convert rump...



details:   https://anonhg.NetBSD.org/src/rev/cf15ee56d3ea
branches:  trunk
changeset: 754436:cf15ee56d3ea
user:      pooka <pooka%NetBSD.org@localhost>
date:      Fri Apr 30 10:03:13 2010 +0000

description:
Add translation from vtype to dirent type.  Convert rumpfs now.
I'll convert the rest of the file servers in need after the next
version bump to avoid the coding module crisis.

diffstat:

 sys/kern/vfs_subr.c               |  25 +++++++++++++++++++++++--
 sys/rump/librump/rumpvfs/rumpfs.c |  18 +++---------------
 sys/sys/vnode.h                   |   3 ++-
 3 files changed, 28 insertions(+), 18 deletions(-)

diffs (116 lines):

diff -r b751d59863b2 -r cf15ee56d3ea sys/kern/vfs_subr.c
--- a/sys/kern/vfs_subr.c       Fri Apr 30 10:02:00 2010 +0000
+++ b/sys/kern/vfs_subr.c       Fri Apr 30 10:03:13 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_subr.c,v 1.399 2010/04/25 15:56:00 ad Exp $        */
+/*     $NetBSD: vfs_subr.c,v 1.400 2010/04/30 10:03:13 pooka Exp $     */
 
 /*-
  * Copyright (c) 1997, 1998, 2004, 2005, 2007, 2008 The NetBSD Foundation, Inc.
@@ -91,7 +91,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.399 2010/04/25 15:56:00 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.400 2010/04/30 10:03:13 pooka Exp $");
 
 #include "opt_ddb.h"
 #include "opt_compat_netbsd.h"
@@ -100,6 +100,7 @@
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/conf.h>
+#include <sys/dirent.h>
 #include <sys/proc.h>
 #include <sys/kernel.h>
 #include <sys/mount.h>
@@ -2973,6 +2974,26 @@
        return 0;
 }
 
+static const uint8_t vttodt_tab[9] = {
+       DT_UNKNOWN,     /* VNON  */
+       DT_REG,         /* VREG  */
+       DT_DIR,         /* VDIR  */
+       DT_BLK,         /* VBLK  */
+       DT_CHR,         /* VCHR  */
+       DT_LNK,         /* VLNK  */
+       DT_SOCK,        /* VSUCK */
+       DT_FIFO,        /* VFIFO */
+       DT_UNKNOWN      /* VBAD  */
+};
+
+uint8_t
+vtype2dt(enum vtype vt)
+{
+
+       CTASSERT(VBAD == __arraycount(vttodt_tab) - 1);
+       return vttodt_tab[vt];
+}
+
 /*
  * mount_specific_key_create --
  *     Create a key for subsystem mount-specific data.
diff -r b751d59863b2 -r cf15ee56d3ea sys/rump/librump/rumpvfs/rumpfs.c
--- a/sys/rump/librump/rumpvfs/rumpfs.c Fri Apr 30 10:02:00 2010 +0000
+++ b/sys/rump/librump/rumpvfs/rumpfs.c Fri Apr 30 10:03:13 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rumpfs.c,v 1.45 2010/04/30 09:44:38 pooka Exp $        */
+/*     $NetBSD: rumpfs.c,v 1.46 2010/04/30 10:03:13 pooka Exp $        */
 
 /*
  * Copyright (c) 2009  Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.45 2010/04/30 09:44:38 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rumpfs.c,v 1.46 2010/04/30 10:03:13 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -765,18 +765,6 @@
        return error;
 }
 
-/* copypaste from libpuffs.  XXX: do this properly */
-static int vdmap[] = {
-        DT_UNKNOWN,     /* VNON */
-        DT_REG,         /* VREG */
-        DT_DIR,         /* VDIR */
-        DT_BLK,         /* VBLK */
-        DT_CHR,         /* VCHR */
-        DT_LNK,         /* VLNK */
-        DT_SOCK,        /* VSUCK*/
-        DT_FIFO,        /* VFIFO*/
-        DT_UNKNOWN      /* VBAD */
-};
 /* simple readdir.  event omits dotstuff and periods */
 static int
 rump_vop_readdir(void *v)
@@ -812,7 +800,7 @@
                dent.d_fileno = rdent->rd_node->rn_va.va_fileid;
                strlcpy(dent.d_name, rdent->rd_name, sizeof(dent.d_name));
                dent.d_namlen = strlen(dent.d_name);
-               dent.d_type = vdmap[rdent->rd_node->rn_va.va_type];
+               dent.d_type = vtype2dt(rdent->rd_node->rn_va.va_type);
                dent.d_reclen = _DIRENT_RECLEN(&dent, dent.d_namlen);
 
                if (uio->uio_resid < dent.d_reclen) {
diff -r b751d59863b2 -r cf15ee56d3ea sys/sys/vnode.h
--- a/sys/sys/vnode.h   Fri Apr 30 10:02:00 2010 +0000
+++ b/sys/sys/vnode.h   Fri Apr 30 10:03:13 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vnode.h,v 1.217 2010/04/23 05:10:19 dholland Exp $     */
+/*     $NetBSD: vnode.h,v 1.218 2010/04/30 10:03:14 pooka Exp $        */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -649,6 +649,7 @@
 int    vlockmgr(struct vnlock *, int);
 int    vlockstatus(struct vnlock *);
 int    rawdev_mounted(struct vnode *, struct vnode **);
+uint8_t        vtype2dt(enum vtype);
 
 /* see vfssubr(9) */
 void   vfs_getnewfsid(struct mount *);



Home | Main Index | Thread Index | Old Index