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.
This commit is contained in:
pooka 2010-04-30 10:03:13 +00:00
parent ffb5896ed4
commit 6e3fa8db54
3 changed files with 28 additions and 18 deletions

View File

@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: vfs_subr.c,v 1.399 2010/04/25 15:56:00 ad Exp $");
#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 @@ vlockstatus(struct vnlock *vl)
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.

View File

@ -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 @@ rump_vop_open(void *v)
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 @@ rump_vop_readdir(void *v)
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) {

View File

@ -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 dorevoke(struct vnode *, kauth_cred_t);
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 *);