kernel - Tear out vfs polling
[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.
984263bc 32 */
aac0aabd
MD
33/*
34 * Filesystem FIFO type ops. All entry points are MPSAFE. We primarily
35 * use v_token to interlock operations.
36 */
984263bc
MD
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>
87de5057 43#include <sys/thread2.h>
984263bc
MD
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>
984263bc 51#include <sys/un.h>
87de5057
MD
52
53#include <sys/thread2.h>
54
1f2de5d4 55#include "fifo.h"
984263bc
MD
56
57/*
58 * This structure is associated with the FIFO vnode and stores
59 * the state associated with the FIFO.
60 */
61struct fifoinfo {
62 struct socket *fi_readsock;
63 struct socket *fi_writesock;
64 long fi_readers;
65 long fi_writers;
66};
67
a6ee311a
RG
68static int fifo_badop (void);
69static int fifo_print (struct vop_print_args *);
e62afb5f 70static int fifo_lookup (struct vop_old_lookup_args *);
a6ee311a
RG
71static int fifo_open (struct vop_open_args *);
72static int fifo_close (struct vop_close_args *);
73static int fifo_read (struct vop_read_args *);
74static int fifo_write (struct vop_write_args *);
75static int fifo_ioctl (struct vop_ioctl_args *);
a6ee311a
RG
76static int fifo_kqfilter (struct vop_kqfilter_args *);
77static int fifo_inactive (struct vop_inactive_args *);
78static int fifo_bmap (struct vop_bmap_args *);
79static int fifo_pathconf (struct vop_pathconf_args *);
80static int fifo_advlock (struct vop_advlock_args *);
984263bc
MD
81
82static void filt_fifordetach(struct knote *kn);
83static int filt_fiforead(struct knote *kn, long hint);
84static void filt_fifowdetach(struct knote *kn);
85static int filt_fifowrite(struct knote *kn, long hint);
86
87static struct filterops fiforead_filtops =
88 { 1, NULL, filt_fifordetach, filt_fiforead };
89static struct filterops fifowrite_filtops =
90 { 1, NULL, filt_fifowdetach, filt_fifowrite };
91
66a1ddf5
MD
92struct vop_ops fifo_vnode_vops = {
93 .vop_default = vop_defaultop,
94 .vop_access = (void *)vop_ebadf,
95 .vop_advlock = fifo_advlock,
96 .vop_bmap = fifo_bmap,
97 .vop_close = fifo_close,
98 .vop_old_create = (void *)fifo_badop,
99 .vop_getattr = (void *)vop_ebadf,
100 .vop_inactive = fifo_inactive,
101 .vop_ioctl = fifo_ioctl,
102 .vop_kqfilter = fifo_kqfilter,
103 .vop_old_link = (void *)fifo_badop,
104 .vop_old_lookup = fifo_lookup,
105 .vop_old_mkdir = (void *)fifo_badop,
106 .vop_old_mknod = (void *)fifo_badop,
107 .vop_open = fifo_open,
108 .vop_pathconf = fifo_pathconf,
66a1ddf5
MD
109 .vop_print = fifo_print,
110 .vop_read = fifo_read,
111 .vop_readdir = (void *)fifo_badop,
112 .vop_readlink = (void *)fifo_badop,
113 .vop_reallocblks = (void *)fifo_badop,
114 .vop_reclaim = (void *)vop_null,
115 .vop_old_remove = (void *)fifo_badop,
116 .vop_old_rename = (void *)fifo_badop,
117 .vop_old_rmdir = (void *)fifo_badop,
118 .vop_setattr = (void *)vop_ebadf,
119 .vop_old_symlink = (void *)fifo_badop,
120 .vop_write = fifo_write
984263bc 121};
984263bc 122
66a1ddf5 123VNODEOP_SET(fifo_vnode_vops);
984263bc 124
5fd012e0
MD
125static MALLOC_DEFINE(M_FIFOINFO, "Fifo info", "Fifo info entries");
126
b5f12e21 127/*
31bd717a 128 * fifo_vnoperate()
b5f12e21 129 */
984263bc 130int
b5f12e21 131fifo_vnoperate(struct vop_generic_args *ap)
984263bc 132{
66a1ddf5 133 return (VOCALL(&fifo_vnode_vops, ap));
984263bc
MD
134}
135
136/*
137 * Trivial lookup routine that always fails.
b5f12e21
CP
138 *
139 * fifo_lookup(struct vnode *a_dvp, struct vnode **a_vpp,
140 * struct componentname *a_cnp)
984263bc
MD
141 */
142/* ARGSUSED */
143static int
e62afb5f 144fifo_lookup(struct vop_old_lookup_args *ap)
984263bc 145{
984263bc
MD
146 *ap->a_vpp = NULL;
147 return (ENOTDIR);
148}
149
150/*
151 * Open called to set up a new instance of a fifo or
152 * to find an active instance of a fifo.
b5f12e21
CP
153 *
154 * fifo_open(struct vnode *a_vp, int a_mode, struct ucred *a_cred,
b478fdce 155 * struct file *a_fp)
984263bc
MD
156 */
157/* ARGSUSED */
158static int
b5f12e21 159fifo_open(struct vop_open_args *ap)
984263bc 160{
87de5057 161 struct thread *td = curthread;
984263bc
MD
162 struct vnode *vp = ap->a_vp;
163 struct fifoinfo *fip;
984263bc
MD
164 struct socket *rso, *wso;
165 int error;
166
3b998fa9 167 lwkt_gettoken(&vp->v_token);
984263bc 168 if ((fip = vp->v_fifoinfo) == NULL) {
5fd012e0 169 MALLOC(fip, struct fifoinfo *, sizeof(*fip), M_FIFOINFO, M_WAITOK);
984263bc 170 vp->v_fifoinfo = fip;
87de5057 171 error = socreate(AF_LOCAL, &rso, SOCK_STREAM, 0, td);
984263bc 172 if (error) {
efda3bd0 173 kfree(fip, M_FIFOINFO);
984263bc 174 vp->v_fifoinfo = NULL;
aac0aabd 175 goto done;
984263bc
MD
176 }
177 fip->fi_readsock = rso;
87de5057 178 error = socreate(AF_LOCAL, &wso, SOCK_STREAM, 0, td);
984263bc 179 if (error) {
9ba76b73 180 soclose(rso, FNONBLOCK);
efda3bd0 181 kfree(fip, M_FIFOINFO);
984263bc 182 vp->v_fifoinfo = NULL;
aac0aabd 183 goto done;
984263bc
MD
184 }
185 fip->fi_writesock = wso;
186 error = unp_connect2(wso, rso);
187 if (error) {
9ba76b73
MD
188 soclose(wso, FNONBLOCK);
189 soclose(rso, FNONBLOCK);
efda3bd0 190 kfree(fip, M_FIFOINFO);
984263bc 191 vp->v_fifoinfo = NULL;
aac0aabd 192 goto done;
984263bc
MD
193 }
194 fip->fi_readers = fip->fi_writers = 0;
6d49aa6f 195 wso->so_snd.ssb_lowat = PIPE_BUF;
984263bc
MD
196 rso->so_state |= SS_CANTRCVMORE;
197 }
198 if (ap->a_mode & FREAD) {
199 fip->fi_readers++;
200 if (fip->fi_readers == 1) {
201 fip->fi_writesock->so_state &= ~SS_CANTSENDMORE;
202 if (fip->fi_writers > 0) {
203 wakeup((caddr_t)&fip->fi_writers);
204 sowwakeup(fip->fi_writesock);
205 }
206 }
207 }
208 if (ap->a_mode & FWRITE) {
209 fip->fi_writers++;
210 if (fip->fi_writers == 1) {
211 fip->fi_readsock->so_state &= ~SS_CANTRCVMORE;
212 if (fip->fi_readers > 0) {
213 wakeup((caddr_t)&fip->fi_readers);
214 sorwakeup(fip->fi_writesock);
215 }
216 }
217 }
218 if ((ap->a_mode & FREAD) && (ap->a_mode & O_NONBLOCK) == 0) {
219 if (fip->fi_writers == 0) {
a11aaa81 220 vn_unlock(vp);
984263bc 221 error = tsleep((caddr_t)&fip->fi_readers,
377d4740 222 PCATCH, "fifoor", 0);
ca466bae 223 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
984263bc
MD
224 if (error)
225 goto bad;
226 /*
227 * We must have got woken up because we had a writer.
228 * That (and not still having one) is the condition
229 * that we must wait for.
230 */
231 }
232 }
233 if (ap->a_mode & FWRITE) {
234 if (ap->a_mode & O_NONBLOCK) {
235 if (fip->fi_readers == 0) {
236 error = ENXIO;
237 goto bad;
238 }
239 } else {
240 if (fip->fi_readers == 0) {
a11aaa81 241 vn_unlock(vp);
984263bc 242 error = tsleep((caddr_t)&fip->fi_writers,
377d4740 243 PCATCH, "fifoow", 0);
ca466bae 244 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
984263bc
MD
245 if (error)
246 goto bad;
247 /*
248 * We must have got woken up because we had
249 * a reader. That (and not still having one)
250 * is the condition that we must wait for.
251 */
252 }
253 }
254 }
2247fe02 255 vsetflags(vp, VNOTSEEKABLE);
aac0aabd 256 error = vop_stdopen(ap);
3b998fa9 257 lwkt_reltoken(&vp->v_token);
aac0aabd 258 return (error);
984263bc 259bad:
cbeb1f72 260 vop_stdopen(ap); /* bump opencount/writecount as appropriate */
87de5057 261 VOP_CLOSE(vp, ap->a_mode);
aac0aabd 262done:
3b998fa9 263 lwkt_reltoken(&vp->v_token);
984263bc
MD
264 return (error);
265}
266
267/*
268 * Vnode op for read
b5f12e21
CP
269 *
270 * fifo_read(struct vnode *a_vp, struct uio *a_uio, int a_ioflag,
271 * struct ucred *a_cred)
984263bc
MD
272 */
273/* ARGSUSED */
274static int
b5f12e21 275fifo_read(struct vop_read_args *ap)
984263bc
MD
276{
277 struct uio *uio = ap->a_uio;
3b998fa9
MD
278 struct vnode *vp = ap->a_vp;
279 struct socket *rso = vp->v_fifoinfo->fi_readsock;
984263bc 280 int error, startresid;
9ba76b73 281 int flags;
984263bc
MD
282
283#ifdef DIAGNOSTIC
284 if (uio->uio_rw != UIO_READ)
285 panic("fifo_read mode");
286#endif
287 if (uio->uio_resid == 0)
288 return (0);
289 if (ap->a_ioflag & IO_NDELAY)
9ba76b73
MD
290 flags = MSG_FNONBLOCKING;
291 else
292 flags = 0;
984263bc 293 startresid = uio->uio_resid;
3b998fa9
MD
294 vn_unlock(vp);
295 lwkt_gettoken(&vp->v_token);
d8a9a23b 296 error = soreceive(rso, NULL, uio, NULL, NULL, &flags);
3b998fa9
MD
297 lwkt_reltoken(&vp->v_token);
298 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
984263bc
MD
299 return (error);
300}
301
302/*
303 * Vnode op for write
b5f12e21
CP
304 *
305 * fifo_write(struct vnode *a_vp, struct uio *a_uio, int a_ioflag,
306 * struct ucred *a_cred)
984263bc
MD
307 */
308/* ARGSUSED */
309static int
b5f12e21 310fifo_write(struct vop_write_args *ap)
984263bc 311{
dadab5e9 312 struct thread *td = ap->a_uio->uio_td;
3b998fa9
MD
313 struct vnode *vp = ap->a_vp;
314 struct socket *wso = vp->v_fifoinfo->fi_writesock;
984263bc 315 int error;
9ba76b73 316 int flags;
984263bc
MD
317
318#ifdef DIAGNOSTIC
319 if (ap->a_uio->uio_rw != UIO_WRITE)
320 panic("fifo_write mode");
321#endif
322 if (ap->a_ioflag & IO_NDELAY)
9ba76b73
MD
323 flags = MSG_FNONBLOCKING;
324 else
325 flags = 0;
3b998fa9
MD
326 vn_unlock(vp);
327 lwkt_gettoken(&vp->v_token);
60233e58 328 error = sosend(wso, NULL, ap->a_uio, 0, NULL, flags, td);
3b998fa9
MD
329 lwkt_reltoken(&vp->v_token);
330 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
984263bc
MD
331 return (error);
332}
333
334/*
335 * Device ioctl operation.
b5f12e21
CP
336 *
337 * fifo_ioctl(struct vnode *a_vp, int a_command, caddr_t a_data, int a_fflag,
87baaf0c 338 * struct ucred *a_cred, struct sysmsg *a_sysmsg)
984263bc
MD
339 */
340/* ARGSUSED */
341static int
b5f12e21 342fifo_ioctl(struct vop_ioctl_args *ap)
984263bc 343{
9443ca22 344 struct file filetmp; /* Local */
3b998fa9 345 struct vnode *vp = ap->a_vp;
984263bc
MD
346 int error;
347
984263bc 348 if (ap->a_fflag & FREAD) {
3b998fa9
MD
349 filetmp.f_data = vp->v_fifoinfo->fi_readsock;
350 lwkt_gettoken(&vp->v_token);
87baaf0c
MD
351 error = soo_ioctl(&filetmp, ap->a_command, ap->a_data,
352 ap->a_cred, ap->a_sysmsg);
3b998fa9 353 lwkt_reltoken(&vp->v_token);
984263bc
MD
354 if (error)
355 return (error);
356 }
357 if (ap->a_fflag & FWRITE) {
3b998fa9
MD
358 filetmp.f_data = vp->v_fifoinfo->fi_writesock;
359 lwkt_gettoken(&vp->v_token);
87baaf0c
MD
360 error = soo_ioctl(&filetmp, ap->a_command, ap->a_data,
361 ap->a_cred, ap->a_sysmsg);
3b998fa9 362 lwkt_reltoken(&vp->v_token);
984263bc
MD
363 if (error)
364 return (error);
365 }
366 return (0);
367}
368
b5f12e21
CP
369/*
370 * fifo_kqfilter(struct vnode *a_vp, struct knote *a_kn)
371 */
984263bc
MD
372/* ARGSUSED */
373static int
b5f12e21 374fifo_kqfilter(struct vop_kqfilter_args *ap)
984263bc 375{
aac0aabd
MD
376 struct vnode *vp = ap->a_vp;
377 struct fifoinfo *fi = vp->v_fifoinfo;
984263bc 378 struct socket *so;
6d49aa6f 379 struct signalsockbuf *ssb;
984263bc 380
3b998fa9 381 lwkt_gettoken(&vp->v_token);
b58e725b 382
984263bc
MD
383 switch (ap->a_kn->kn_filter) {
384 case EVFILT_READ:
385 ap->a_kn->kn_fop = &fiforead_filtops;
386 so = fi->fi_readsock;
6d49aa6f 387 ssb = &so->so_rcv;
984263bc
MD
388 break;
389 case EVFILT_WRITE:
390 ap->a_kn->kn_fop = &fifowrite_filtops;
391 so = fi->fi_writesock;
6d49aa6f 392 ssb = &so->so_snd;
984263bc
MD
393 break;
394 default:
3b998fa9 395 lwkt_reltoken(&vp->v_token);
b287d649 396 return (EOPNOTSUPP);
984263bc
MD
397 }
398
aac0aabd 399 ap->a_kn->kn_hook = (caddr_t)vp;
6d49aa6f 400 ssb_insert_knote(ssb, ap->a_kn);
984263bc 401
3b998fa9 402 lwkt_reltoken(&vp->v_token);
984263bc
MD
403 return (0);
404}
405
406static void
407filt_fifordetach(struct knote *kn)
408{
aac0aabd
MD
409 struct vnode *vp = (void *)kn->kn_hook;
410 struct socket *so = vp->v_fifoinfo->fi_readsock;
984263bc 411
3b998fa9 412 lwkt_gettoken(&vp->v_token);
6d49aa6f 413 ssb_remove_knote(&so->so_rcv, kn);
3b998fa9 414 lwkt_reltoken(&vp->v_token);
984263bc
MD
415}
416
417static int
418filt_fiforead(struct knote *kn, long hint)
419{
aac0aabd 420 struct vnode *vp = (void *)kn->kn_hook;
7a5447ef 421 struct socket *so = vp->v_fifoinfo->fi_readsock;
984263bc 422
3b998fa9 423 lwkt_gettoken(&vp->v_token);
6d49aa6f 424 kn->kn_data = so->so_rcv.ssb_cc;
984263bc
MD
425 if (so->so_state & SS_CANTRCVMORE) {
426 kn->kn_flags |= EV_EOF;
3b998fa9 427 lwkt_reltoken(&vp->v_token);
984263bc
MD
428 return (1);
429 }
430 kn->kn_flags &= ~EV_EOF;
3b998fa9 431 lwkt_reltoken(&vp->v_token);
984263bc
MD
432 return (kn->kn_data > 0);
433}
434
435static void
436filt_fifowdetach(struct knote *kn)
437{
aac0aabd
MD
438 struct vnode *vp = (void *)kn->kn_hook;
439 struct socket *so = vp->v_fifoinfo->fi_writesock;
984263bc 440
3b998fa9 441 lwkt_gettoken(&vp->v_token);
6d49aa6f 442 ssb_remove_knote(&so->so_snd, kn);
3b998fa9 443 lwkt_reltoken(&vp->v_token);
984263bc
MD
444}
445
446static int
447filt_fifowrite(struct knote *kn, long hint)
448{
aac0aabd
MD
449 struct vnode *vp = (void *)kn->kn_hook;
450 struct socket *so = vp->v_fifoinfo->fi_writesock;
984263bc 451
3b998fa9 452 lwkt_gettoken(&vp->v_token);
6d49aa6f 453 kn->kn_data = ssb_space(&so->so_snd);
984263bc
MD
454 if (so->so_state & SS_CANTSENDMORE) {
455 kn->kn_flags |= EV_EOF;
3b998fa9 456 lwkt_reltoken(&vp->v_token);
984263bc
MD
457 return (1);
458 }
459 kn->kn_flags &= ~EV_EOF;
3b998fa9 460 lwkt_reltoken(&vp->v_token);
6d49aa6f 461 return (kn->kn_data >= so->so_snd.ssb_lowat);
984263bc
MD
462}
463
b5f12e21 464/*
b478fdce 465 * fifo_inactive(struct vnode *a_vp)
b5f12e21 466 */
984263bc 467static int
b5f12e21 468fifo_inactive(struct vop_inactive_args *ap)
984263bc 469{
984263bc
MD
470 return (0);
471}
472
473/*
474 * This is a noop, simply returning what one has been given.
b5f12e21 475 *
08daea96 476 * fifo_bmap(struct vnode *a_vp, off_t a_loffset,
54078292 477 * off_t *a_doffsetp, int *a_runp, int *a_runb)
984263bc
MD
478 */
479static int
b5f12e21 480fifo_bmap(struct vop_bmap_args *ap)
984263bc 481{
54078292
MD
482 if (ap->a_doffsetp != NULL)
483 *ap->a_doffsetp = ap->a_loffset;
984263bc
MD
484 if (ap->a_runp != NULL)
485 *ap->a_runp = 0;
486 if (ap->a_runb != NULL)
487 *ap->a_runb = 0;
488 return (0);
489}
490
491/*
492 * Device close routine
b5f12e21 493 *
b478fdce 494 * fifo_close(struct vnode *a_vp, int a_fflag)
984263bc
MD
495 */
496/* ARGSUSED */
497static int
b5f12e21 498fifo_close(struct vop_close_args *ap)
984263bc 499{
0e99e805 500 struct vnode *vp = ap->a_vp;
aac0aabd 501 struct fifoinfo *fip;
984263bc
MD
502 int error1, error2;
503
3b998fa9 504 lwkt_gettoken(&vp->v_token);
aac0aabd 505 fip = vp->v_fifoinfo;
984263bc
MD
506 if (ap->a_fflag & FREAD) {
507 fip->fi_readers--;
508 if (fip->fi_readers == 0)
509 socantsendmore(fip->fi_writesock);
510 }
511 if (ap->a_fflag & FWRITE) {
512 fip->fi_writers--;
513 if (fip->fi_writers == 0)
514 socantrcvmore(fip->fi_readsock);
515 }
3c37c940 516 if (vp->v_sysref.refcnt > 1) {
8ddc6004 517 vop_stdclose(ap);
3b998fa9 518 lwkt_reltoken(&vp->v_token);
984263bc 519 return (0);
8ddc6004 520 }
9ba76b73
MD
521 error1 = soclose(fip->fi_readsock, FNONBLOCK);
522 error2 = soclose(fip->fi_writesock, FNONBLOCK);
5fd012e0 523 FREE(fip, M_FIFOINFO);
984263bc 524 vp->v_fifoinfo = NULL;
aac0aabd
MD
525 if (error1) {
526 error2 = error1;
527 } else {
528 vop_stdclose(ap);
529 }
3b998fa9 530 lwkt_reltoken(&vp->v_token);
984263bc
MD
531 return (error2);
532}
533
534
535/*
536 * Print out internal contents of a fifo vnode.
537 */
538int
b5f12e21 539fifo_printinfo(struct vnode *vp)
984263bc 540{
0e99e805 541 struct fifoinfo *fip = vp->v_fifoinfo;
984263bc 542
086c1d7e 543 kprintf(", fifo with %ld readers and %ld writers",
984263bc
MD
544 fip->fi_readers, fip->fi_writers);
545 return (0);
546}
547
548/*
549 * Print out the contents of a fifo vnode.
b5f12e21
CP
550 *
551 * fifo_print(struct vnode *a_vp)
984263bc
MD
552 */
553static int
b5f12e21 554fifo_print(struct vop_print_args *ap)
984263bc 555{
086c1d7e 556 kprintf("tag VT_NON");
984263bc 557 fifo_printinfo(ap->a_vp);
086c1d7e 558 kprintf("\n");
984263bc
MD
559 return (0);
560}
561
562/*
563 * Return POSIX pathconf information applicable to fifo's.
b5f12e21
CP
564 *
565 * fifo_pathconf(struct vnode *a_vp, int a_name, int *a_retval)
984263bc
MD
566 */
567int
b5f12e21 568fifo_pathconf(struct vop_pathconf_args *ap)
984263bc 569{
984263bc
MD
570 switch (ap->a_name) {
571 case _PC_LINK_MAX:
572 *ap->a_retval = LINK_MAX;
573 return (0);
574 case _PC_PIPE_BUF:
575 *ap->a_retval = PIPE_BUF;
576 return (0);
577 case _PC_CHOWN_RESTRICTED:
578 *ap->a_retval = 1;
579 return (0);
580 default:
581 return (EINVAL);
582 }
583 /* NOTREACHED */
584}
585
586/*
587 * Fifo advisory byte-level locks.
b5f12e21
CP
588 *
589 * fifo_advlock(struct vnode *a_vp, caddr_t a_id, int a_op, struct flock *a_fl,
590 * int a_flags)
984263bc
MD
591 */
592/* ARGSUSED */
593static int
b5f12e21 594fifo_advlock(struct vop_advlock_args *ap)
984263bc 595{
71c18fe3 596 return ((ap->a_flags & F_POSIX) ? EINVAL : EOPNOTSUPP);
984263bc
MD
597}
598
599/*
600 * Fifo bad operation
601 */
602static int
b5f12e21 603fifo_badop(void)
984263bc 604{
984263bc
MD
605 panic("fifo_badop called");
606 /* NOTREACHED */
607}