spec_vnops.c revision 1.46 1 /* $NetBSD: spec_vnops.c,v 1.46 1999/12/08 18:57:07 sommerfeld Exp $ */
2
3 /*
4 * Copyright (c) 1989, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. All advertising materials mentioning features or use of this software
16 * must display the following acknowledgement:
17 * This product includes software developed by the University of
18 * California, Berkeley and its contributors.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 * SUCH DAMAGE.
34 *
35 * @(#)spec_vnops.c 8.15 (Berkeley) 7/14/95
36 */
37
38 #include <sys/param.h>
39 #include <sys/proc.h>
40 #include <sys/systm.h>
41 #include <sys/kernel.h>
42 #include <sys/conf.h>
43 #include <sys/buf.h>
44 #include <sys/mount.h>
45 #include <sys/namei.h>
46 #include <sys/vnode.h>
47 #include <sys/stat.h>
48 #include <sys/errno.h>
49 #include <sys/ioctl.h>
50 #include <sys/file.h>
51 #include <sys/disklabel.h>
52 #include <sys/lockf.h>
53
54 #include <miscfs/genfs/genfs.h>
55 #include <miscfs/specfs/specdev.h>
56
57 /* symbolic sleep message strings for devices */
58 const char devopn[] = "devopn";
59 const char devio[] = "devio";
60 const char devwait[] = "devwait";
61 const char devin[] = "devin";
62 const char devout[] = "devout";
63 const char devioc[] = "devioc";
64 const char devcls[] = "devcls";
65
66 /*
67 * This vnode operations vector is used for two things only:
68 * - special device nodes created from whole cloth by the kernel.
69 * - as a temporary vnodeops replacement for vnodes which were found to
70 * be aliased by callers of checkalias().
71 * For the ops vector for vnodes built from special devices found in a
72 * filesystem, see (e.g) ffs_specop_entries[] in ffs_vnops.c or the
73 * equivalent for other filesystems.
74 */
75
76 int (**spec_vnodeop_p) __P((void *));
77 struct vnodeopv_entry_desc spec_vnodeop_entries[] = {
78 { &vop_default_desc, vn_default_error },
79 { &vop_lookup_desc, spec_lookup }, /* lookup */
80 { &vop_create_desc, spec_create }, /* create */
81 { &vop_mknod_desc, spec_mknod }, /* mknod */
82 { &vop_open_desc, spec_open }, /* open */
83 { &vop_close_desc, spec_close }, /* close */
84 { &vop_access_desc, spec_access }, /* access */
85 { &vop_getattr_desc, spec_getattr }, /* getattr */
86 { &vop_setattr_desc, spec_setattr }, /* setattr */
87 { &vop_read_desc, spec_read }, /* read */
88 { &vop_write_desc, spec_write }, /* write */
89 { &vop_lease_desc, spec_lease_check }, /* lease */
90 { &vop_ioctl_desc, spec_ioctl }, /* ioctl */
91 { &vop_poll_desc, spec_poll }, /* poll */
92 { &vop_revoke_desc, spec_revoke }, /* revoke */
93 { &vop_mmap_desc, spec_mmap }, /* mmap */
94 { &vop_fsync_desc, spec_fsync }, /* fsync */
95 { &vop_seek_desc, spec_seek }, /* seek */
96 { &vop_remove_desc, spec_remove }, /* remove */
97 { &vop_link_desc, spec_link }, /* link */
98 { &vop_rename_desc, spec_rename }, /* rename */
99 { &vop_mkdir_desc, spec_mkdir }, /* mkdir */
100 { &vop_rmdir_desc, spec_rmdir }, /* rmdir */
101 { &vop_symlink_desc, spec_symlink }, /* symlink */
102 { &vop_readdir_desc, spec_readdir }, /* readdir */
103 { &vop_readlink_desc, spec_readlink }, /* readlink */
104 { &vop_abortop_desc, spec_abortop }, /* abortop */
105 { &vop_inactive_desc, spec_inactive }, /* inactive */
106 { &vop_reclaim_desc, spec_reclaim }, /* reclaim */
107 { &vop_lock_desc, spec_lock }, /* lock */
108 { &vop_unlock_desc, spec_unlock }, /* unlock */
109 { &vop_bmap_desc, spec_bmap }, /* bmap */
110 { &vop_strategy_desc, spec_strategy }, /* strategy */
111 { &vop_print_desc, spec_print }, /* print */
112 { &vop_islocked_desc, spec_islocked }, /* islocked */
113 { &vop_pathconf_desc, spec_pathconf }, /* pathconf */
114 { &vop_advlock_desc, spec_advlock }, /* advlock */
115 { &vop_blkatoff_desc, spec_blkatoff }, /* blkatoff */
116 { &vop_valloc_desc, spec_valloc }, /* valloc */
117 { &vop_vfree_desc, spec_vfree }, /* vfree */
118 { &vop_truncate_desc, spec_truncate }, /* truncate */
119 { &vop_update_desc, spec_update }, /* update */
120 { &vop_bwrite_desc, spec_bwrite }, /* bwrite */
121 { (struct vnodeop_desc*)NULL, (int(*) __P((void *)))NULL }
122 };
123 struct vnodeopv_desc spec_vnodeop_opv_desc =
124 { &spec_vnodeop_p, spec_vnodeop_entries };
125
126 /*
127 * Trivial lookup routine that always fails.
128 */
129 int
130 spec_lookup(v)
131 void *v;
132 {
133 struct vop_lookup_args /* {
134 struct vnode *a_dvp;
135 struct vnode **a_vpp;
136 struct componentname *a_cnp;
137 } */ *ap = v;
138
139 *ap->a_vpp = NULL;
140 return (ENOTDIR);
141 }
142
143 /*
144 * Open a special file.
145 */
146 /* ARGSUSED */
147 int
148 spec_open(v)
149 void *v;
150 {
151 struct vop_open_args /* {
152 struct vnode *a_vp;
153 int a_mode;
154 struct ucred *a_cred;
155 struct proc *a_p;
156 } */ *ap = v;
157 struct proc *p = ap->a_p;
158 struct vnode *bvp, *vp = ap->a_vp;
159 dev_t bdev, dev = (dev_t)vp->v_rdev;
160 register int maj = major(dev);
161 int error;
162
163 /*
164 * Don't allow open if fs is mounted -nodev.
165 */
166 if (vp->v_mount && (vp->v_mount->mnt_flag & MNT_NODEV))
167 return (ENXIO);
168
169 switch (vp->v_type) {
170
171 case VCHR:
172 if ((u_int)maj >= nchrdev)
173 return (ENXIO);
174 if (ap->a_cred != FSCRED && (ap->a_mode & FWRITE)) {
175 /*
176 * When running in very secure mode, do not allow
177 * opens for writing of any disk character devices.
178 */
179 if (securelevel >= 2 && cdevsw[maj].d_type == D_DISK)
180 return (EPERM);
181 /*
182 * When running in secure mode, do not allow opens
183 * for writing of /dev/mem, /dev/kmem, or character
184 * devices whose corresponding block devices are
185 * currently mounted.
186 */
187 if (securelevel >= 1) {
188 if ((bdev = chrtoblk(dev)) != (dev_t)NODEV &&
189 vfinddev(bdev, VBLK, &bvp) &&
190 bvp->v_usecount > 0 &&
191 (error = vfs_mountedon(bvp)))
192 return (error);
193 if (iskmemdev(dev))
194 return (EPERM);
195 }
196 }
197 if (cdevsw[maj].d_type == D_TTY)
198 vp->v_flag |= VISTTY;
199 VOP_UNLOCK(vp, 0);
200 error = (*cdevsw[maj].d_open)(dev, ap->a_mode, S_IFCHR, p);
201 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
202 return (error);
203
204 case VBLK:
205 if ((u_int)maj >= nblkdev)
206 return (ENXIO);
207 /*
208 * When running in very secure mode, do not allow
209 * opens for writing of any disk block devices.
210 */
211 if (securelevel >= 2 && ap->a_cred != FSCRED &&
212 (ap->a_mode & FWRITE) && bdevsw[maj].d_type == D_DISK)
213 return (EPERM);
214 /*
215 * Do not allow opens of block devices that are
216 * currently mounted.
217 */
218 if ((error = vfs_mountedon(vp)) != 0)
219 return (error);
220 return ((*bdevsw[maj].d_open)(dev, ap->a_mode, S_IFBLK, p));
221 case VNON:
222 case VLNK:
223 case VDIR:
224 case VREG:
225 case VBAD:
226 case VFIFO:
227 case VSOCK:
228 break;
229 }
230 return (0);
231 }
232
233 /*
234 * Vnode op for read
235 */
236 /* ARGSUSED */
237 int
238 spec_read(v)
239 void *v;
240 {
241 struct vop_read_args /* {
242 struct vnode *a_vp;
243 struct uio *a_uio;
244 int a_ioflag;
245 struct ucred *a_cred;
246 } */ *ap = v;
247 register struct vnode *vp = ap->a_vp;
248 register struct uio *uio = ap->a_uio;
249 struct proc *p = uio->uio_procp;
250 struct buf *bp;
251 daddr_t bn, nextbn;
252 long bsize, bscale, ssize;
253 struct partinfo dpart;
254 int n, on, majordev;
255 int (*ioctl) __P((dev_t, u_long, caddr_t, int, struct proc *));
256 int error = 0;
257
258 #ifdef DIAGNOSTIC
259 if (uio->uio_rw != UIO_READ)
260 panic("spec_read mode");
261 if (uio->uio_segflg == UIO_USERSPACE && uio->uio_procp != curproc)
262 panic("spec_read proc");
263 #endif
264 if (uio->uio_resid == 0)
265 return (0);
266
267 switch (vp->v_type) {
268
269 case VCHR:
270 VOP_UNLOCK(vp, 0);
271 error = (*cdevsw[major(vp->v_rdev)].d_read)
272 (vp->v_rdev, uio, ap->a_ioflag);
273 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
274 return (error);
275
276 case VBLK:
277 if (uio->uio_offset < 0)
278 return (EINVAL);
279 bsize = BLKDEV_IOSIZE;
280 ssize = DEV_BSIZE;
281 if ((majordev = major(vp->v_rdev)) < nblkdev &&
282 (ioctl = bdevsw[majordev].d_ioctl) != NULL &&
283 (*ioctl)(vp->v_rdev, DIOCGPART, (caddr_t)&dpart, FREAD, p) == 0) {
284 if (dpart.part->p_fstype == FS_BSDFFS &&
285 dpart.part->p_frag != 0 && dpart.part->p_fsize != 0)
286 bsize = dpart.part->p_frag *
287 dpart.part->p_fsize;
288 if (dpart.disklab->d_secsize != 0)
289 ssize = dpart.disklab->d_secsize;
290 }
291 bscale = bsize / ssize;
292 do {
293 bn = (uio->uio_offset / ssize) &~ (bscale - 1);
294 on = uio->uio_offset % bsize;
295 n = min((unsigned)(bsize - on), uio->uio_resid);
296 if (vp->v_lastr + bscale == bn) {
297 nextbn = bn + bscale;
298 error = breadn(vp, bn, (int)bsize, &nextbn,
299 (int *)&bsize, 1, NOCRED, &bp);
300 } else
301 error = bread(vp, bn, (int)bsize, NOCRED, &bp);
302 vp->v_lastr = bn;
303 n = min(n, bsize - bp->b_resid);
304 if (error) {
305 brelse(bp);
306 return (error);
307 }
308 error = uiomove((char *)bp->b_data + on, n, uio);
309 brelse(bp);
310 } while (error == 0 && uio->uio_resid > 0 && n != 0);
311 return (error);
312
313 default:
314 panic("spec_read type");
315 }
316 /* NOTREACHED */
317 }
318
319 /*
320 * Vnode op for write
321 */
322 /* ARGSUSED */
323 int
324 spec_write(v)
325 void *v;
326 {
327 struct vop_write_args /* {
328 struct vnode *a_vp;
329 struct uio *a_uio;
330 int a_ioflag;
331 struct ucred *a_cred;
332 } */ *ap = v;
333 register struct vnode *vp = ap->a_vp;
334 register struct uio *uio = ap->a_uio;
335 struct proc *p = uio->uio_procp;
336 struct buf *bp;
337 daddr_t bn;
338 long bsize, bscale, ssize;
339 struct partinfo dpart;
340 int n, on, majordev;
341 int (*ioctl) __P((dev_t, u_long, caddr_t, int, struct proc *));
342 int error = 0;
343
344 #ifdef DIAGNOSTIC
345 if (uio->uio_rw != UIO_WRITE)
346 panic("spec_write mode");
347 if (uio->uio_segflg == UIO_USERSPACE && uio->uio_procp != curproc)
348 panic("spec_write proc");
349 #endif
350
351 switch (vp->v_type) {
352
353 case VCHR:
354 VOP_UNLOCK(vp, 0);
355 error = (*cdevsw[major(vp->v_rdev)].d_write)
356 (vp->v_rdev, uio, ap->a_ioflag);
357 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
358 return (error);
359
360 case VBLK:
361 if (uio->uio_resid == 0)
362 return (0);
363 if (uio->uio_offset < 0)
364 return (EINVAL);
365 bsize = BLKDEV_IOSIZE;
366 ssize = DEV_BSIZE;
367 if ((majordev = major(vp->v_rdev)) < nblkdev &&
368 (ioctl = bdevsw[majordev].d_ioctl) != NULL &&
369 (*ioctl)(vp->v_rdev, DIOCGPART, (caddr_t)&dpart, FREAD, p) == 0) {
370 if (dpart.part->p_fstype == FS_BSDFFS &&
371 dpart.part->p_frag != 0 && dpart.part->p_fsize != 0)
372 bsize = dpart.part->p_frag *
373 dpart.part->p_fsize;
374 if (dpart.disklab->d_secsize != 0)
375 ssize = dpart.disklab->d_secsize;
376 }
377 bscale = bsize / ssize;
378 do {
379 bn = (uio->uio_offset / ssize) &~ (bscale - 1);
380 on = uio->uio_offset % bsize;
381 n = min((unsigned)(bsize - on), uio->uio_resid);
382 if (n == bsize)
383 bp = getblk(vp, bn, bsize, 0, 0);
384 else
385 error = bread(vp, bn, bsize, NOCRED, &bp);
386 if (error) {
387 brelse(bp);
388 return (error);
389 }
390 n = min(n, bsize - bp->b_resid);
391 error = uiomove((char *)bp->b_data + on, n, uio);
392 if (error)
393 brelse(bp);
394 else {
395 if (n + on == bsize)
396 bawrite(bp);
397 else
398 bdwrite(bp);
399 if (bp->b_flags & B_ERROR)
400 error = bp->b_error;
401 }
402 } while (error == 0 && uio->uio_resid > 0 && n != 0);
403 return (error);
404
405 default:
406 panic("spec_write type");
407 }
408 /* NOTREACHED */
409 }
410
411 /*
412 * Device ioctl operation.
413 */
414 /* ARGSUSED */
415 int
416 spec_ioctl(v)
417 void *v;
418 {
419 struct vop_ioctl_args /* {
420 struct vnode *a_vp;
421 u_long a_command;
422 caddr_t a_data;
423 int a_fflag;
424 struct ucred *a_cred;
425 struct proc *a_p;
426 } */ *ap = v;
427 dev_t dev = ap->a_vp->v_rdev;
428 int maj = major(dev);
429
430 switch (ap->a_vp->v_type) {
431
432 case VCHR:
433 return ((*cdevsw[maj].d_ioctl)(dev, ap->a_command, ap->a_data,
434 ap->a_fflag, ap->a_p));
435
436 case VBLK:
437 if (ap->a_command == 0 && (long)ap->a_data == B_TAPE) {
438 if (bdevsw[maj].d_type == D_TAPE)
439 return (0);
440 else
441 return (1);
442 }
443 return ((*bdevsw[maj].d_ioctl)(dev, ap->a_command, ap->a_data,
444 ap->a_fflag, ap->a_p));
445
446 default:
447 panic("spec_ioctl");
448 /* NOTREACHED */
449 }
450 }
451
452 /* ARGSUSED */
453 int
454 spec_poll(v)
455 void *v;
456 {
457 struct vop_poll_args /* {
458 struct vnode *a_vp;
459 int a_events;
460 struct proc *a_p;
461 } */ *ap = v;
462 register dev_t dev;
463
464 switch (ap->a_vp->v_type) {
465
466 case VCHR:
467 dev = ap->a_vp->v_rdev;
468 return (*cdevsw[major(dev)].d_poll)(dev, ap->a_events, ap->a_p);
469
470 default:
471 return (genfs_poll(v));
472 }
473 }
474 /*
475 * Synch buffers associated with a block device
476 */
477 /* ARGSUSED */
478 int
479 spec_fsync(v)
480 void *v;
481 {
482 struct vop_fsync_args /* {
483 struct vnode *a_vp;
484 struct ucred *a_cred;
485 int a_flags;
486 struct proc *a_p;
487 } */ *ap = v;
488 register struct vnode *vp = ap->a_vp;
489
490 if (vp->v_type == VBLK)
491 vflushbuf(vp, (ap->a_flags & FSYNC_WAIT) != 0);
492 return (0);
493 }
494
495 /*
496 * Just call the device strategy routine
497 */
498 int
499 spec_strategy(v)
500 void *v;
501 {
502 struct vop_strategy_args /* {
503 struct buf *a_bp;
504 } */ *ap = v;
505 struct buf *bp;
506
507 bp = ap->a_bp;
508 if (!(bp->b_flags & B_READ) &&
509 (LIST_FIRST(&bp->b_dep)) != NULL && bioops.io_start)
510 (*bioops.io_start)(bp);
511 (*bdevsw[major(bp->b_dev)].d_strategy)(bp);
512 return (0);
513 }
514
515 int
516 spec_inactive(v)
517 void *v;
518 {
519 struct vop_inactive_args /* {
520 struct vnode *a_vp;
521 struct proc *a_p;
522 } */ *ap = v;
523
524 VOP_UNLOCK(ap->a_vp, 0);
525 return (0);
526 }
527
528 /*
529 * This is a noop, simply returning what one has been given.
530 */
531 int
532 spec_bmap(v)
533 void *v;
534 {
535 struct vop_bmap_args /* {
536 struct vnode *a_vp;
537 daddr_t a_bn;
538 struct vnode **a_vpp;
539 daddr_t *a_bnp;
540 int *a_runp;
541 } */ *ap = v;
542
543 if (ap->a_vpp != NULL)
544 *ap->a_vpp = ap->a_vp;
545 if (ap->a_bnp != NULL)
546 *ap->a_bnp = ap->a_bn;
547 if (ap->a_runp != NULL)
548 *ap->a_runp = 0;
549 return (0);
550 }
551
552 /*
553 * Device close routine
554 */
555 /* ARGSUSED */
556 int
557 spec_close(v)
558 void *v;
559 {
560 struct vop_close_args /* {
561 struct vnode *a_vp;
562 int a_fflag;
563 struct ucred *a_cred;
564 struct proc *a_p;
565 } */ *ap = v;
566 register struct vnode *vp = ap->a_vp;
567 dev_t dev = vp->v_rdev;
568 int (*devclose) __P((dev_t, int, int, struct proc *));
569 int mode, error, count, flags, flags1;
570
571 simple_lock(&vp->v_interlock);
572 count = vcount(vp);
573 flags = vp->v_flag;
574 simple_unlock(&vp->v_interlock);
575
576 switch (vp->v_type) {
577
578 case VCHR:
579 /*
580 * Hack: a tty device that is a controlling terminal
581 * has a reference from the session structure.
582 * We cannot easily tell that a character device is
583 * a controlling terminal, unless it is the closing
584 * process' controlling terminal. In that case,
585 * if the reference count is 2 (this last descriptor
586 * plus the session), release the reference from the session.
587 */
588 if (count == 2 && ap->a_p &&
589 vp == ap->a_p->p_session->s_ttyvp) {
590 vrele(vp);
591 count--;
592 ap->a_p->p_session->s_ttyvp = NULL;
593 }
594 /*
595 * If the vnode is locked, then we are in the midst
596 * of forcably closing the device, otherwise we only
597 * close on last reference.
598 */
599 if (count > 1 && (flags & VXLOCK) == 0)
600 return (0);
601 devclose = cdevsw[major(dev)].d_close;
602 mode = S_IFCHR;
603 break;
604
605 case VBLK:
606 /*
607 * On last close of a block device (that isn't mounted)
608 * we must invalidate any in core blocks, so that
609 * we can, for instance, change floppy disks.
610 */
611 error = vinvalbuf(vp, V_SAVE, ap->a_cred, ap->a_p, 0, 0);
612 if (error)
613 return (error);
614 /*
615 * We do not want to really close the device if it
616 * is still in use unless we are trying to close it
617 * forcibly. Since every use (buffer, vnode, swap, cmap)
618 * holds a reference to the vnode, and because we mark
619 * any other vnodes that alias this device, when the
620 * sum of the reference counts on all the aliased
621 * vnodes descends to one, we are on last close.
622 */
623 if (count > 1 && (flags & VXLOCK) == 0)
624 return (0);
625 devclose = bdevsw[major(dev)].d_close;
626 mode = S_IFBLK;
627 break;
628
629 default:
630 panic("spec_close: not special");
631 }
632
633 flags1 = ap->a_fflag;
634
635 /*
636 * if VXLOCK is set, then we're going away soon, so make this
637 * non-blocking. Also ensures that we won't wedge in vn_lock below.
638 */
639 if (flags & VXLOCK)
640 flags1 |= FNONBLOCK;
641
642 /*
643 * If we're able to block, release the vnode lock & reaquire. We
644 * might end up sleaping for someone else who wants our queues. They
645 * won't get them if we hold the vnode locked. Also, if VXLOCK is set,
646 * don't release the lock as we won't be able to regain it.
647 */
648 if (!(flags1 & FNONBLOCK))
649 VOP_UNLOCK(vp, 0);
650
651 error = (*devclose)(dev, flags1, mode, ap->a_p);
652
653 if (!(flags1 & FNONBLOCK))
654 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
655
656 return (error);
657 }
658
659 /*
660 * Print out the contents of a special device vnode.
661 */
662 int
663 spec_print(v)
664 void *v;
665 {
666 struct vop_print_args /* {
667 struct vnode *a_vp;
668 } */ *ap = v;
669
670 printf("tag VT_NON, dev %d, %d\n", major(ap->a_vp->v_rdev),
671 minor(ap->a_vp->v_rdev));
672 return 0;
673 }
674
675 /*
676 * Return POSIX pathconf information applicable to special devices.
677 */
678 int
679 spec_pathconf(v)
680 void *v;
681 {
682 struct vop_pathconf_args /* {
683 struct vnode *a_vp;
684 int a_name;
685 register_t *a_retval;
686 } */ *ap = v;
687
688 switch (ap->a_name) {
689 case _PC_LINK_MAX:
690 *ap->a_retval = LINK_MAX;
691 return (0);
692 case _PC_MAX_CANON:
693 *ap->a_retval = MAX_CANON;
694 return (0);
695 case _PC_MAX_INPUT:
696 *ap->a_retval = MAX_INPUT;
697 return (0);
698 case _PC_PIPE_BUF:
699 *ap->a_retval = PIPE_BUF;
700 return (0);
701 case _PC_CHOWN_RESTRICTED:
702 *ap->a_retval = 1;
703 return (0);
704 case _PC_VDISABLE:
705 *ap->a_retval = _POSIX_VDISABLE;
706 return (0);
707 case _PC_SYNC_IO:
708 *ap->a_retval = 1;
709 return (0);
710 default:
711 return (EINVAL);
712 }
713 /* NOTREACHED */
714 }
715
716 /*
717 * Advisory record locking support.
718 */
719 int
720 spec_advlock(v)
721 void *v;
722 {
723 struct vop_advlock_args /* {
724 struct vnode *a_vp;
725 caddr_t a_id;
726 int a_op;
727 struct flock *a_fl;
728 int a_flags;
729 } */ *ap = v;
730 register struct vnode *vp = ap->a_vp;
731
732 return (lf_advlock(&vp->v_speclockf, (off_t)0, ap->a_id, ap->a_op,
733 ap->a_fl, ap->a_flags));
734 }
735