VFS messaging/interfacing work stage 1/99. This stage replaces the old
[dragonfly.git] / sys / vfs / fifofs / fifo_vnops.c
CommitLineData
984263bc
MD
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 * @(#)fifo_vnops.c 8.10 (Berkeley) 5/27/95
34 * $FreeBSD: src/sys/miscfs/fifofs/fifo_vnops.c,v 1.45.2.4 2003/04/22 10:11:24 bde Exp $
2d3e977e 35 * $DragonFly: src/sys/vfs/fifofs/fifo_vnops.c,v 1.15 2004/08/13 17:51:10 dillon Exp $
984263bc
MD
36 */
37
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/unistd.h>
41#include <sys/kernel.h>
42#include <sys/lock.h>
43#include <sys/malloc.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>
1f2de5d4 53#include "fifo.h"
984263bc
MD
54
55/*
56 * This structure is associated with the FIFO vnode and stores
57 * the state associated with the FIFO.
58 */
59struct fifoinfo {
60 struct socket *fi_readsock;
61 struct socket *fi_writesock;
62 long fi_readers;
63 long fi_writers;
64};
65
a6ee311a
RG
66static int fifo_badop (void);
67static int fifo_print (struct vop_print_args *);
68static int fifo_lookup (struct vop_lookup_args *);
69static int fifo_open (struct vop_open_args *);
70static int fifo_close (struct vop_close_args *);
71static int fifo_read (struct vop_read_args *);
72static int fifo_write (struct vop_write_args *);
73static int fifo_ioctl (struct vop_ioctl_args *);
74static int fifo_poll (struct vop_poll_args *);
75static int fifo_kqfilter (struct vop_kqfilter_args *);
76static int fifo_inactive (struct vop_inactive_args *);
77static int fifo_bmap (struct vop_bmap_args *);
78static int fifo_pathconf (struct vop_pathconf_args *);
79static int fifo_advlock (struct vop_advlock_args *);
984263bc
MD
80
81static void filt_fifordetach(struct knote *kn);
82static int filt_fiforead(struct knote *kn, long hint);
83static void filt_fifowdetach(struct knote *kn);
84static int filt_fifowrite(struct knote *kn, long hint);
85
86static struct filterops fiforead_filtops =
87 { 1, NULL, filt_fifordetach, filt_fiforead };
88static struct filterops fifowrite_filtops =
89 { 1, NULL, filt_fifowdetach, filt_fifowrite };
90
2d3e977e 91struct vop_ops *fifo_vnode_vops;
984263bc 92static struct vnodeopv_entry_desc fifo_vnodeop_entries[] = {
2d3e977e
MD
93 { &vop_default_desc, (void *) vop_defaultop },
94 { &vop_access_desc, (void *) vop_ebadf },
95 { &vop_advlock_desc, (void *) fifo_advlock },
96 { &vop_bmap_desc, (void *) fifo_bmap },
97 { &vop_close_desc, (void *) fifo_close },
98 { &vop_create_desc, (void *) fifo_badop },
99 { &vop_getattr_desc, (void *) vop_ebadf },
100 { &vop_inactive_desc, (void *) fifo_inactive },
101 { &vop_ioctl_desc, (void *) fifo_ioctl },
102 { &vop_kqfilter_desc, (void *) fifo_kqfilter },
103 { &vop_lease_desc, (void *) vop_null },
104 { &vop_link_desc, (void *) fifo_badop },
105 { &vop_lookup_desc, (void *) fifo_lookup },
106 { &vop_mkdir_desc, (void *) fifo_badop },
107 { &vop_mknod_desc, (void *) fifo_badop },
108 { &vop_open_desc, (void *) fifo_open },
109 { &vop_pathconf_desc, (void *) fifo_pathconf },
110 { &vop_poll_desc, (void *) fifo_poll },
111 { &vop_print_desc, (void *) fifo_print },
112 { &vop_read_desc, (void *) fifo_read },
113 { &vop_readdir_desc, (void *) fifo_badop },
114 { &vop_readlink_desc, (void *) fifo_badop },
115 { &vop_reallocblks_desc, (void *) fifo_badop },
116 { &vop_reclaim_desc, (void *) vop_null },
117 { &vop_remove_desc, (void *) fifo_badop },
118 { &vop_rename_desc, (void *) fifo_badop },
119 { &vop_rmdir_desc, (void *) fifo_badop },
120 { &vop_setattr_desc, (void *) vop_ebadf },
121 { &vop_symlink_desc, (void *) fifo_badop },
122 { &vop_write_desc, (void *) fifo_write },
984263bc
MD
123 { NULL, NULL }
124};
125static struct vnodeopv_desc fifo_vnodeop_opv_desc =
2d3e977e 126 { &fifo_vnode_vops, fifo_vnodeop_entries };
984263bc
MD
127
128VNODEOP_SET(fifo_vnodeop_opv_desc);
129
b5f12e21
CP
130/*
131 * fifo_vnoperate(struct vnodeop_desc *a_desc, ...)
132 */
984263bc 133int
b5f12e21 134fifo_vnoperate(struct vop_generic_args *ap)
984263bc 135{
2d3e977e 136 return (VOCALL(fifo_vnode_vops, ap->a_desc->vdesc_offset, ap));
984263bc
MD
137}
138
139/*
140 * Trivial lookup routine that always fails.
b5f12e21
CP
141 *
142 * fifo_lookup(struct vnode *a_dvp, struct vnode **a_vpp,
143 * struct componentname *a_cnp)
984263bc
MD
144 */
145/* ARGSUSED */
146static int
b5f12e21 147fifo_lookup(struct vop_lookup_args *ap)
984263bc 148{
984263bc
MD
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.
b5f12e21
CP
156 *
157 * fifo_open(struct vnode *a_vp, int a_mode, struct ucred *a_cred,
158 * struct thread *a_td)
984263bc
MD
159 */
160/* ARGSUSED */
161static int
b5f12e21 162fifo_open(struct vop_open_args *ap)
984263bc
MD
163{
164 struct vnode *vp = ap->a_vp;
165 struct fifoinfo *fip;
984263bc
MD
166 struct socket *rso, *wso;
167 int error;
168
169 if ((fip = vp->v_fifoinfo) == NULL) {
170 MALLOC(fip, struct fifoinfo *, sizeof(*fip), M_VNODE, M_WAITOK);
171 vp->v_fifoinfo = fip;
dadab5e9 172 error = socreate(AF_LOCAL, &rso, SOCK_STREAM, 0, ap->a_td);
984263bc
MD
173 if (error) {
174 free(fip, M_VNODE);
175 vp->v_fifoinfo = NULL;
176 return (error);
177 }
178 fip->fi_readsock = rso;
dadab5e9 179 error = socreate(AF_LOCAL, &wso, SOCK_STREAM, 0, ap->a_td);
984263bc
MD
180 if (error) {
181 (void)soclose(rso);
182 free(fip, M_VNODE);
183 vp->v_fifoinfo = NULL;
184 return (error);
185 }
186 fip->fi_writesock = wso;
187 error = unp_connect2(wso, rso);
188 if (error) {
189 (void)soclose(wso);
190 (void)soclose(rso);
191 free(fip, M_VNODE);
192 vp->v_fifoinfo = NULL;
193 return (error);
194 }
195 fip->fi_readers = fip->fi_writers = 0;
196 wso->so_snd.sb_lowat = PIPE_BUF;
197 rso->so_state |= SS_CANTRCVMORE;
198 }
199 if (ap->a_mode & FREAD) {
200 fip->fi_readers++;
201 if (fip->fi_readers == 1) {
202 fip->fi_writesock->so_state &= ~SS_CANTSENDMORE;
203 if (fip->fi_writers > 0) {
204 wakeup((caddr_t)&fip->fi_writers);
205 sowwakeup(fip->fi_writesock);
206 }
207 }
208 }
209 if (ap->a_mode & FWRITE) {
210 fip->fi_writers++;
211 if (fip->fi_writers == 1) {
212 fip->fi_readsock->so_state &= ~SS_CANTRCVMORE;
213 if (fip->fi_readers > 0) {
214 wakeup((caddr_t)&fip->fi_readers);
215 sorwakeup(fip->fi_writesock);
216 }
217 }
218 }
219 if ((ap->a_mode & FREAD) && (ap->a_mode & O_NONBLOCK) == 0) {
220 if (fip->fi_writers == 0) {
41a01a4d 221 VOP_UNLOCK(vp, NULL, 0, ap->a_td);
984263bc 222 error = tsleep((caddr_t)&fip->fi_readers,
377d4740 223 PCATCH, "fifoor", 0);
41a01a4d 224 vn_lock(vp, NULL, LK_EXCLUSIVE | LK_RETRY, ap->a_td);
984263bc
MD
225 if (error)
226 goto bad;
227 /*
228 * We must have got woken up because we had a writer.
229 * That (and not still having one) is the condition
230 * that we must wait for.
231 */
232 }
233 }
234 if (ap->a_mode & FWRITE) {
235 if (ap->a_mode & O_NONBLOCK) {
236 if (fip->fi_readers == 0) {
237 error = ENXIO;
238 goto bad;
239 }
240 } else {
241 if (fip->fi_readers == 0) {
41a01a4d 242 VOP_UNLOCK(vp, NULL, 0, ap->a_td);
984263bc 243 error = tsleep((caddr_t)&fip->fi_writers,
377d4740 244 PCATCH, "fifoow", 0);
41a01a4d 245 vn_lock(vp, NULL, LK_EXCLUSIVE | LK_RETRY, ap->a_td);
984263bc
MD
246 if (error)
247 goto bad;
248 /*
249 * We must have got woken up because we had
250 * a reader. That (and not still having one)
251 * is the condition that we must wait for.
252 */
253 }
254 }
255 }
256 return (0);
257bad:
3b568787 258 VOP_CLOSE(vp, ap->a_mode, ap->a_td);
984263bc
MD
259 return (error);
260}
261
262/*
263 * Vnode op for read
b5f12e21
CP
264 *
265 * fifo_read(struct vnode *a_vp, struct uio *a_uio, int a_ioflag,
266 * struct ucred *a_cred)
984263bc
MD
267 */
268/* ARGSUSED */
269static int
b5f12e21 270fifo_read(struct vop_read_args *ap)
984263bc
MD
271{
272 struct uio *uio = ap->a_uio;
273 struct socket *rso = ap->a_vp->v_fifoinfo->fi_readsock;
dadab5e9 274 struct thread *td = uio->uio_td;
984263bc
MD
275 int error, startresid;
276
277#ifdef DIAGNOSTIC
278 if (uio->uio_rw != UIO_READ)
279 panic("fifo_read mode");
280#endif
281 if (uio->uio_resid == 0)
282 return (0);
283 if (ap->a_ioflag & IO_NDELAY)
284 rso->so_state |= SS_NBIO;
285 startresid = uio->uio_resid;
41a01a4d 286 VOP_UNLOCK(ap->a_vp, NULL, 0, td);
984263bc
MD
287 error = soreceive(rso, (struct sockaddr **)0, uio, (struct mbuf **)0,
288 (struct mbuf **)0, (int *)0);
41a01a4d 289 vn_lock(ap->a_vp, NULL, LK_EXCLUSIVE | LK_RETRY, td);
984263bc
MD
290 if (ap->a_ioflag & IO_NDELAY)
291 rso->so_state &= ~SS_NBIO;
292 return (error);
293}
294
295/*
296 * Vnode op for write
b5f12e21
CP
297 *
298 * fifo_write(struct vnode *a_vp, struct uio *a_uio, int a_ioflag,
299 * struct ucred *a_cred)
984263bc
MD
300 */
301/* ARGSUSED */
302static int
b5f12e21 303fifo_write(struct vop_write_args *ap)
984263bc
MD
304{
305 struct socket *wso = ap->a_vp->v_fifoinfo->fi_writesock;
dadab5e9 306 struct thread *td = ap->a_uio->uio_td;
984263bc
MD
307 int error;
308
309#ifdef DIAGNOSTIC
310 if (ap->a_uio->uio_rw != UIO_WRITE)
311 panic("fifo_write mode");
312#endif
313 if (ap->a_ioflag & IO_NDELAY)
314 wso->so_state |= SS_NBIO;
41a01a4d 315 VOP_UNLOCK(ap->a_vp, NULL, 0, td);
984263bc 316 error = sosend(wso, (struct sockaddr *)0, ap->a_uio, 0,
dadab5e9 317 (struct mbuf *)0, 0, td);
41a01a4d 318 vn_lock(ap->a_vp, NULL, LK_EXCLUSIVE | LK_RETRY, td);
984263bc
MD
319 if (ap->a_ioflag & IO_NDELAY)
320 wso->so_state &= ~SS_NBIO;
321 return (error);
322}
323
324/*
325 * Device ioctl operation.
b5f12e21
CP
326 *
327 * fifo_ioctl(struct vnode *a_vp, int a_command, caddr_t a_data, int a_fflag,
328 * struct ucred *a_cred, struct thread *a_td)
984263bc
MD
329 */
330/* ARGSUSED */
331static int
b5f12e21 332fifo_ioctl(struct vop_ioctl_args *ap)
984263bc 333{
9443ca22 334 struct file filetmp; /* Local */
984263bc
MD
335 int error;
336
337 if (ap->a_command == FIONBIO)
338 return (0);
339 if (ap->a_fflag & FREAD) {
340 filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_readsock;
dadab5e9 341 error = soo_ioctl(&filetmp, ap->a_command, ap->a_data, ap->a_td);
984263bc
MD
342 if (error)
343 return (error);
344 }
345 if (ap->a_fflag & FWRITE) {
346 filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_writesock;
dadab5e9 347 error = soo_ioctl(&filetmp, ap->a_command, ap->a_data, ap->a_td);
984263bc
MD
348 if (error)
349 return (error);
350 }
351 return (0);
352}
353
b5f12e21
CP
354/*
355 * fifo_kqfilter(struct vnode *a_vp, struct knote *a_kn)
356 */
984263bc
MD
357/* ARGSUSED */
358static int
b5f12e21 359fifo_kqfilter(struct vop_kqfilter_args *ap)
984263bc
MD
360{
361 struct fifoinfo *fi = ap->a_vp->v_fifoinfo;
362 struct socket *so;
363 struct sockbuf *sb;
364
365 switch (ap->a_kn->kn_filter) {
366 case EVFILT_READ:
367 ap->a_kn->kn_fop = &fiforead_filtops;
368 so = fi->fi_readsock;
369 sb = &so->so_rcv;
370 break;
371 case EVFILT_WRITE:
372 ap->a_kn->kn_fop = &fifowrite_filtops;
373 so = fi->fi_writesock;
374 sb = &so->so_snd;
375 break;
376 default:
377 return (1);
378 }
379
380 ap->a_kn->kn_hook = (caddr_t)so;
381
382 SLIST_INSERT_HEAD(&sb->sb_sel.si_note, ap->a_kn, kn_selnext);
383 sb->sb_flags |= SB_KNOTE;
384
385 return (0);
386}
387
388static void
389filt_fifordetach(struct knote *kn)
390{
391 struct socket *so = (struct socket *)kn->kn_hook;
392
393 SLIST_REMOVE(&so->so_rcv.sb_sel.si_note, kn, knote, kn_selnext);
394 if (SLIST_EMPTY(&so->so_rcv.sb_sel.si_note))
395 so->so_rcv.sb_flags &= ~SB_KNOTE;
396}
397
398static int
399filt_fiforead(struct knote *kn, long hint)
400{
401 struct socket *so = (struct socket *)kn->kn_hook;
402
403 kn->kn_data = so->so_rcv.sb_cc;
404 if (so->so_state & SS_CANTRCVMORE) {
405 kn->kn_flags |= EV_EOF;
406 return (1);
407 }
408 kn->kn_flags &= ~EV_EOF;
409 return (kn->kn_data > 0);
410}
411
412static void
413filt_fifowdetach(struct knote *kn)
414{
415 struct socket *so = (struct socket *)kn->kn_hook;
416
417 SLIST_REMOVE(&so->so_snd.sb_sel.si_note, kn, knote, kn_selnext);
418 if (SLIST_EMPTY(&so->so_snd.sb_sel.si_note))
419 so->so_snd.sb_flags &= ~SB_KNOTE;
420}
421
422static int
423filt_fifowrite(struct knote *kn, long hint)
424{
425 struct socket *so = (struct socket *)kn->kn_hook;
426
427 kn->kn_data = sbspace(&so->so_snd);
428 if (so->so_state & SS_CANTSENDMORE) {
429 kn->kn_flags |= EV_EOF;
430 return (1);
431 }
432 kn->kn_flags &= ~EV_EOF;
433 return (kn->kn_data >= so->so_snd.sb_lowat);
434}
435
b5f12e21
CP
436/*
437 * fifo_poll(struct vnode *a_vp, int a_events, struct ucred *a_cred,
438 * struct thread *a_td)
439 */
984263bc
MD
440/* ARGSUSED */
441static int
b5f12e21 442fifo_poll(struct vop_poll_args *ap)
984263bc
MD
443{
444 struct file filetmp;
d08a3c4d
HP
445 int events, revents = 0;
446
630a348c 447 events = ap->a_events &
9443ca22 448 (POLLIN | POLLINIGNEOF | POLLPRI | POLLRDNORM | POLLRDBAND);
d08a3c4d
HP
449 if (events) {
450 /*
9443ca22
HP
451 * If POLLIN or POLLRDNORM is requested and POLLINIGNEOF is
452 * not, then convert the first two to the last one. This
453 * tells the socket poll function to ignore EOF so that we
454 * block if there is no writer (and no data). Callers can
455 * set POLLINIGNEOF to get non-blocking behavior.
d08a3c4d 456 */
ad4bd3a5
HP
457 if (events & (POLLIN | POLLRDNORM) &&
458 !(events & POLLINIGNEOF)) {
d08a3c4d
HP
459 events &= ~(POLLIN | POLLRDNORM);
460 events |= POLLINIGNEOF;
461 }
9443ca22 462
984263bc
MD
463 filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_readsock;
464 if (filetmp.f_data)
d08a3c4d 465 revents |= soo_poll(&filetmp, events, ap->a_cred,
dadab5e9 466 ap->a_td);
d08a3c4d 467
9443ca22
HP
468 /* Reverse the above conversion. */
469 if ((revents & POLLINIGNEOF) &&
470 !(ap->a_events & POLLINIGNEOF)) {
471 revents |= (ap->a_events & (POLLIN | POLLRDNORM));
d08a3c4d 472 revents &= ~POLLINIGNEOF;
d08a3c4d 473 }
984263bc 474 }
d08a3c4d
HP
475 events = ap->a_events & (POLLOUT | POLLWRNORM | POLLWRBAND);
476 if (events) {
984263bc
MD
477 filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_writesock;
478 if (filetmp.f_data)
d08a3c4d 479 revents |= soo_poll(&filetmp, events, ap->a_cred,
dadab5e9 480 ap->a_td);
984263bc
MD
481 }
482 return (revents);
483}
484
b5f12e21
CP
485/*
486 * fifo_inactive(struct vnode *a_vp, struct thread *a_td)
487 */
984263bc 488static int
b5f12e21 489fifo_inactive(struct vop_inactive_args *ap)
984263bc 490{
41a01a4d 491 VOP_UNLOCK(ap->a_vp, NULL, 0, ap->a_td);
984263bc
MD
492 return (0);
493}
494
495/*
496 * This is a noop, simply returning what one has been given.
b5f12e21
CP
497 *
498 * fifo_bmap(struct vnode *a_vp, daddr_t a_bn, struct vnode **a_vpp,
499 * daddr_t *a_bnp, int *a_runp, int *a_runb)
984263bc
MD
500 */
501static int
b5f12e21 502fifo_bmap(struct vop_bmap_args *ap)
984263bc 503{
984263bc
MD
504 if (ap->a_vpp != NULL)
505 *ap->a_vpp = ap->a_vp;
506 if (ap->a_bnp != NULL)
507 *ap->a_bnp = ap->a_bn;
508 if (ap->a_runp != NULL)
509 *ap->a_runp = 0;
510 if (ap->a_runb != NULL)
511 *ap->a_runb = 0;
512 return (0);
513}
514
515/*
516 * Device close routine
b5f12e21
CP
517 *
518 * fifo_close(struct vnode *a_vp, int a_fflag, struct ucred *a_cred,
519 * struct thread *a_td)
984263bc
MD
520 */
521/* ARGSUSED */
522static int
b5f12e21 523fifo_close(struct vop_close_args *ap)
984263bc 524{
0e99e805
RG
525 struct vnode *vp = ap->a_vp;
526 struct fifoinfo *fip = vp->v_fifoinfo;
984263bc
MD
527 int error1, error2;
528
529 if (ap->a_fflag & FREAD) {
530 fip->fi_readers--;
531 if (fip->fi_readers == 0)
532 socantsendmore(fip->fi_writesock);
533 }
534 if (ap->a_fflag & FWRITE) {
535 fip->fi_writers--;
536 if (fip->fi_writers == 0)
537 socantrcvmore(fip->fi_readsock);
538 }
539 if (vp->v_usecount > 1)
540 return (0);
541 error1 = soclose(fip->fi_readsock);
542 error2 = soclose(fip->fi_writesock);
543 FREE(fip, M_VNODE);
544 vp->v_fifoinfo = NULL;
545 if (error1)
546 return (error1);
547 return (error2);
548}
549
550
551/*
552 * Print out internal contents of a fifo vnode.
553 */
554int
b5f12e21 555fifo_printinfo(struct vnode *vp)
984263bc 556{
0e99e805 557 struct fifoinfo *fip = vp->v_fifoinfo;
984263bc
MD
558
559 printf(", fifo with %ld readers and %ld writers",
560 fip->fi_readers, fip->fi_writers);
561 return (0);
562}
563
564/*
565 * Print out the contents of a fifo vnode.
b5f12e21
CP
566 *
567 * fifo_print(struct vnode *a_vp)
984263bc
MD
568 */
569static int
b5f12e21 570fifo_print(struct vop_print_args *ap)
984263bc 571{
984263bc
MD
572 printf("tag VT_NON");
573 fifo_printinfo(ap->a_vp);
574 printf("\n");
575 return (0);
576}
577
578/*
579 * Return POSIX pathconf information applicable to fifo's.
b5f12e21
CP
580 *
581 * fifo_pathconf(struct vnode *a_vp, int a_name, int *a_retval)
984263bc
MD
582 */
583int
b5f12e21 584fifo_pathconf(struct vop_pathconf_args *ap)
984263bc 585{
984263bc
MD
586 switch (ap->a_name) {
587 case _PC_LINK_MAX:
588 *ap->a_retval = LINK_MAX;
589 return (0);
590 case _PC_PIPE_BUF:
591 *ap->a_retval = PIPE_BUF;
592 return (0);
593 case _PC_CHOWN_RESTRICTED:
594 *ap->a_retval = 1;
595 return (0);
596 default:
597 return (EINVAL);
598 }
599 /* NOTREACHED */
600}
601
602/*
603 * Fifo advisory byte-level locks.
b5f12e21
CP
604 *
605 * fifo_advlock(struct vnode *a_vp, caddr_t a_id, int a_op, struct flock *a_fl,
606 * int a_flags)
984263bc
MD
607 */
608/* ARGSUSED */
609static int
b5f12e21 610fifo_advlock(struct vop_advlock_args *ap)
984263bc 611{
984263bc
MD
612 return (ap->a_flags & F_FLOCK ? EOPNOTSUPP : EINVAL);
613}
614
615/*
616 * Fifo bad operation
617 */
618static int
b5f12e21 619fifo_badop(void)
984263bc 620{
984263bc
MD
621 panic("fifo_badop called");
622 /* NOTREACHED */
623}