Source-Changes-HG archive

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

[src/trunk]: src/sys/miscfs/procfs procfs_readdir(): in Pfd case, only show d...



details:   https://anonhg.NetBSD.org/src/rev/9e429f1fdea4
branches:  trunk
changeset: 545921:9e429f1fdea4
user:      jdolecek <jdolecek%NetBSD.org@localhost>
date:      Thu Apr 17 20:33:17 2003 +0000

description:
procfs_readdir(): in Pfd case, only show descriptors of types we want
how to represent (vnodes, fifo, pipes); also use fd_getfile() et al

this avoids annoying EOPNOTSUPP error messages from ls -F and such

diffstat:

 sys/miscfs/procfs/procfs_vnops.c |  25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)

diffs (54 lines):

diff -r 0a3daa5425fb -r 9e429f1fdea4 sys/miscfs/procfs/procfs_vnops.c
--- a/sys/miscfs/procfs/procfs_vnops.c  Thu Apr 17 20:19:18 2003 +0000
+++ b/sys/miscfs/procfs/procfs_vnops.c  Thu Apr 17 20:33:17 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: procfs_vnops.c,v 1.99 2003/04/17 20:19:18 jdolecek Exp $       */
+/*     $NetBSD: procfs_vnops.c,v 1.100 2003/04/17 20:33:17 jdolecek Exp $      */
 
 /*
  * Copyright (c) 1993 Jan-Simon Pendry
@@ -44,7 +44,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.99 2003/04/17 20:19:18 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: procfs_vnops.c,v 1.100 2003/04/17 20:33:17 jdolecek Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1050,6 +1050,7 @@
        case Pfd: {
                struct proc *p;
                struct filedesc *fdp;
+               struct file *fp;
                int lim, last, nc = 0;
 
                p = PFIND(pfs->pfs_pid);
@@ -1089,8 +1090,26 @@
                        break;
                }
                for (; uio->uio_resid >= UIO_MX && i < fdp->fd_nfiles; i++) {
-                       if (fdp->fd_ofiles[i - 2] == NULL)
+                       if ((fp = fd_getfile(fdp, i - 2)) == NULL)
                                continue;
+                       FILE_USE(fp); 
+
+                       /*
+                        * Only show supported file descriptors - must
+                        * match procfs_allocvp() set.
+                        */
+                       switch(fp->f_type) {
+                       case DTYPE_VNODE:
+                       case DTYPE_PIPE:
+                       case DTYPE_SOCKET:
+                               FILE_UNUSE(fp, p);
+                               break;
+                       default:
+                               /* unsupported, skip */
+                               FILE_UNUSE(fp, p);
+                               continue;
+                       }
+                       
                        d.d_fileno = PROCFS_FILENO(pfs->pfs_pid, Pfd, i - 2);
                        d.d_namlen = snprintf(d.d_name, sizeof(d.d_name),
                            "%lld", (long long)(i - 2));



Home | Main Index | Thread Index | Old Index