From 194d17d824e14cfe741d0e7f6d4fec58e87b6446 Mon Sep 17 00:00:00 2001 From: pooka Date: Tue, 21 Nov 2006 23:11:09 +0000 Subject: [PATCH] mode_t to enum vtype conversion --- lib/libpuffs/puffs.h | 3 ++- lib/libpuffs/subr.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/lib/libpuffs/puffs.h b/lib/libpuffs/puffs.h index ae7c648a7028..78162cfe792e 100644 --- a/lib/libpuffs/puffs.h +++ b/lib/libpuffs/puffs.h @@ -1,4 +1,4 @@ -/* $NetBSD: puffs.h,v 1.9 2006/11/18 12:40:35 pooka Exp $ */ +/* $NetBSD: puffs.h,v 1.10 2006/11/21 23:11:09 pooka Exp $ */ /* * Copyright (c) 2005, 2006 Antti Kantee. All Rights Reserved. @@ -207,6 +207,7 @@ int puffs_gendotdent(struct dirent **, ino_t, int, size_t *); int puffs_nextdent(struct dirent **, const char *, ino_t, uint8_t, size_t *); int puffs_vtype2dt(enum vtype); +enum vtype puffs_mode2vt(mode_t); /* diff --git a/lib/libpuffs/subr.c b/lib/libpuffs/subr.c index b841013dfc0a..d1e3d07b5e62 100644 --- a/lib/libpuffs/subr.c +++ b/lib/libpuffs/subr.c @@ -1,4 +1,4 @@ -/* $NetBSD: subr.c,v 1.8 2006/11/14 11:45:03 pooka Exp $ */ +/* $NetBSD: subr.c,v 1.9 2006/11/21 23:11:09 pooka Exp $ */ /* * Copyright (c) 2006 Antti Kantee. All Rights Reserved. @@ -30,7 +30,7 @@ #include #if !defined(lint) -__RCSID("$NetBSD: subr.c,v 1.8 2006/11/14 11:45:03 pooka Exp $"); +__RCSID("$NetBSD: subr.c,v 1.9 2006/11/21 23:11:09 pooka Exp $"); #endif /* !lint */ #include @@ -203,3 +203,27 @@ puffs_vtype2dt(enum vtype vt) return DT_UNKNOWN; } + +enum vtype +puffs_mode2vt(mode_t mode) +{ + + switch (mode & S_IFMT) { + case S_IFIFO: + return VFIFO; + case S_IFCHR: + return VCHR; + case S_IFDIR: + return VDIR; + case S_IFBLK: + return VBLK; + case S_IFREG: + return VREG; + case S_IFLNK: + return VLNK; + case S_IFSOCK: + return VSOCK; + default: + return VBAD; /* XXX: not really true, but ... */ + } +}