Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/fstat move the mapping of vnode type to file type to...
details: https://anonhg.NetBSD.org/src/rev/2f81ef970674
branches: trunk
changeset: 481726:2f81ef970674
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Fri Feb 04 10:35:46 2000 +0000
description:
move the mapping of vnode type to file type to separate function getftype()
and use it where appropriate
diffstat:
usr.bin/fstat/fstat.c | 69 ++++++++++++++++++++++++++++----------------------
usr.bin/fstat/fstat.h | 3 +-
usr.bin/fstat/ntfs.c | 18 ++-----------
3 files changed, 44 insertions(+), 46 deletions(-)
diffs (166 lines):
diff -r 18fddefb9836 -r 2f81ef970674 usr.bin/fstat/fstat.c
--- a/usr.bin/fstat/fstat.c Fri Feb 04 10:35:21 2000 +0000
+++ b/usr.bin/fstat/fstat.c Fri Feb 04 10:35:46 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fstat.c,v 1.39 2000/02/04 09:43:45 jdolecek Exp $ */
+/* $NetBSD: fstat.c,v 1.40 2000/02/04 10:35:46 jdolecek Exp $ */
/*-
* Copyright (c) 1988, 1993
@@ -43,7 +43,7 @@
#if 0
static char sccsid[] = "@(#)fstat.c 8.3 (Berkeley) 5/2/95";
#else
-__RCSID("$NetBSD: fstat.c,v 1.39 2000/02/04 09:43:45 jdolecek Exp $");
+__RCSID("$NetBSD: fstat.c,v 1.40 2000/02/04 10:35:46 jdolecek Exp $");
#endif
#endif /* not lint */
@@ -533,7 +533,6 @@
{
struct nfsnode nfsnode;
struct vattr va;
- mode_t mode;
if (!KVM_READ(VTONFS(vp), &nfsnode, sizeof (nfsnode))) {
dprintf("can't read nfsnode at %p for pid %d", VTONFS(vp),
@@ -549,33 +548,7 @@
fsp->fileid = va.va_fileid;
fsp->size = nfsnode.n_size;
fsp->rdev = va.va_rdev;
- mode = (mode_t)va.va_mode;
- switch (vp->v_type) {
- case VREG:
- mode |= S_IFREG;
- break;
- case VDIR:
- mode |= S_IFDIR;
- break;
- case VBLK:
- mode |= S_IFBLK;
- break;
- case VCHR:
- mode |= S_IFCHR;
- break;
- case VLNK:
- mode |= S_IFLNK;
- break;
- case VSOCK:
- mode |= S_IFSOCK;
- break;
- case VFIFO:
- mode |= S_IFIFO;
- break;
- default:
- break;
- };
- fsp->mode = mode;
+ fsp->mode = (mode_t)va.va_mode | getftype(vp->v_type);
return 1;
}
@@ -903,6 +876,42 @@
return(1);
}
+mode_t
+getftype(v_type)
+ enum vtype v_type;
+{
+ mode_t ftype;
+
+ switch (v_type) {
+ case VREG:
+ ftype = S_IFREG;
+ break;
+ case VDIR:
+ ftype = S_IFDIR;
+ break;
+ case VBLK:
+ ftype = S_IFBLK;
+ break;
+ case VCHR:
+ ftype = S_IFCHR;
+ break;
+ case VLNK:
+ ftype = S_IFLNK;
+ break;
+ case VSOCK:
+ ftype = S_IFSOCK;
+ break;
+ case VFIFO:
+ ftype = S_IFIFO;
+ break;
+ default:
+ ftype = 0;
+ break;
+ };
+
+ return ftype;
+}
+
void
usage()
{
diff -r 18fddefb9836 -r 2f81ef970674 usr.bin/fstat/fstat.h
--- a/usr.bin/fstat/fstat.h Fri Feb 04 10:35:21 2000 +0000
+++ b/usr.bin/fstat/fstat.h Fri Feb 04 10:35:46 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fstat.h,v 1.2 1999/08/02 17:39:13 jdolecek Exp $ */
+/* $NetBSD: fstat.h,v 1.3 2000/02/04 10:35:46 jdolecek Exp $ */
/*-
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
@@ -52,5 +52,6 @@
#define dprintf if (vflg) warnx
+mode_t getftype __P((enum vtype));
int isofs_filestat __P((struct vnode *, struct filestat *));
int ntfs_filestat __P((struct vnode *, struct filestat *));
diff -r 18fddefb9836 -r 2f81ef970674 usr.bin/fstat/ntfs.c
--- a/usr.bin/fstat/ntfs.c Fri Feb 04 10:35:21 2000 +0000
+++ b/usr.bin/fstat/ntfs.c Fri Feb 04 10:35:46 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ntfs.c,v 1.4 2000/02/04 10:13:54 jdolecek Exp $ */
+/* $NetBSD: ntfs.c,v 1.5 2000/02/04 10:35:46 jdolecek Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: ntfs.c,v 1.4 2000/02/04 10:13:54 jdolecek Exp $");
+__RCSID("$NetBSD: ntfs.c,v 1.5 2000/02/04 10:35:46 jdolecek Exp $");
#include <sys/param.h>
#include <sys/time.h>
@@ -64,7 +64,6 @@
struct ntnode ntnode;
struct fnode fn;
struct ntfsmount ntm;
- mode_t mode;
/* to get the ntnode, we have to go in two steps - firstly
* to read appropriate struct fnode and then getting the address
@@ -85,18 +84,7 @@
fsp->fsid = ntnode.i_dev & 0xffff;
fsp->fileid = (long)ntnode.i_number;
- mode = (mode_t)ntm.ntm_mode;
- switch (vp->v_type) {
- case VREG:
- mode |= S_IFREG;
- break;
- case VDIR:
- mode |= S_IFDIR;
- break;
- default:
- break;
- }
- fsp->mode = mode;
+ fsp->mode = (mode_t)ntm.ntm_mode | getftype(vp->v_type);
fsp->size = fn.f_size;
fsp->rdev = 0; /* XXX */
return 1;
Home |
Main Index |
Thread Index |
Old Index