Source-Changes-HG archive

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

[src/netbsd-1-5]: src/usr.bin/fstat Pullup rev. 1.43 and 1.44. This makes fs...



details:   https://anonhg.NetBSD.org/src/rev/b62f10f0d64f
branches:  netbsd-1-5
changeset: 489631:b62f10f0d64f
user:      enami <enami%NetBSD.org@localhost>
date:      Mon Oct 02 03:11:37 2000 +0000

description:
Pullup rev. 1.43 and 1.44.  This makes fstat works with layered filesystem
and fixes PR#11113.  Approved by thorpej.

diffstat:

 usr.bin/fstat/fstat.c |  143 +++++++++++++++++++++++++++++++++----------------
 1 files changed, 97 insertions(+), 46 deletions(-)

diffs (203 lines):

diff -r dda89e8a5ab6 -r b62f10f0d64f usr.bin/fstat/fstat.c
--- a/usr.bin/fstat/fstat.c     Mon Oct 02 03:10:31 2000 +0000
+++ b/usr.bin/fstat/fstat.c     Mon Oct 02 03:11:37 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fstat.c,v 1.42 2000/05/27 15:02:04 sommerfeld Exp $    */
+/*     $NetBSD: fstat.c,v 1.42.4.1 2000/10/02 03:11:37 enami 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.42 2000/05/27 15:02:04 sommerfeld Exp $");
+__RCSID("$NetBSD: fstat.c,v 1.42.4.1 2000/10/02 03:11:37 enami Exp $");
 #endif
 #endif /* not lint */
 
@@ -81,6 +81,9 @@
 #define        _KERNEL
 #include <msdosfs/msdosfsmount.h>
 #undef _KERNEL
+#define        _KERNEL
+#include <miscfs/genfs/layer.h>
+#undef _KERNEL
 
 #include <net/route.h>
 #include <netinet/in.h>
@@ -152,6 +155,7 @@
 int    getfname __P((char *));
 void   getinetproto __P((int));
 char   *getmnton __P((struct mount *));
+char   *layer_filestat __P((struct vnode *, struct filestat *));
 int    main __P((int, char **));
 int    msdosfs_filestat __P((struct vnode *, struct filestat *));
 int    nfs_filestat __P((struct vnode *, struct filestat *));
@@ -161,6 +165,7 @@
 void   socktrans __P((struct socket *, int));
 int    ufs_filestat __P((struct vnode *, struct filestat *));
 void   usage __P((void));
+char   *vfilestat __P((struct vnode *, struct filestat *));
 void   vtrans __P((struct vnode *, int, int));
 void   ftrans __P((struct file *, int));
 
@@ -394,6 +399,62 @@
        }
 }
 
+char *
+vfilestat(vp, fsp)
+       struct vnode *vp;
+       struct filestat *fsp;
+{
+       char *badtype = NULL;
+
+       if (vp->v_type == VNON || vp->v_tag == VT_NON)
+               badtype = "none";
+       else if (vp->v_type == VBAD)
+               badtype = "bad";
+       else
+               switch (vp->v_tag) {
+               case VT_UFS:
+                       if (!ufs_filestat(vp, fsp))
+                               badtype = "error";
+                       break;
+               case VT_MFS:
+                       if (!ufs_filestat(vp, fsp))
+                               badtype = "error";
+                       break;
+               case VT_MSDOSFS:
+                       if (!msdosfs_filestat(vp, fsp))
+                               badtype = "error";
+                       break;
+               case VT_NFS:
+                       if (!nfs_filestat(vp, fsp))
+                               badtype = "error";
+                       break;
+               case VT_EXT2FS:
+                       if (!ext2fs_filestat(vp, fsp))
+                               badtype = "error";
+                       break;
+               case VT_ISOFS:
+                       if (!isofs_filestat(vp, fsp))
+                               badtype = "error";
+                       break;
+               case VT_NTFS:
+                       if (!ntfs_filestat(vp, fsp))
+                               badtype = "error";
+                       break;
+               case VT_NULL:
+               case VT_OVERLAY:
+               case VT_UMAP:
+                       badtype = layer_filestat(vp, fsp);
+                       break;
+               default: {
+                       static char unknown[10];
+                       (void)snprintf(badtype = unknown, sizeof unknown,
+                           "?(%x)", vp->v_tag);
+                       break;
+               }
+       }
+       return (badtype);
+}
+
 void
 vtrans(vp, i, flag)
        struct vnode *vp;
@@ -403,54 +464,14 @@
        struct vnode vn;
        struct filestat fst;
        char mode[15], rw[3];
-       char *badtype = NULL, *filename;
+       char *badtype, *filename;
 
-       filename = badtype = NULL;
-       if (!KVM_READ(vp, &vn, sizeof (struct vnode))) {
+       filename = NULL;
+       if (!KVM_READ(vp, &vn, sizeof(struct vnode))) {
                dprintf("can't read vnode at %p for pid %d", vp, Pid);
                return;
        }
-       if (vn.v_type == VNON || vn.v_tag == VT_NON)
-               badtype = "none";
-       else if (vn.v_type == VBAD)
-               badtype = "bad";
-       else
-               switch (vn.v_tag) {
-               case VT_UFS:
-                       if (!ufs_filestat(&vn, &fst))
-                               badtype = "error";
-                       break;
-               case VT_MFS:
-                       if (!ufs_filestat(&vn, &fst))
-                               badtype = "error";
-                       break;
-               case VT_MSDOSFS:
-                       if (!msdosfs_filestat(&vn, &fst))
-                               badtype = "error";
-                       break;
-               case VT_NFS:
-                       if (!nfs_filestat(&vn, &fst))
-                               badtype = "error";
-                       break;
-               case VT_EXT2FS:
-                       if (!ext2fs_filestat(&vn, &fst))
-                               badtype = "error";
-                       break;
-               case VT_ISOFS:
-                       if (!isofs_filestat(&vn, &fst))
-                               badtype = "error";
-                       break;
-               case VT_NTFS:
-                       if (!ntfs_filestat(&vn, &fst))
-                               badtype = "error";
-                       break;
-               default: {
-                       static char unknown[10];
-                       (void)snprintf(badtype = unknown, sizeof unknown,
-                           "?(%x)", vn.v_tag);
-                       break;;
-               }
-       }
+       badtype = vfilestat(&vn, &fst);
        if (checkfile) {
                int fsmatch = 0;
                DEVS *d;
@@ -602,6 +623,36 @@
 }
 
 char *
+layer_filestat(vp, fsp)
+       struct vnode *vp;
+       struct filestat *fsp;
+{
+       struct layer_node layer_node;
+       struct mount mount;
+       struct vnode vn;
+       char *badtype;
+
+       if (!KVM_READ(VTOLAYER(vp), &layer_node, sizeof(layer_node))) {
+               dprintf("can't read layer_node at %p for pid %d",
+                   VTOLAYER(vp), Pid);
+               return ("error");
+       }
+       if (!KVM_READ(vp->v_mount, &mount, sizeof(struct mount))) {
+               dprintf("can't read mount struct at %p for pid %d",
+                   vp->v_mount, Pid);
+               return ("error");
+       }
+       vp = layer_node.layer_lowervp;
+       if (!KVM_READ(vp, &vn, sizeof(struct vnode))) {
+               dprintf("can't read vnode at %p for pid %d", vp, Pid);
+               return ("error");
+       }
+       if ((badtype = vfilestat(&vn, fsp)) == NULL)
+               fsp->fsid = mount.mnt_stat.f_fsid.val[0];
+       return (badtype);
+}
+
+char *
 getmnton(m)
        struct mount *m;
 {



Home | Main Index | Thread Index | Old Index