must include proc before tty.h and socketvar.h
[unix-history] / usr / src / sys / miscfs / fifofs / fifo_vnops.c
index 060be93..be9fbdf 100644 (file)
@@ -2,30 +2,23 @@
  * 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 and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not 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.
+ * %sccs.include.redist.c%
  *
  *
- *     @(#)fifo_vnops.c        7.3 (Berkeley) %G%
+ *     @(#)fifo_vnops.c        7.10 (Berkeley) %G%
  */
 
 #include "param.h"
  */
 
 #include "param.h"
+#include "proc.h"
 #include "time.h"
 #include "namei.h"
 #include "vnode.h"
 #include "socket.h"
 #include "socketvar.h"
 #include "stat.h"
 #include "time.h"
 #include "namei.h"
 #include "vnode.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"
 
@@ -40,67 +33,60 @@ 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 */
+       fifo_blkatoff,          /* blkatoff */
+       fifo_vget,              /* vget */
+       fifo_valloc,            /* valloc */
+       fifo_vfree,             /* vfree */
+       fifo_truncate,          /* truncate */
+       fifo_update,            /* update */
+       fifo_bwrite,            /* bwrite */
 };
 
 /*
  * Trivial lookup routine that always fails.
  */
 };
 
 /*
  * Trivial lookup routine that always fails.
  */
-fifo_lookup(vp, ndp)
-       struct vnode *vp;
-       struct nameidata *ndp;
+/* ARGSUSED */
+fifo_lookup(dvp, vpp, cnp)
+       struct vnode *dvp;
+       struct vnode **vpp;
+       struct componentname *cnp;
 {
 {
-
-       ndp->ni_dvp = vp;
-       ndp->ni_vp = NULL;
+       
+       *vpp = NULL;
        return (ENOTDIR);
 }
 
        return (ENOTDIR);
 }
 
@@ -109,10 +95,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;
@@ -178,7 +165,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);
 }
 
@@ -195,8 +182,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)
@@ -229,8 +218,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);
@@ -245,12 +236,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;
@@ -261,14 +253,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;
@@ -277,7 +270,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));
 }
 
 /*
 }
 
 /*
@@ -320,10 +313,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;
@@ -382,20 +376,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 */
 }
 }