Merge branch 'vendor/OPENSSH'
[dragonfly.git] / sys / vfs / fifofs / fifo_vnops.c
1 /*
2  * Copyright (c) 1990, 1993, 1995
3  *      The Regents of the University of California.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *      This product includes software developed by the University of
16  *      California, Berkeley and its contributors.
17  * 4. Neither the name of the University nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  */
33 /*
34  * Filesystem FIFO type ops.  All entry points are MPSAFE.  We primarily
35  * use v_token to interlock operations.
36  */
37 #include <sys/param.h>
38 #include <sys/systm.h>
39 #include <sys/unistd.h>
40 #include <sys/kernel.h>
41 #include <sys/lock.h>
42 #include <sys/malloc.h>
43 #include <sys/thread2.h>
44 #include <sys/vnode.h>
45 #include <sys/socket.h>
46 #include <sys/socketvar.h>
47 #include <sys/filio.h>
48 #include <sys/fcntl.h>
49 #include <sys/file.h>
50 #include <sys/event.h>
51 #include <sys/poll.h>
52 #include <sys/un.h>
53
54 #include <sys/thread2.h>
55
56 #include "fifo.h"
57
58 /*
59  * This structure is associated with the FIFO vnode and stores
60  * the state associated with the FIFO.
61  */
62 struct fifoinfo {
63         struct socket   *fi_readsock;
64         struct socket   *fi_writesock;
65         long            fi_readers;
66         long            fi_writers;
67 };
68
69 static int      fifo_badop (void);
70 static int      fifo_print (struct vop_print_args *);
71 static int      fifo_lookup (struct vop_old_lookup_args *);
72 static int      fifo_open (struct vop_open_args *);
73 static int      fifo_close (struct vop_close_args *);
74 static int      fifo_read (struct vop_read_args *);
75 static int      fifo_write (struct vop_write_args *);
76 static int      fifo_ioctl (struct vop_ioctl_args *);
77 static int      fifo_poll (struct vop_poll_args *);
78 static int      fifo_kqfilter (struct vop_kqfilter_args *);
79 static int      fifo_inactive (struct  vop_inactive_args *);
80 static int      fifo_bmap (struct vop_bmap_args *);
81 static int      fifo_pathconf (struct vop_pathconf_args *);
82 static int      fifo_advlock (struct vop_advlock_args *);
83
84 static void     filt_fifordetach(struct knote *kn);
85 static int      filt_fiforead(struct knote *kn, long hint);
86 static void     filt_fifowdetach(struct knote *kn);
87 static int      filt_fifowrite(struct knote *kn, long hint);
88
89 static struct filterops fiforead_filtops =
90         { 1, NULL, filt_fifordetach, filt_fiforead };
91 static struct filterops fifowrite_filtops =
92         { 1, NULL, filt_fifowdetach, filt_fifowrite };
93   
94 struct vop_ops fifo_vnode_vops = {
95         .vop_default =          vop_defaultop,
96         .vop_access =           (void *)vop_ebadf,
97         .vop_advlock =          fifo_advlock,
98         .vop_bmap =             fifo_bmap,
99         .vop_close =            fifo_close,
100         .vop_old_create =       (void *)fifo_badop,
101         .vop_getattr =          (void *)vop_ebadf,
102         .vop_inactive =         fifo_inactive,
103         .vop_ioctl =            fifo_ioctl,
104         .vop_kqfilter =         fifo_kqfilter,
105         .vop_old_link =         (void *)fifo_badop,
106         .vop_old_lookup =       fifo_lookup,
107         .vop_old_mkdir =        (void *)fifo_badop,
108         .vop_old_mknod =        (void *)fifo_badop,
109         .vop_open =             fifo_open,
110         .vop_pathconf =         fifo_pathconf,
111         .vop_poll =             fifo_poll,
112         .vop_print =            fifo_print,
113         .vop_read =             fifo_read,
114         .vop_readdir =          (void *)fifo_badop,
115         .vop_readlink =         (void *)fifo_badop,
116         .vop_reallocblks =      (void *)fifo_badop,
117         .vop_reclaim =          (void *)vop_null,
118         .vop_old_remove =       (void *)fifo_badop,
119         .vop_old_rename =       (void *)fifo_badop,
120         .vop_old_rmdir =        (void *)fifo_badop,
121         .vop_setattr =          (void *)vop_ebadf,
122         .vop_old_symlink =      (void *)fifo_badop,
123         .vop_write =            fifo_write
124 };
125
126 VNODEOP_SET(fifo_vnode_vops);
127
128 static MALLOC_DEFINE(M_FIFOINFO, "Fifo info", "Fifo info entries");
129
130 /*
131  * fifo_vnoperate()
132  */
133 int
134 fifo_vnoperate(struct vop_generic_args *ap)
135 {
136         return (VOCALL(&fifo_vnode_vops, ap));
137 }
138
139 /*
140  * Trivial lookup routine that always fails.
141  *
142  * fifo_lookup(struct vnode *a_dvp, struct vnode **a_vpp,
143  *             struct componentname *a_cnp)
144  */
145 /* ARGSUSED */
146 static int
147 fifo_lookup(struct vop_old_lookup_args *ap)
148 {
149         *ap->a_vpp = NULL;
150         return (ENOTDIR);
151 }
152
153 /*
154  * Open called to set up a new instance of a fifo or
155  * to find an active instance of a fifo.
156  *
157  * fifo_open(struct vnode *a_vp, int a_mode, struct ucred *a_cred,
158  *           struct file *a_fp)
159  */
160 /* ARGSUSED */
161 static int
162 fifo_open(struct vop_open_args *ap)
163 {
164         struct thread *td = curthread;
165         struct vnode *vp = ap->a_vp;
166         struct fifoinfo *fip;
167         struct socket *rso, *wso;
168         lwkt_tokref     vlock;
169         int error;
170
171         lwkt_gettoken(&vlock, &vp->v_token);
172         if ((fip = vp->v_fifoinfo) == NULL) {
173                 MALLOC(fip, struct fifoinfo *, sizeof(*fip), M_FIFOINFO, M_WAITOK);
174                 vp->v_fifoinfo = fip;
175                 error = socreate(AF_LOCAL, &rso, SOCK_STREAM, 0, td);
176                 if (error) {
177                         kfree(fip, M_FIFOINFO);
178                         vp->v_fifoinfo = NULL;
179                         goto done;
180                 }
181                 fip->fi_readsock = rso;
182                 error = socreate(AF_LOCAL, &wso, SOCK_STREAM, 0, td);
183                 if (error) {
184                         soclose(rso, FNONBLOCK);
185                         kfree(fip, M_FIFOINFO);
186                         vp->v_fifoinfo = NULL;
187                         goto done;
188                 }
189                 fip->fi_writesock = wso;
190                 error = unp_connect2(wso, rso);
191                 if (error) {
192                         soclose(wso, FNONBLOCK);
193                         soclose(rso, FNONBLOCK);
194                         kfree(fip, M_FIFOINFO);
195                         vp->v_fifoinfo = NULL;
196                         goto done;
197                 }
198                 fip->fi_readers = fip->fi_writers = 0;
199                 wso->so_snd.ssb_lowat = PIPE_BUF;
200                 rso->so_state |= SS_CANTRCVMORE;
201         }
202         if (ap->a_mode & FREAD) {
203                 fip->fi_readers++;
204                 if (fip->fi_readers == 1) {
205                         fip->fi_writesock->so_state &= ~SS_CANTSENDMORE;
206                         if (fip->fi_writers > 0) {
207                                 wakeup((caddr_t)&fip->fi_writers);
208                                 sowwakeup(fip->fi_writesock);
209                         }
210                 }
211         }
212         if (ap->a_mode & FWRITE) {
213                 fip->fi_writers++;
214                 if (fip->fi_writers == 1) {
215                         fip->fi_readsock->so_state &= ~SS_CANTRCVMORE;
216                         if (fip->fi_readers > 0) {
217                                 wakeup((caddr_t)&fip->fi_readers);
218                                 sorwakeup(fip->fi_writesock);
219                         }
220                 }
221         }
222         if ((ap->a_mode & FREAD) && (ap->a_mode & O_NONBLOCK) == 0) {
223                 if (fip->fi_writers == 0) {
224                         vn_unlock(vp);
225                         error = tsleep((caddr_t)&fip->fi_readers,
226                             PCATCH, "fifoor", 0);
227                         vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
228                         if (error)
229                                 goto bad;
230                         /*
231                          * We must have got woken up because we had a writer.
232                          * That (and not still having one) is the condition
233                          * that we must wait for.
234                          */
235                 }
236         }
237         if (ap->a_mode & FWRITE) {
238                 if (ap->a_mode & O_NONBLOCK) {
239                         if (fip->fi_readers == 0) {
240                                 error = ENXIO;
241                                 goto bad;
242                         }
243                 } else {
244                         if (fip->fi_readers == 0) {
245                                 vn_unlock(vp);
246                                 error = tsleep((caddr_t)&fip->fi_writers,
247                                     PCATCH, "fifoow", 0);
248                                 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
249                                 if (error)
250                                         goto bad;
251                                 /*
252                                  * We must have got woken up because we had
253                                  * a reader.  That (and not still having one)
254                                  * is the condition that we must wait for.
255                                  */
256                         }
257                 }
258         }
259         vsetflags(vp, VNOTSEEKABLE);
260         error = vop_stdopen(ap);
261         lwkt_reltoken(&vlock);
262         return (error);
263 bad:
264         vop_stdopen(ap);        /* bump opencount/writecount as appropriate */
265         VOP_CLOSE(vp, ap->a_mode);
266 done:
267         lwkt_reltoken(&vlock);
268         return (error);
269 }
270
271 /*
272  * Vnode op for read
273  *
274  * fifo_read(struct vnode *a_vp, struct uio *a_uio, int a_ioflag,
275  *           struct ucred *a_cred)
276  */
277 /* ARGSUSED */
278 static int
279 fifo_read(struct vop_read_args *ap)
280 {
281         struct uio *uio = ap->a_uio;
282         struct socket *rso = ap->a_vp->v_fifoinfo->fi_readsock;
283         int error, startresid;
284         lwkt_tokref vlock;
285         int flags;
286
287 #ifdef DIAGNOSTIC
288         if (uio->uio_rw != UIO_READ)
289                 panic("fifo_read mode");
290 #endif
291         if (uio->uio_resid == 0)
292                 return (0);
293         if (ap->a_ioflag & IO_NDELAY)
294                 flags = MSG_FNONBLOCKING;
295         else
296                 flags = 0;
297         startresid = uio->uio_resid;
298         vn_unlock(ap->a_vp);
299         lwkt_gettoken(&vlock, &ap->a_vp->v_token);
300         error = soreceive(rso, NULL, uio, NULL, NULL, &flags);
301         lwkt_reltoken(&vlock);
302         vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY);
303         return (error);
304 }
305
306 /*
307  * Vnode op for write
308  *
309  * fifo_write(struct vnode *a_vp, struct uio *a_uio, int a_ioflag,
310  *            struct ucred *a_cred)
311  */
312 /* ARGSUSED */
313 static int
314 fifo_write(struct vop_write_args *ap)
315 {
316         struct socket *wso = ap->a_vp->v_fifoinfo->fi_writesock;
317         struct thread *td = ap->a_uio->uio_td;
318         lwkt_tokref vlock;
319         int error;
320         int flags;
321
322 #ifdef DIAGNOSTIC
323         if (ap->a_uio->uio_rw != UIO_WRITE)
324                 panic("fifo_write mode");
325 #endif
326         if (ap->a_ioflag & IO_NDELAY)
327                 flags = MSG_FNONBLOCKING;
328         else
329                 flags = 0;
330         vn_unlock(ap->a_vp);
331         lwkt_gettoken(&vlock, &ap->a_vp->v_token);
332         error = sosend(wso, NULL, ap->a_uio, 0, NULL, flags, td);
333         lwkt_reltoken(&vlock);
334         vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY);
335         return (error);
336 }
337
338 /*
339  * Device ioctl operation.
340  *
341  * fifo_ioctl(struct vnode *a_vp, int a_command, caddr_t a_data, int a_fflag,
342  *            struct ucred *a_cred, struct sysmsg *a_sysmsg)
343  */
344 /* ARGSUSED */
345 static int
346 fifo_ioctl(struct vop_ioctl_args *ap)
347 {
348         struct file filetmp;    /* Local */
349         lwkt_tokref vlock;
350         int error;
351
352         if (ap->a_fflag & FREAD) {
353                 filetmp.f_data = ap->a_vp->v_fifoinfo->fi_readsock;
354                 lwkt_gettoken(&vlock, &ap->a_vp->v_token);
355                 error = soo_ioctl(&filetmp, ap->a_command, ap->a_data,
356                                   ap->a_cred, ap->a_sysmsg);
357                 lwkt_reltoken(&vlock);
358                 if (error)
359                         return (error);
360         }
361         if (ap->a_fflag & FWRITE) {
362                 filetmp.f_data = ap->a_vp->v_fifoinfo->fi_writesock;
363                 lwkt_gettoken(&vlock, &ap->a_vp->v_token);
364                 error = soo_ioctl(&filetmp, ap->a_command, ap->a_data,
365                                   ap->a_cred, ap->a_sysmsg);
366                 lwkt_reltoken(&vlock);
367                 if (error)
368                         return (error);
369         }
370         return (0);
371 }
372
373 /*
374  * fifo_kqfilter(struct vnode *a_vp, struct knote *a_kn)
375  */
376 /* ARGSUSED */
377 static int
378 fifo_kqfilter(struct vop_kqfilter_args *ap)
379 {
380         struct vnode *vp = ap->a_vp;
381         struct fifoinfo *fi = vp->v_fifoinfo;
382         struct socket *so;
383         struct signalsockbuf *ssb;
384         lwkt_tokref vlock;
385
386         lwkt_gettoken(&vlock, &vp->v_token);
387         switch (ap->a_kn->kn_filter) {
388         case EVFILT_READ:
389                 ap->a_kn->kn_fop = &fiforead_filtops;
390                 so = fi->fi_readsock;
391                 ssb = &so->so_rcv;
392                 break;
393         case EVFILT_WRITE:
394                 ap->a_kn->kn_fop = &fifowrite_filtops;
395                 so = fi->fi_writesock;
396                 ssb = &so->so_snd;
397                 break;
398         default:
399                 return (1);
400         }
401
402         ap->a_kn->kn_hook = (caddr_t)vp;
403         ssb_insert_knote(ssb, ap->a_kn);
404
405         lwkt_reltoken(&vlock);
406         return (0);
407 }
408
409 static void
410 filt_fifordetach(struct knote *kn)
411 {
412         struct vnode *vp = (void *)kn->kn_hook;
413         struct socket *so = vp->v_fifoinfo->fi_readsock;
414         lwkt_tokref vlock;
415
416         lwkt_gettoken(&vlock, &vp->v_token);
417         ssb_remove_knote(&so->so_rcv, kn);
418         lwkt_reltoken(&vlock);
419 }
420
421 static int
422 filt_fiforead(struct knote *kn, long hint)
423 {
424         struct vnode *vp = (void *)kn->kn_hook;
425         struct socket *so = vp->v_fifoinfo->fi_readsock;
426         lwkt_tokref vlock;
427
428         lwkt_gettoken(&vlock, &vp->v_token);
429         kn->kn_data = so->so_rcv.ssb_cc;
430         if (so->so_state & SS_CANTRCVMORE) {
431                 kn->kn_flags |= EV_EOF;
432                 return (1);
433         }
434         kn->kn_flags &= ~EV_EOF;
435         lwkt_reltoken(&vlock);
436         return (kn->kn_data > 0);
437 }
438
439 static void
440 filt_fifowdetach(struct knote *kn)
441 {
442         struct vnode *vp = (void *)kn->kn_hook;
443         struct socket *so = vp->v_fifoinfo->fi_writesock;
444         lwkt_tokref vlock;
445
446         lwkt_gettoken(&vlock, &vp->v_token);
447         ssb_remove_knote(&so->so_snd, kn);
448         lwkt_reltoken(&vlock);
449 }
450
451 static int
452 filt_fifowrite(struct knote *kn, long hint)
453 {
454         struct vnode *vp = (void *)kn->kn_hook;
455         struct socket *so = vp->v_fifoinfo->fi_writesock;
456         lwkt_tokref vlock;
457
458         lwkt_gettoken(&vlock, &vp->v_token);
459         kn->kn_data = ssb_space(&so->so_snd);
460         if (so->so_state & SS_CANTSENDMORE) {
461                 kn->kn_flags |= EV_EOF;
462                 return (1);
463         }
464         kn->kn_flags &= ~EV_EOF;
465         lwkt_reltoken(&vlock);
466         return (kn->kn_data >= so->so_snd.ssb_lowat);
467 }
468
469 /*
470  * fifo_poll(struct vnode *a_vp, int a_events, struct ucred *a_cred)
471  */
472 /* ARGSUSED */
473 static int
474 fifo_poll(struct vop_poll_args *ap)
475 {
476         struct file filetmp;
477         int events, revents = 0;
478         lwkt_tokref vlock;
479
480         lwkt_gettoken(&vlock, &ap->a_vp->v_token);
481         events = ap->a_events &
482                 (POLLIN | POLLINIGNEOF | POLLPRI | POLLRDNORM | POLLRDBAND);
483         if (events) {
484                 /*
485                  * If POLLIN or POLLRDNORM is requested and POLLINIGNEOF is
486                  * not, then convert the first two to the last one.  This
487                  * tells the socket poll function to ignore EOF so that we
488                  * block if there is no writer (and no data).  Callers can
489                  * set POLLINIGNEOF to get non-blocking behavior.
490                  */
491                 if (events & (POLLIN | POLLRDNORM) &&
492                         !(events & POLLINIGNEOF)) {
493                         events &= ~(POLLIN | POLLRDNORM);
494                         events |= POLLINIGNEOF;
495                 }
496                 
497                 filetmp.f_data = ap->a_vp->v_fifoinfo->fi_readsock;
498                 if (filetmp.f_data)
499                         revents |= soo_poll(&filetmp, events, ap->a_cred);
500
501                 /* Reverse the above conversion. */
502                 if ((revents & POLLINIGNEOF) &&
503                         !(ap->a_events & POLLINIGNEOF)) {
504                         revents |= (ap->a_events & (POLLIN | POLLRDNORM));
505                         revents &= ~POLLINIGNEOF;
506                 }
507         }
508         events = ap->a_events & (POLLOUT | POLLWRNORM | POLLWRBAND);
509         if (events) {
510                 filetmp.f_data = ap->a_vp->v_fifoinfo->fi_writesock;
511                 if (filetmp.f_data)
512                         revents |= soo_poll(&filetmp, events, ap->a_cred);
513         }
514         lwkt_reltoken(&vlock);
515         return (revents);
516 }
517
518 /*
519  * fifo_inactive(struct vnode *a_vp)
520  */
521 static int
522 fifo_inactive(struct vop_inactive_args *ap)
523 {
524         return (0);
525 }
526
527 /*
528  * This is a noop, simply returning what one has been given.
529  *
530  * fifo_bmap(struct vnode *a_vp, off_t a_loffset, 
531  *           off_t *a_doffsetp, int *a_runp, int *a_runb)
532  */
533 static int
534 fifo_bmap(struct vop_bmap_args *ap)
535 {
536         if (ap->a_doffsetp != NULL)
537                 *ap->a_doffsetp = ap->a_loffset;
538         if (ap->a_runp != NULL)
539                 *ap->a_runp = 0;
540         if (ap->a_runb != NULL)
541                 *ap->a_runb = 0;
542         return (0);
543 }
544
545 /*
546  * Device close routine
547  *
548  * fifo_close(struct vnode *a_vp, int a_fflag)
549  */
550 /* ARGSUSED */
551 static int
552 fifo_close(struct vop_close_args *ap)
553 {
554         struct vnode *vp = ap->a_vp;
555         struct fifoinfo *fip;
556         int error1, error2;
557         lwkt_tokref vlock;
558
559         lwkt_gettoken(&vlock, &vp->v_token);
560         fip = vp->v_fifoinfo;
561         if (ap->a_fflag & FREAD) {
562                 fip->fi_readers--;
563                 if (fip->fi_readers == 0)
564                         socantsendmore(fip->fi_writesock);
565         }
566         if (ap->a_fflag & FWRITE) {
567                 fip->fi_writers--;
568                 if (fip->fi_writers == 0)
569                         socantrcvmore(fip->fi_readsock);
570         }
571         if (vp->v_sysref.refcnt > 1) {
572                 vop_stdclose(ap);
573                 lwkt_reltoken(&vlock);
574                 return (0);
575         }
576         error1 = soclose(fip->fi_readsock, FNONBLOCK);
577         error2 = soclose(fip->fi_writesock, FNONBLOCK);
578         FREE(fip, M_FIFOINFO);
579         vp->v_fifoinfo = NULL;
580         if (error1) {
581                 error2 = error1;
582         } else {
583                 vop_stdclose(ap);
584         }
585         lwkt_reltoken(&vlock);
586         return (error2);
587 }
588
589
590 /*
591  * Print out internal contents of a fifo vnode.
592  */
593 int
594 fifo_printinfo(struct vnode *vp)
595 {
596         struct fifoinfo *fip = vp->v_fifoinfo;
597
598         kprintf(", fifo with %ld readers and %ld writers",
599                 fip->fi_readers, fip->fi_writers);
600         return (0);
601 }
602
603 /*
604  * Print out the contents of a fifo vnode.
605  *
606  * fifo_print(struct vnode *a_vp)
607  */
608 static int
609 fifo_print(struct vop_print_args *ap)
610 {
611         kprintf("tag VT_NON");
612         fifo_printinfo(ap->a_vp);
613         kprintf("\n");
614         return (0);
615 }
616
617 /*
618  * Return POSIX pathconf information applicable to fifo's.
619  *
620  * fifo_pathconf(struct vnode *a_vp, int a_name, int *a_retval)
621  */
622 int
623 fifo_pathconf(struct vop_pathconf_args *ap)
624 {
625         switch (ap->a_name) {
626         case _PC_LINK_MAX:
627                 *ap->a_retval = LINK_MAX;
628                 return (0);
629         case _PC_PIPE_BUF:
630                 *ap->a_retval = PIPE_BUF;
631                 return (0);
632         case _PC_CHOWN_RESTRICTED:
633                 *ap->a_retval = 1;
634                 return (0);
635         default:
636                 return (EINVAL);
637         }
638         /* NOTREACHED */
639 }
640
641 /*
642  * Fifo advisory byte-level locks.
643  *
644  * fifo_advlock(struct vnode *a_vp, caddr_t a_id, int a_op, struct flock *a_fl,
645  *              int a_flags)
646  */
647 /* ARGSUSED */
648 static int
649 fifo_advlock(struct vop_advlock_args *ap)
650 {
651         return ((ap->a_flags & F_POSIX) ? EINVAL : EOPNOTSUPP);
652 }
653
654 /*
655  * Fifo bad operation
656  */
657 static int
658 fifo_badop(void)
659 {
660         panic("fifo_badop called");
661         /* NOTREACHED */
662 }