Module Name: src Committed By: pooka Date: Fri Apr 30 10:03:14 UTC 2010
Modified Files: src/sys/kern: vfs_subr.c src/sys/rump/librump/rumpvfs: rumpfs.c src/sys/sys: vnode.h Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.399 -r1.400 src/sys/kern/vfs_subr.c cvs rdiff -u -r1.45 -r1.46 src/sys/rump/librump/rumpvfs/rumpfs.c cvs rdiff -u -r1.217 -r1.218 src/sys/sys/vnode.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/vfs_subr.c diff -u src/sys/kern/vfs_subr.c:1.399 src/sys/kern/vfs_subr.c:1.400 --- src/sys/kern/vfs_subr.c:1.399 Sun Apr 25 15:56:00 2010 +++ src/sys/kern/vfs_subr.c Fri Apr 30 10:03:13 2010 @@ -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. Index: src/sys/rump/librump/rumpvfs/rumpfs.c diff -u src/sys/rump/librump/rumpvfs/rumpfs.c:1.45 src/sys/rump/librump/rumpvfs/rumpfs.c:1.46 --- src/sys/rump/librump/rumpvfs/rumpfs.c:1.45 Fri Apr 30 09:44:38 2010 +++ src/sys/rump/librump/rumpvfs/rumpfs.c Fri Apr 30 10:03:13 2010 @@ -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) { Index: src/sys/sys/vnode.h diff -u src/sys/sys/vnode.h:1.217 src/sys/sys/vnode.h:1.218 --- src/sys/sys/vnode.h:1.217 Fri Apr 23 05:10:19 2010 +++ src/sys/sys/vnode.h Fri Apr 30 10:03:14 2010 @@ -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 *);