BSD 4_4_Lite1 release
[unix-history] / usr / src / sys / miscfs / fdesc / fdesc_vnops.c
index 7169f93..00d8675 100644 (file)
@@ -1,14 +1,39 @@
 /*
 /*
- * Copyright (c) 1992 The Regents of the University of California
- * Copyright (c) 1990, 1992, 1993 Jan-Simon Pendry
- * All rights reserved.
+ * Copyright (c) 1992, 1993
+ *     The Regents of the University of California.  All rights reserved.
  *
  * This code is derived from software donated to Berkeley by
  * Jan-Simon Pendry.
  *
  *
  * This code is derived from software donated to Berkeley by
  * Jan-Simon Pendry.
  *
- * %sccs.include.redist.c%
+ * 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 University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
  *
  *
- *     @(#)fdesc_vnops.c       7.8 (Berkeley) %G%
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ *     @(#)fdesc_vnops.c       8.9 (Berkeley) 1/21/94
  *
  * $Id: fdesc_vnops.c,v 1.12 1993/04/06 16:17:17 jsp Exp $
  */
  *
  * $Id: fdesc_vnops.c,v 1.12 1993/04/06 16:17:17 jsp Exp $
  */
 #include <sys/dirent.h>
 #include <miscfs/fdesc/fdesc.h>
 
 #include <sys/dirent.h>
 #include <miscfs/fdesc/fdesc.h>
 
-#define cttyvp(p) ((p)->p_flag&SCTTY ? (p)->p_session->s_ttyvp : NULL)
+#define cttyvp(p) ((p)->p_flag & P_CONTROLT ? (p)->p_session->s_ttyvp : NULL)
 
 #define FDL_WANT       0x01
 #define FDL_LOCKED     0x02
 
 #define FDL_WANT       0x01
 #define FDL_LOCKED     0x02
-static int fdescvplock;
-static struct vnode *fdescvp[FD_MAX];
+static int fdcache_lock;
+
+dev_t devctty;
 
 #if (FD_STDIN != FD_STDOUT-1) || (FD_STDOUT != FD_STDERR-1)
 FD_STDIN, FD_STDOUT, FD_STDERR must be a sequence n, n+1, n+2
 #endif
 
 
 #if (FD_STDIN != FD_STDOUT-1) || (FD_STDOUT != FD_STDERR-1)
 FD_STDIN, FD_STDOUT, FD_STDERR must be a sequence n, n+1, n+2
 #endif
 
+#define        NFDCACHE 3
+#define        FD_NHASH(ix) ((ix) & NFDCACHE)
+
+/*
+ * Cache head
+ */
+struct fdcache {
+       struct fdescnode        *fc_forw;
+       struct fdescnode        *fc_back;
+};
+
+static struct fdcache fdcache[NFDCACHE];
+
+/*
+ * Initialise cache headers
+ */
+fdesc_init()
+{
+       struct fdcache *fc;
+
+       devctty = makedev(nchrdev, 0);
+
+       for (fc = fdcache; fc < fdcache + NFDCACHE; fc++)
+               fc->fc_forw = fc->fc_back = (struct fdescnode *) fc;
+}
+
+/*
+ * Compute hash list for given target vnode
+ */
+static struct fdcache *
+fdesc_hash(ix)
+       int ix;
+{
+
+       return (&fdcache[FD_NHASH(ix)]);
+}
+
+int
 fdesc_allocvp(ftype, ix, mp, vpp)
        fdntype ftype;
        int ix;
        struct mount *mp;
        struct vnode **vpp;
 {
 fdesc_allocvp(ftype, ix, mp, vpp)
        fdntype ftype;
        int ix;
        struct mount *mp;
        struct vnode **vpp;
 {
-       struct vnode **nvpp = 0;
+       struct fdcache *fc;
+       struct fdescnode *fd;
        int error = 0;
 
 loop:
        int error = 0;
 
 loop:
-       /* get stashed copy of the vnode */
-       if (ix >= 0 && ix < FD_MAX) {
-               nvpp = &fdescvp[ix];
-               if (*nvpp) {
-                       if (vget(*nvpp))
+       fc = fdesc_hash(ix);
+       for (fd = fc->fc_forw; fd != (struct fdescnode *) fc; fd = fd->fd_forw) {
+               if (fd->fd_ix == ix && fd->fd_vnode->v_mount == mp) {
+                       if (vget(fd->fd_vnode, 0))
                                goto loop;
                                goto loop;
-                       VOP_UNLOCK(*nvpp);
-                       *vpp = *nvpp;
+                       *vpp = fd->fd_vnode;
                        return (error);
                }
        }
                        return (error);
                }
        }
@@ -72,30 +135,32 @@ loop:
         * otherwise lock the array while we call getnewvnode
         * since that can block.
         */ 
         * otherwise lock the array while we call getnewvnode
         * since that can block.
         */ 
-       if (fdescvplock & FDL_LOCKED) {
-               fdescvplock |= FDL_WANT;
-               sleep((caddr_t) &fdescvplock, PINOD);
+       if (fdcache_lock & FDL_LOCKED) {
+               fdcache_lock |= FDL_WANT;
+               sleep((caddr_t) &fdcache_lock, PINOD);
                goto loop;
        }
                goto loop;
        }
-       fdescvplock |= FDL_LOCKED;
+       fdcache_lock |= FDL_LOCKED;
 
 
-       error = getnewvnode(VT_UFS, mp, fdesc_vnodeop_p, vpp);
+       error = getnewvnode(VT_FDESC, mp, fdesc_vnodeop_p, vpp);
        if (error)
                goto out;
        if (error)
                goto out;
-       MALLOC((*vpp)->v_data, void *, sizeof(struct fdescnode), M_TEMP, M_WAITOK);
-       if (nvpp)
-               *nvpp = *vpp;
-       VTOFDESC(*vpp)->fd_type = ftype;
-       VTOFDESC(*vpp)->fd_fd = -1;
-       VTOFDESC(*vpp)->fd_link = 0;
-       VTOFDESC(*vpp)->fd_ix = ix;
+       MALLOC(fd, void *, sizeof(struct fdescnode), M_TEMP, M_WAITOK);
+       (*vpp)->v_data = fd;
+       fd->fd_vnode = *vpp;
+       fd->fd_type = ftype;
+       fd->fd_fd = -1;
+       fd->fd_link = 0;
+       fd->fd_ix = ix;
+       fc = fdesc_hash(ix);
+       insque(fd, fc);
 
 out:;
 
 out:;
-       fdescvplock &= ~FDL_LOCKED;
+       fdcache_lock &= ~FDL_LOCKED;
 
 
-       if (fdescvplock & FDL_WANT) {
-               fdescvplock &= ~FDL_WANT;
-               wakeup((caddr_t) &fdescvplock);
+       if (fdcache_lock & FDL_WANT) {
+               fdcache_lock &= ~FDL_WANT;
+               wakeup((caddr_t) &fdcache_lock);
        }
 
        return (error);
        }
 
        return (error);
@@ -105,6 +170,7 @@ out:;
  * vp is the current namei directory
  * ndp is the name to locate in that directory...
  */
  * vp is the current namei directory
  * ndp is the name to locate in that directory...
  */
+int
 fdesc_lookup(ap)
        struct vop_lookup_args /* {
                struct vnode * a_dvp;
 fdesc_lookup(ap)
        struct vop_lookup_args /* {
                struct vnode * a_dvp;
@@ -122,14 +188,7 @@ fdesc_lookup(ap)
        struct vnode *fvp;
        char *ln;
 
        struct vnode *fvp;
        char *ln;
 
-#ifdef FDESC_DIAGNOSTIC
-       printf("fdesc_lookup(%x)\n", ap);
-       printf("fdesc_lookup(dp = %x, vpp = %x, cnp = %x)\n", dvp, vpp, ap->a_cnp);
-#endif
        pname = ap->a_cnp->cn_nameptr;
        pname = ap->a_cnp->cn_nameptr;
-#ifdef FDESC_DIAGNOSTIC
-       printf("fdesc_lookup(%s)\n", pname);
-#endif
        if (ap->a_cnp->cn_namelen == 1 && *pname == '.') {
                *vpp = dvp;
                VREF(dvp);      
        if (ap->a_cnp->cn_namelen == 1 && *pname == '.') {
                *vpp = dvp;
                VREF(dvp);      
@@ -156,9 +215,6 @@ fdesc_lookup(ap)
                        *vpp = fvp;
                        fvp->v_type = VDIR;
                        VOP_LOCK(fvp);
                        *vpp = fvp;
                        fvp->v_type = VDIR;
                        VOP_LOCK(fvp);
-#ifdef FDESC_DIAGNOSTIC
-                       printf("fdesc_lookup: newvp = %x\n", fvp);
-#endif
                        return (0);
                }
 
                        return (0);
                }
 
@@ -174,9 +230,6 @@ fdesc_lookup(ap)
                        *vpp = fvp;
                        fvp->v_type = VFIFO;
                        VOP_LOCK(fvp);
                        *vpp = fvp;
                        fvp->v_type = VFIFO;
                        VOP_LOCK(fvp);
-#ifdef FDESC_DIAGNOSTIC
-                       printf("fdesc_lookup: ttyvp = %x\n", fvp);
-#endif
                        return (0);
                }
 
                        return (0);
                }
 
@@ -201,9 +254,6 @@ fdesc_lookup(ap)
                }
 
                if (ln) {
                }
 
                if (ln) {
-#ifdef FDESC_DIAGNOSTIC
-                       printf("fdesc_lookup: link -> %s\n", ln);
-#endif
                        error = fdesc_allocvp(Flink, fd, dvp->v_mount, &fvp);
                        if (error)
                                goto bad;
                        error = fdesc_allocvp(Flink, fd, dvp->v_mount, &fvp);
                        if (error)
                                goto bad;
@@ -211,16 +261,13 @@ fdesc_lookup(ap)
                        *vpp = fvp;
                        fvp->v_type = VLNK;
                        VOP_LOCK(fvp);
                        *vpp = fvp;
                        fvp->v_type = VLNK;
                        VOP_LOCK(fvp);
-#ifdef FDESC_DIAGNOSTIC
-                       printf("fdesc_lookup: newvp = %x\n", fvp);
-#endif
                        return (0);
                } else {
                        error = ENOENT;
                        goto bad;
                }
 
                        return (0);
                } else {
                        error = ENOENT;
                        goto bad;
                }
 
-               /* fall through */
+               /* FALL THROUGH */
 
        case Fdevfd:
                if (ap->a_cnp->cn_namelen == 2 && bcmp(pname, "..", 2) == 0) {
 
        case Fdevfd:
                if (ap->a_cnp->cn_namelen == 2 && bcmp(pname, "..", 2) == 0) {
@@ -235,9 +282,6 @@ fdesc_lookup(ap)
                                break;
                }
 
                                break;
                }
 
-#ifdef FDESC_DIAGNOSTIC
-               printf("fdesc_lookup: fd = %d, *pname = %x\n", fd, *pname);
-#endif
                if (*pname != '\0') {
                        error = ENOENT;
                        goto bad;
                if (*pname != '\0') {
                        error = ENOENT;
                        goto bad;
@@ -248,28 +292,20 @@ fdesc_lookup(ap)
                        goto bad;
                }
 
                        goto bad;
                }
 
-#ifdef FDESC_DIAGNOSTIC
-               printf("fdesc_lookup: allocate new vnode\n");
-#endif
                error = fdesc_allocvp(Fdesc, FD_DESC+fd, dvp->v_mount, &fvp);
                if (error)
                        goto bad;
                VTOFDESC(fvp)->fd_fd = fd;
                *vpp = fvp;
                error = fdesc_allocvp(Fdesc, FD_DESC+fd, dvp->v_mount, &fvp);
                if (error)
                        goto bad;
                VTOFDESC(fvp)->fd_fd = fd;
                *vpp = fvp;
-#ifdef FDESC_DIAGNOSTIC
-               printf("fdesc_lookup: newvp = %x\n", fvp);
-#endif
                return (0);
        }
 
 bad:;
        *vpp = NULL;
                return (0);
        }
 
 bad:;
        *vpp = NULL;
-#ifdef FDESC_DIAGNOSTIC
-       printf("fdesc_lookup: error = %d\n", error);
-#endif
        return (error);
 }
 
        return (error);
 }
 
+int
 fdesc_open(ap)
        struct vop_open_args /* {
                struct vnode *a_vp;
 fdesc_open(ap)
        struct vop_open_args /* {
                struct vnode *a_vp;
@@ -315,15 +351,8 @@ fdesc_attr(fd, vap, cred, p)
        struct stat stb;
        int error;
 
        struct stat stb;
        int error;
 
-#ifdef FDESC_DIAGNOSTIC
-       printf("fdesc_attr: fd = %d, nfiles = %d\n", fd, fdp->fd_nfiles);
-#endif
-       if (fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL) {
-#ifdef FDESC_DIAGNOSTIC
-               printf("fdesc_attr: fp = %x (EBADF)\n", fp);
-#endif
+       if (fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL)
                return (EBADF);
                return (EBADF);
-       }
 
        switch (fp->f_type) {
        case DTYPE_VNODE:
 
        switch (fp->f_type) {
        case DTYPE_VNODE:
@@ -365,12 +394,10 @@ fdesc_attr(fd, vap, cred, p)
                break;
        }
 
                break;
        }
 
-#ifdef FDESC_DIAGNOSTIC
-       printf("fdesc_attr: returns error %d\n", error);
-#endif
        return (error);
 }
 
        return (error);
 }
 
+int
 fdesc_getattr(ap)
        struct vop_getattr_args /* {
                struct vnode *a_vp;
 fdesc_getattr(ap)
        struct vop_getattr_args /* {
                struct vnode *a_vp;
@@ -382,11 +409,7 @@ fdesc_getattr(ap)
        struct vnode *vp = ap->a_vp;
        struct vattr *vap = ap->a_vap;
        unsigned fd;
        struct vnode *vp = ap->a_vp;
        struct vattr *vap = ap->a_vap;
        unsigned fd;
-       int error;
-
-#ifdef FDESC_DIAGNOSTIC
-       printf("fdesc_getattr: stat type = %d\n", VTOFDESC(vp)->fd_type);
-#endif
+       int error = 0;
 
        switch (VTOFDESC(vp)->fd_type) {
        case Froot:
 
        switch (VTOFDESC(vp)->fd_type) {
        case Froot:
@@ -402,7 +425,6 @@ fdesc_getattr(ap)
                        vap->va_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
                        vap->va_type = VLNK;
                        vap->va_nlink = 1;
                        vap->va_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
                        vap->va_type = VLNK;
                        vap->va_nlink = 1;
-                       /* vap->va_qsize = strlen(VTOFDESC(vp)->fd_link); */
                        vap->va_size = strlen(VTOFDESC(vp)->fd_link);
                        break;
 
                        vap->va_size = strlen(VTOFDESC(vp)->fd_link);
                        break;
 
@@ -410,7 +432,6 @@ fdesc_getattr(ap)
                        vap->va_mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;
                        vap->va_type = VFIFO;
                        vap->va_nlink = 1;
                        vap->va_mode = S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH;
                        vap->va_type = VFIFO;
                        vap->va_nlink = 1;
-                       /* vap->va_qsize = 0; */
                        vap->va_size = 0;
                        break;
 
                        vap->va_size = 0;
                        break;
 
@@ -418,7 +439,6 @@ fdesc_getattr(ap)
                        vap->va_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
                        vap->va_type = VDIR;
                        vap->va_nlink = 2;
                        vap->va_mode = S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH;
                        vap->va_type = VDIR;
                        vap->va_nlink = 2;
-                       /* vap->va_qsize = 0; */
                        vap->va_size = DEV_BSIZE;
                        break;
                }
                        vap->va_size = DEV_BSIZE;
                        break;
                }
@@ -429,18 +449,14 @@ fdesc_getattr(ap)
                vap->va_atime.ts_sec = boottime.tv_sec;
                vap->va_atime.ts_nsec = 0;
                vap->va_mtime = vap->va_atime;
                vap->va_atime.ts_sec = boottime.tv_sec;
                vap->va_atime.ts_nsec = 0;
                vap->va_mtime = vap->va_atime;
-               vap->va_ctime = vap->va_ctime;
+               vap->va_ctime = vap->va_mtime;
                vap->va_gen = 0;
                vap->va_flags = 0;
                vap->va_rdev = 0;
                vap->va_gen = 0;
                vap->va_flags = 0;
                vap->va_rdev = 0;
-               /* vap->va_qbytes = 0; */
                vap->va_bytes = 0;
                break;
 
        case Fdesc:
                vap->va_bytes = 0;
                break;
 
        case Fdesc:
-#ifdef FDESC_DIAGNOSTIC
-               printf("fdesc_getattr: stat desc #%d\n", VTOFDESC(vp)->fd_fd);
-#endif
                fd = VTOFDESC(vp)->fd_fd;
                error = fdesc_attr(fd, vap, ap->a_cred, ap->a_p);
                break;
                fd = VTOFDESC(vp)->fd_fd;
                error = fdesc_attr(fd, vap, ap->a_cred, ap->a_p);
                break;
@@ -453,12 +469,10 @@ fdesc_getattr(ap)
        if (error == 0)
                vp->v_type = vap->va_type;
 
        if (error == 0)
                vp->v_type = vap->va_type;
 
-#ifdef FDESC_DIAGNOSTIC
-       printf("fdesc_getattr: stat returns 0\n");
-#endif
        return (error);
 }
 
        return (error);
 }
 
+int
 fdesc_setattr(ap)
        struct vop_setattr_args /* {
                struct vnode *a_vp;
 fdesc_setattr(ap)
        struct vop_setattr_args /* {
                struct vnode *a_vp;
@@ -487,13 +501,7 @@ fdesc_setattr(ap)
        }
 
        fd = VTOFDESC(ap->a_vp)->fd_fd;
        }
 
        fd = VTOFDESC(ap->a_vp)->fd_fd;
-#ifdef FDESC_DIAGNOSTIC
-       printf("fdesc_setattr: fd = %d, nfiles = %d\n", fd, fdp->fd_nfiles);
-#endif
        if (fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL) {
        if (fd >= fdp->fd_nfiles || (fp = fdp->fd_ofiles[fd]) == NULL) {
-#ifdef FDESC_DIAGNOSTIC
-               printf("fdesc_setattr: fp = %x (EBADF)\n", fp);
-#endif
                return (EBADF);
        }
 
                return (EBADF);
        }
 
@@ -514,9 +522,6 @@ fdesc_setattr(ap)
                break;
        }
 
                break;
        }
 
-#ifdef FDESC_DIAGNOSTIC
-       printf("fdesc_setattr: returns error %d\n", error);
-#endif
        return (error);
 }
 
        return (error);
 }
 
@@ -536,6 +541,7 @@ static struct dirtmp {
        { 0 }
 };
 
        { 0 }
 };
 
+int
 fdesc_readdir(ap)
        struct vop_readdir_args /* {
                struct vnode *a_vp;
 fdesc_readdir(ap)
        struct vop_readdir_args /* {
                struct vnode *a_vp;
@@ -586,13 +592,13 @@ fdesc_readdir(ap)
                        case FD_STDIN:
                        case FD_STDOUT:
                        case FD_STDERR:
                        case FD_STDIN:
                        case FD_STDOUT:
                        case FD_STDERR:
-                               if ((i-FD_STDIN) >= fdp->fd_nfiles)
+                               if ((dt->d_fileno-FD_STDIN) >= fdp->fd_nfiles)
                                        continue;
                                        continue;
-                               if (fdp->fd_ofiles[i-FD_STDIN] == NULL)
+                               if (fdp->fd_ofiles[dt->d_fileno-FD_STDIN] == NULL)
                                        continue;
                                break;
                        }
                                        continue;
                                break;
                        }
-                       bzero(dp, UIO_MX);
+                       bzero((caddr_t) dp, UIO_MX);
                        dp->d_fileno = dt->d_fileno;
                        dp->d_namlen = dt->d_namlen;
                        dp->d_type = DT_UNKNOWN;
                        dp->d_fileno = dt->d_fileno;
                        dp->d_namlen = dt->d_namlen;
                        dp->d_type = DT_UNKNOWN;
@@ -609,20 +615,16 @@ fdesc_readdir(ap)
        i = uio->uio_offset / UIO_MX;
        error = 0;
        while (uio->uio_resid > 0) {
        i = uio->uio_offset / UIO_MX;
        error = 0;
        while (uio->uio_resid > 0) {
-               if (i >= fdp->fd_nfiles) {
-                       /* *ap->a_eofflagp = 1; */
+               if (i >= fdp->fd_nfiles)
                        break;
                        break;
-               }
+
                if (fdp->fd_ofiles[i] != NULL) {
                        struct dirent d;
                        struct dirent *dp = &d;
                if (fdp->fd_ofiles[i] != NULL) {
                        struct dirent d;
                        struct dirent *dp = &d;
-                       char *cp = dp->d_name;
+
                        bzero((caddr_t) dp, UIO_MX);
 
                        dp->d_namlen = sprintf(dp->d_name, "%d", i);
                        bzero((caddr_t) dp, UIO_MX);
 
                        dp->d_namlen = sprintf(dp->d_name, "%d", i);
-                       /*
-                        * Fill in the remaining fields
-                        */
                        dp->d_reclen = UIO_MX;
                        dp->d_type = DT_UNKNOWN;
                        dp->d_fileno = i + FD_STDIN;
                        dp->d_reclen = UIO_MX;
                        dp->d_type = DT_UNKNOWN;
                        dp->d_fileno = i + FD_STDIN;
@@ -648,7 +650,7 @@ fdesc_readlink(ap)
                struct ucred *a_cred;
        } */ *ap;
 {
                struct ucred *a_cred;
        } */ *ap;
 {
-       register struct vnode *vp = ap->a_vp;
+       struct vnode *vp = ap->a_vp;
        int error;
 
        if (vp->v_type != VLNK)
        int error;
 
        if (vp->v_type != VLNK)
@@ -664,6 +666,7 @@ fdesc_readlink(ap)
        return (error);
 }
 
        return (error);
 }
 
+int
 fdesc_read(ap)
        struct vop_read_args /* {
                struct vnode *a_vp;
 fdesc_read(ap)
        struct vop_read_args /* {
                struct vnode *a_vp;
@@ -687,6 +690,7 @@ fdesc_read(ap)
        return (error);
 }
 
        return (error);
 }
 
+int
 fdesc_write(ap)
        struct vop_write_args /* {
                struct vnode *a_vp;
 fdesc_write(ap)
        struct vop_write_args /* {
                struct vnode *a_vp;
@@ -710,6 +714,7 @@ fdesc_write(ap)
        return (error);
 }
 
        return (error);
 }
 
+int
 fdesc_ioctl(ap)
        struct vop_ioctl_args /* {
                struct vnode *a_vp;
 fdesc_ioctl(ap)
        struct vop_ioctl_args /* {
                struct vnode *a_vp;
@@ -722,10 +727,6 @@ fdesc_ioctl(ap)
 {
        int error = EOPNOTSUPP;
 
 {
        int error = EOPNOTSUPP;
 
-#ifdef FDESC_DIAGNOSTIC
-       printf("fdesc_ioctl: type = %d, command = %x\n",
-                       VTOFDESC(ap->a_vp)->fd_type, ap->a_command);
-#endif
        switch (VTOFDESC(ap->a_vp)->fd_type) {
        case Fctty:
                error = cttyioctl(devctty, ap->a_command, ap->a_data,
        switch (VTOFDESC(ap->a_vp)->fd_type) {
        case Fctty:
                error = cttyioctl(devctty, ap->a_command, ap->a_data,
@@ -740,6 +741,7 @@ fdesc_ioctl(ap)
        return (error);
 }
 
        return (error);
 }
 
+int
 fdesc_select(ap)
        struct vop_select_args /* {
                struct vnode *a_vp;
 fdesc_select(ap)
        struct vop_select_args /* {
                struct vnode *a_vp;
@@ -764,6 +766,7 @@ fdesc_select(ap)
        return (error);
 }
 
        return (error);
 }
 
+int
 fdesc_inactive(ap)
        struct vop_inactive_args /* {
                struct vnode *a_vp;
 fdesc_inactive(ap)
        struct vop_inactive_args /* {
                struct vnode *a_vp;
@@ -776,40 +779,65 @@ fdesc_inactive(ap)
         * nasty things happening in vgone().
         */
        vp->v_type = VNON;
         * nasty things happening in vgone().
         */
        vp->v_type = VNON;
-#ifdef FDESC_DIAGNOSTIC
-       printf("fdesc_inactive(%x)\n", vp);
-#endif
        return (0);
 }
 
        return (0);
 }
 
+int
 fdesc_reclaim(ap)
        struct vop_reclaim_args /* {
                struct vnode *a_vp;
        } */ *ap;
 {
        struct vnode *vp = ap->a_vp;
 fdesc_reclaim(ap)
        struct vop_reclaim_args /* {
                struct vnode *a_vp;
        } */ *ap;
 {
        struct vnode *vp = ap->a_vp;
-       int ix;
 
 
-#ifdef FDESC_DIAGNOSTIC
-       printf("fdesc_reclaim(%x)\n", vp);
-#endif
-       ix = VTOFDESC(vp)->fd_ix;
-       if (ix >= 0 && ix < FD_MAX) {
-               if (fdescvp[ix] != vp)
-                       panic("fdesc_reclaim");
-               fdescvp[ix] = 0;
-       }
-       if (vp->v_data) {
-               FREE(vp->v_data, M_TEMP);
-               vp->v_data = 0;
-       }
+       remque(VTOFDESC(vp));
+       FREE(vp->v_data, M_TEMP);
+       vp->v_data = 0;
+
        return (0);
 }
 
        return (0);
 }
 
+/*
+ * Return POSIX pathconf information applicable to special devices.
+ */
+fdesc_pathconf(ap)
+       struct vop_pathconf_args /* {
+               struct vnode *a_vp;
+               int a_name;
+               int *a_retval;
+       } */ *ap;
+{
+
+       switch (ap->a_name) {
+       case _PC_LINK_MAX:
+               *ap->a_retval = LINK_MAX;
+               return (0);
+       case _PC_MAX_CANON:
+               *ap->a_retval = MAX_CANON;
+               return (0);
+       case _PC_MAX_INPUT:
+               *ap->a_retval = MAX_INPUT;
+               return (0);
+       case _PC_PIPE_BUF:
+               *ap->a_retval = PIPE_BUF;
+               return (0);
+       case _PC_CHOWN_RESTRICTED:
+               *ap->a_retval = 1;
+               return (0);
+       case _PC_VDISABLE:
+               *ap->a_retval = _POSIX_VDISABLE;
+               return (0);
+       default:
+               return (EINVAL);
+       }
+       /* NOTREACHED */
+}
+
 /*
  * Print out the contents of a /dev/fd vnode.
  */
 /* ARGSUSED */
 /*
  * Print out the contents of a /dev/fd vnode.
  */
 /* ARGSUSED */
+int
 fdesc_print(ap)
        struct vop_print_args /* {
                struct vnode *a_vp;
 fdesc_print(ap)
        struct vop_print_args /* {
                struct vnode *a_vp;
@@ -821,6 +849,7 @@ fdesc_print(ap)
 }
 
 /*void*/
 }
 
 /*void*/
+int
 fdesc_vfree(ap)
        struct vop_vfree_args /* {
                struct vnode *a_pvp;
 fdesc_vfree(ap)
        struct vop_vfree_args /* {
                struct vnode *a_pvp;
@@ -835,6 +864,7 @@ fdesc_vfree(ap)
 /*
  * /dev/fd vnode unsupported operation
  */
 /*
  * /dev/fd vnode unsupported operation
  */
+int
 fdesc_enotsupp()
 {
 
 fdesc_enotsupp()
 {
 
@@ -844,6 +874,7 @@ fdesc_enotsupp()
 /*
  * /dev/fd "should never get here" operation
  */
 /*
  * /dev/fd "should never get here" operation
  */
+int
 fdesc_badop()
 {
 
 fdesc_badop()
 {
 
@@ -854,6 +885,7 @@ fdesc_badop()
 /*
  * /dev/fd vnode null operation
  */
 /*
  * /dev/fd vnode null operation
  */
+int
 fdesc_nullop()
 {
 
 fdesc_nullop()
 {
 
@@ -928,6 +960,7 @@ struct vnodeopv_entry_desc fdesc_vnodeop_entries[] = {
        { &vop_strategy_desc, fdesc_strategy }, /* strategy */
        { &vop_print_desc, fdesc_print },       /* print */
        { &vop_islocked_desc, fdesc_islocked }, /* islocked */
        { &vop_strategy_desc, fdesc_strategy }, /* strategy */
        { &vop_print_desc, fdesc_print },       /* print */
        { &vop_islocked_desc, fdesc_islocked }, /* islocked */
+       { &vop_pathconf_desc, fdesc_pathconf }, /* pathconf */
        { &vop_advlock_desc, fdesc_advlock },   /* advlock */
        { &vop_blkatoff_desc, fdesc_blkatoff }, /* blkatoff */
        { &vop_valloc_desc, fdesc_valloc },     /* valloc */
        { &vop_advlock_desc, fdesc_advlock },   /* advlock */
        { &vop_blkatoff_desc, fdesc_blkatoff }, /* blkatoff */
        { &vop_valloc_desc, fdesc_valloc },     /* valloc */