BSD 4_3_Net_2 release
[unix-history] / usr / src / sys / kern / fifo_vnops.c
index f24c0de..852b50d 100644 (file)
@@ -2,22 +2,35 @@
  * Copyright (c) 1990 The Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1990 The Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution is only permitted until one year after the first shipment
- * of 4.4BSD by the Regents.  Otherwise, redistribution and use in source and
- * binary forms are permitted provided that: (1) source distributions retain
- * this entire copyright notice and comment, and (2) distributions including
- * binaries display the following acknowledgement:  This product includes
- * software developed by the University of California, Berkeley and its
- * contributors'' in the documentation or other materials provided with the
- * distribution and in all advertising materials mentioning features or use
- * of this software.  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.
- * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * 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.
  *
  *
- *     @(#)fifo_vnops.c        7.4 (Berkeley) 6/28/90
+ * 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.
+ *
+ *     @(#)fifo_vnops.c        7.7 (Berkeley) 4/15/91
  */
 
 #include "param.h"
  */
 
 #include "param.h"
 #include "socket.h"
 #include "socketvar.h"
 #include "stat.h"
 #include "socket.h"
 #include "socketvar.h"
 #include "stat.h"
+#include "systm.h"
 #include "ioctl.h"
 #include "file.h"
 #include "ioctl.h"
 #include "file.h"
+#include "fifo.h"
 #include "errno.h"
 #include "malloc.h"
 
 #include "errno.h"
 #include "malloc.h"
 
@@ -43,63 +58,50 @@ struct fifoinfo {
        long            fi_writers;
 };
 
        long            fi_writers;
 };
 
-int    fifo_lookup(),
-       fifo_open(),
-       fifo_read(),
-       fifo_write(),
-       fifo_strategy(),
-       fifo_bmap(),
-       fifo_ioctl(),
-       fifo_select(),
-       fifo_lock(),
-       fifo_unlock(),
-       fifo_close(),
-       fifo_print(),
-       fifo_ebadf(),
-       fifo_badop(),
-       fifo_nullop();
-
 struct vnodeops fifo_vnodeops = {
        fifo_lookup,            /* lookup */
 struct vnodeops fifo_vnodeops = {
        fifo_lookup,            /* lookup */
-       fifo_badop,             /* create */
-       fifo_badop,             /* mknod */
+       fifo_create,            /* create */
+       fifo_mknod,             /* mknod */
        fifo_open,              /* open */
        fifo_close,             /* close */
        fifo_open,              /* open */
        fifo_close,             /* close */
-       fifo_ebadf,             /* access */
-       fifo_ebadf,             /* getattr */
-       fifo_ebadf,             /* setattr */
+       fifo_access,            /* access */
+       fifo_getattr,           /* getattr */
+       fifo_setattr,           /* setattr */
        fifo_read,              /* read */
        fifo_write,             /* write */
        fifo_ioctl,             /* ioctl */
        fifo_select,            /* select */
        fifo_read,              /* read */
        fifo_write,             /* write */
        fifo_ioctl,             /* ioctl */
        fifo_select,            /* select */
-       fifo_badop,             /* mmap */
-       fifo_nullop,            /* fsync */
-       fifo_badop,             /* seek */
-       fifo_badop,             /* remove */
-       fifo_badop,             /* link */
-       fifo_badop,             /* rename */
-       fifo_badop,             /* mkdir */
-       fifo_badop,             /* rmdir */
-       fifo_badop,             /* symlink */
-       fifo_badop,             /* readdir */
-       fifo_badop,             /* readlink */
-       fifo_badop,             /* abortop */
-       fifo_nullop,            /* inactive */
-       fifo_nullop,            /* reclaim */
+       fifo_mmap,              /* mmap */
+       fifo_fsync,             /* fsync */
+       fifo_seek,              /* seek */
+       fifo_remove,            /* remove */
+       fifo_link,              /* link */
+       fifo_rename,            /* rename */
+       fifo_mkdir,             /* mkdir */
+       fifo_rmdir,             /* rmdir */
+       fifo_symlink,           /* symlink */
+       fifo_readdir,           /* readdir */
+       fifo_readlink,          /* readlink */
+       fifo_abortop,           /* abortop */
+       fifo_inactive,          /* inactive */
+       fifo_reclaim,           /* reclaim */
        fifo_lock,              /* lock */
        fifo_unlock,            /* unlock */
        fifo_bmap,              /* bmap */
        fifo_lock,              /* lock */
        fifo_unlock,            /* unlock */
        fifo_bmap,              /* bmap */
-       fifo_badop,             /* strategy */
+       fifo_strategy,          /* strategy */
        fifo_print,             /* print */
        fifo_print,             /* print */
-       fifo_nullop,            /* islocked */
+       fifo_islocked,          /* islocked */
+       fifo_advlock,           /* advlock */
 };
 
 /*
  * Trivial lookup routine that always fails.
  */
 };
 
 /*
  * Trivial lookup routine that always fails.
  */
-fifo_lookup(vp, ndp)
+/* ARGSUSED */
+fifo_lookup(vp, ndp, p)
        struct vnode *vp;
        struct nameidata *ndp;
        struct vnode *vp;
        struct nameidata *ndp;
+       struct proc *p;
 {
 
        ndp->ni_dvp = vp;
 {
 
        ndp->ni_dvp = vp;
@@ -112,10 +114,11 @@ fifo_lookup(vp, ndp)
  * to find an active instance of a fifo.
  */
 /* ARGSUSED */
  * to find an active instance of a fifo.
  */
 /* ARGSUSED */
-fifo_open(vp, mode, cred)
+fifo_open(vp, mode, cred, p)
        register struct vnode *vp;
        int mode;
        struct ucred *cred;
        register struct vnode *vp;
        int mode;
        struct ucred *cred;
+       struct proc *p;
 {
        register struct fifoinfo *fip;
        struct socket *rso, *wso;
 {
        register struct fifoinfo *fip;
        struct socket *rso, *wso;
@@ -181,7 +184,7 @@ fifo_open(vp, mode, cred)
                }
        }
        if (error)
                }
        }
        if (error)
-               fifo_close(vp, mode, cred);
+               fifo_close(vp, mode, cred, p);
        return (error);
 }
 
        return (error);
 }
 
@@ -198,8 +201,10 @@ fifo_read(vp, uio, ioflag, cred)
        register struct socket *rso = vp->v_fifoinfo->fi_readsock;
        int error, startresid;
 
        register struct socket *rso = vp->v_fifoinfo->fi_readsock;
        int error, startresid;
 
+#ifdef DIAGNOSTIC
        if (uio->uio_rw != UIO_READ)
                panic("fifo_read mode");
        if (uio->uio_rw != UIO_READ)
                panic("fifo_read mode");
+#endif
        if (uio->uio_resid == 0)
                return (0);
        if (ioflag & IO_NDELAY)
        if (uio->uio_resid == 0)
                return (0);
        if (ioflag & IO_NDELAY)
@@ -232,8 +237,10 @@ fifo_write(vp, uio, ioflag, cred)
        struct socket *wso = vp->v_fifoinfo->fi_writesock;
        int error;
 
        struct socket *wso = vp->v_fifoinfo->fi_writesock;
        int error;
 
+#ifdef DIAGNOSTIC
        if (uio->uio_rw != UIO_WRITE)
                panic("fifo_write mode");
        if (uio->uio_rw != UIO_WRITE)
                panic("fifo_write mode");
+#endif
        if (ioflag & IO_NDELAY)
                wso->so_state |= SS_NBIO;
        VOP_UNLOCK(vp);
        if (ioflag & IO_NDELAY)
                wso->so_state |= SS_NBIO;
        VOP_UNLOCK(vp);
@@ -248,12 +255,13 @@ fifo_write(vp, uio, ioflag, cred)
  * Device ioctl operation.
  */
 /* ARGSUSED */
  * Device ioctl operation.
  */
 /* ARGSUSED */
-fifo_ioctl(vp, com, data, fflag, cred)
+fifo_ioctl(vp, com, data, fflag, cred, p)
        struct vnode *vp;
        int com;
        caddr_t data;
        int fflag;
        struct ucred *cred;
        struct vnode *vp;
        int com;
        caddr_t data;
        int fflag;
        struct ucred *cred;
+       struct proc *p;
 {
        struct file filetmp;
        int error;
 {
        struct file filetmp;
        int error;
@@ -264,14 +272,15 @@ fifo_ioctl(vp, com, data, fflag, cred)
                filetmp.f_data = (caddr_t)vp->v_fifoinfo->fi_readsock;
        else
                filetmp.f_data = (caddr_t)vp->v_fifoinfo->fi_writesock;
                filetmp.f_data = (caddr_t)vp->v_fifoinfo->fi_readsock;
        else
                filetmp.f_data = (caddr_t)vp->v_fifoinfo->fi_writesock;
-       return (soo_ioctl(&filetmp, com, data));
+       return (soo_ioctl(&filetmp, com, data, p));
 }
 
 /* ARGSUSED */
 }
 
 /* ARGSUSED */
-fifo_select(vp, which, fflag, cred)
+fifo_select(vp, which, fflag, cred, p)
        struct vnode *vp;
        int which, fflag;
        struct ucred *cred;
        struct vnode *vp;
        int which, fflag;
        struct ucred *cred;
+       struct proc *p;
 {
        struct file filetmp;
        int error;
 {
        struct file filetmp;
        int error;
@@ -280,7 +289,7 @@ fifo_select(vp, which, fflag, cred)
                filetmp.f_data = (caddr_t)vp->v_fifoinfo->fi_readsock;
        else
                filetmp.f_data = (caddr_t)vp->v_fifoinfo->fi_writesock;
                filetmp.f_data = (caddr_t)vp->v_fifoinfo->fi_readsock;
        else
                filetmp.f_data = (caddr_t)vp->v_fifoinfo->fi_writesock;
-       return (soo_select(&filetmp, which));
+       return (soo_select(&filetmp, which, p));
 }
 
 /*
 }
 
 /*
@@ -323,10 +332,11 @@ fifo_unlock(vp)
  * Device close routine
  */
 /* ARGSUSED */
  * Device close routine
  */
 /* ARGSUSED */
-fifo_close(vp, fflag, cred)
+fifo_close(vp, fflag, cred, p)
        register struct vnode *vp;
        int fflag;
        struct ucred *cred;
        register struct vnode *vp;
        int fflag;
        struct ucred *cred;
+       struct proc *p;
 {
        register struct fifoinfo *fip = vp->v_fifoinfo;
        int error1, error2;
 {
        register struct fifoinfo *fip = vp->v_fifoinfo;
        int error1, error2;
@@ -385,20 +395,26 @@ fifo_ebadf()
 }
 
 /*
 }
 
 /*
- * Fifo bad operation
+ * Fifo advisory byte-level locks.
  */
  */
-fifo_badop()
+/* ARGSUSED */
+fifo_advlock(vp, id, op, fl, flags)
+       struct vnode *vp;
+       caddr_t id;
+       int op;
+       struct flock *fl;
+       int flags;
 {
 
 {
 
-       panic("fifo_badop called");
-       /* NOTREACHED */
+       return (EOPNOTSUPP);
 }
 
 /*
 }
 
 /*
- * Fifo null operation
+ * Fifo bad operation
  */
  */
-fifo_nullop()
+fifo_badop()
 {
 
 {
 
-       return (0);
+       panic("fifo_badop called");
+       /* NOTREACHED */
 }
 }