Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/fstat PR/32788: KAMADA Ken'ichi: add support for tmpfs



details:   https://anonhg.NetBSD.org/src/rev/9b70ea734d38
branches:  trunk
changeset: 588164:9b70ea734d38
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Feb 10 16:01:45 2006 +0000

description:
PR/32788: KAMADA Ken'ichi: add support for tmpfs

diffstat:

 usr.bin/fstat/Makefile |   4 +-
 usr.bin/fstat/fstat.c  |   8 +++-
 usr.bin/fstat/fstat.h  |   3 +-
 usr.bin/fstat/tmpfs.c  |  87 ++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 97 insertions(+), 5 deletions(-)

diffs (151 lines):

diff -r 6c6168ff14c6 -r 9b70ea734d38 usr.bin/fstat/Makefile
--- a/usr.bin/fstat/Makefile    Fri Feb 10 16:00:02 2006 +0000
+++ b/usr.bin/fstat/Makefile    Fri Feb 10 16:01:45 2006 +0000
@@ -1,11 +1,11 @@
-#      $NetBSD: Makefile,v 1.18 2005/07/17 07:36:26 christos Exp $
+#      $NetBSD: Makefile,v 1.19 2006/02/10 16:01:45 christos Exp $
 #      from: @(#)Makefile      8.1 (Berkeley) 6/6/93
 
 .include <bsd.own.mk>
 
 WARNS= 3
 PROG=  fstat
-SRCS=  fstat.c isofs.c ntfs.c ptyfs.c
+SRCS=  fstat.c isofs.c ntfs.c ptyfs.c tmpfs.c
 DPADD= ${LIBKVM}
 LDADD= -lkvm
 BINGRP=        kmem
diff -r 6c6168ff14c6 -r 9b70ea734d38 usr.bin/fstat/fstat.c
--- a/usr.bin/fstat/fstat.c     Fri Feb 10 16:00:02 2006 +0000
+++ b/usr.bin/fstat/fstat.c     Fri Feb 10 16:01:45 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fstat.c,v 1.72 2005/07/17 07:36:26 christos Exp $      */
+/*     $NetBSD: fstat.c,v 1.73 2006/02/10 16:01:45 christos Exp $      */
 
 /*-
  * Copyright (c) 1988, 1993
@@ -39,7 +39,7 @@
 #if 0
 static char sccsid[] = "@(#)fstat.c    8.3 (Berkeley) 5/2/95";
 #else
-__RCSID("$NetBSD: fstat.c,v 1.72 2005/07/17 07:36:26 christos Exp $");
+__RCSID("$NetBSD: fstat.c,v 1.73 2006/02/10 16:01:45 christos Exp $");
 #endif
 #endif /* not lint */
 
@@ -440,6 +440,10 @@
                        if (!ptyfs_filestat(vp, fsp))
                                badtype = "error";
                        break;
+               case VT_TMPFS:
+                       if (!tmpfs_filestat(vp, fsp))
+                               badtype = "error";
+                       break;
                case VT_NULL:
                case VT_OVERLAY:
                case VT_UMAP:
diff -r 6c6168ff14c6 -r 9b70ea734d38 usr.bin/fstat/fstat.h
--- a/usr.bin/fstat/fstat.h     Fri Feb 10 16:00:02 2006 +0000
+++ b/usr.bin/fstat/fstat.h     Fri Feb 10 16:01:45 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fstat.h,v 1.6 2005/07/17 07:36:26 christos Exp $       */
+/*     $NetBSD: fstat.h,v 1.7 2006/02/10 16:01:45 christos Exp $       */
 /*-
  * Copyright (c) 1988, 1993
  *     The Regents of the University of California.  All rights reserved.
@@ -52,3 +52,4 @@
 int    isofs_filestat(struct vnode *, struct filestat *);
 int    ntfs_filestat(struct vnode *, struct filestat *);
 int    ptyfs_filestat(struct vnode *, struct filestat *);
+int    tmpfs_filestat(struct vnode *, struct filestat *);
diff -r 6c6168ff14c6 -r 9b70ea734d38 usr.bin/fstat/tmpfs.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.bin/fstat/tmpfs.c     Fri Feb 10 16:01:45 2006 +0000
@@ -0,0 +1,87 @@
+/*     $NetBSD: tmpfs.c,v 1.1 2006/02/10 16:01:45 christos Exp $       */
+
+/*-
+ * Copyright (c) 2006 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the NetBSD
+ *     Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: tmpfs.c,v 1.1 2006/02/10 16:01:45 christos Exp $");
+
+#define __POOL_EXPOSE
+#include <sys/types.h>
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/proc.h>
+#include <sys/user.h>
+#include <sys/stat.h>
+#include <sys/vnode.h>
+#include <sys/mount.h>
+
+#include <fs/tmpfs/tmpfs.h>
+
+#include <err.h>
+#include <kvm.h>
+#include "fstat.h"
+
+int
+tmpfs_filestat(struct vnode *vp, struct filestat *fsp)
+{
+       struct tmpfs_node tn;
+       struct mount mt;
+
+       if (!KVM_READ(VP_TO_TMPFS_NODE(vp), &tn, sizeof(tn))) {
+               dprintf("can't read tmpfs_node at %p for pid %d",
+                   VP_TO_TMPFS_NODE(vp), Pid);
+               return 0;
+       }
+       if (!KVM_READ(vp->v_mount, &mt, sizeof(mt))) {
+               dprintf("can't read mount at %p for pid %d",
+                   vp->v_mount, Pid);
+               return 0;
+       }
+
+       fsp->fsid = mt.mnt_stat.f_fsidx.__fsid_val[0];
+       fsp->fileid = (long)tn.tn_id;
+       fsp->mode = tn.tn_mode | getftype(vp->v_type);
+       fsp->size = tn.tn_size;
+       switch (tn.tn_type) {
+       case VBLK:
+       case VCHR:
+               fsp->rdev = tn.tn_rdev;
+               break;
+       default:
+               fsp->rdev = 0;
+               break;
+       }
+
+       return 1;
+}



Home | Main Index | Thread Index | Old Index