2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
22 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
24 * Copyright (c) 1989, 1993, 1995
25 * The Regents of the University of California. All rights reserved.
27 * Redistribution and use in source and binary forms, with or without
28 * modification, are permitted provided that the following conditions
30 * 1. Redistributions of source code must retain the above copyright
31 * notice, this list of conditions and the following disclaimer.
32 * 2. Redistributions in binary form must reproduce the above copyright
33 * notice, this list of conditions and the following disclaimer in the
34 * documentation and/or other materials provided with the distribution.
35 * 3. All advertising materials mentioning features or use of this software
36 * must display the following acknowledgement:
37 * This product includes software developed by the University of
38 * California, Berkeley and its contributors.
39 * 4. Neither the name of the University nor the names of its contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
43 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55 * @(#)spec_vnops.c 8.14 (Berkeley) 5/21/95
58 #include <sys/param.h>
59 #include <sys/proc_internal.h>
60 #include <sys/kauth.h>
61 #include <sys/systm.h>
62 #include <sys/kernel.h>
64 #include <sys/buf_internal.h>
65 #include <sys/mount_internal.h>
66 #include <sys/namei.h>
67 #include <sys/vnode_internal.h>
69 #include <sys/errno.h>
70 #include <sys/ioctl.h>
73 #include <sys/malloc.h>
75 #include <sys/uio_internal.h>
76 #include <miscfs/specfs/specdev.h>
77 #include <vfs/vfs_support.h>
79 #include <sys/kdebug.h>
81 struct vnode
*speclisth
[SPECHSZ
];
83 /* symbolic sleep message strings for devices */
84 char devopn
[] = "devopn";
85 char devio
[] = "devio";
86 char devwait
[] = "devwait";
87 char devin
[] = "devin";
88 char devout
[] = "devout";
89 char devioc
[] = "devioc";
90 char devcls
[] = "devcls";
92 #define VOPFUNC int (*)(void *)
94 int (**spec_vnodeop_p
)(void *);
95 struct vnodeopv_entry_desc spec_vnodeop_entries
[] = {
96 { &vnop_default_desc
, (VOPFUNC
)vn_default_error
},
97 { &vnop_lookup_desc
, (VOPFUNC
)spec_lookup
}, /* lookup */
98 { &vnop_create_desc
, (VOPFUNC
)err_create
}, /* create */
99 { &vnop_mknod_desc
, (VOPFUNC
)err_mknod
}, /* mknod */
100 { &vnop_open_desc
, (VOPFUNC
)spec_open
}, /* open */
101 { &vnop_close_desc
, (VOPFUNC
)spec_close
}, /* close */
102 { &vnop_access_desc
, (VOPFUNC
)spec_access
}, /* access */
103 { &vnop_getattr_desc
, (VOPFUNC
)spec_getattr
}, /* getattr */
104 { &vnop_setattr_desc
, (VOPFUNC
)spec_setattr
}, /* setattr */
105 { &vnop_read_desc
, (VOPFUNC
)spec_read
}, /* read */
106 { &vnop_write_desc
, (VOPFUNC
)spec_write
}, /* write */
107 { &vnop_ioctl_desc
, (VOPFUNC
)spec_ioctl
}, /* ioctl */
108 { &vnop_select_desc
, (VOPFUNC
)spec_select
}, /* select */
109 { &vnop_revoke_desc
, (VOPFUNC
)nop_revoke
}, /* revoke */
110 { &vnop_mmap_desc
, (VOPFUNC
)err_mmap
}, /* mmap */
111 { &vnop_fsync_desc
, (VOPFUNC
)spec_fsync
}, /* fsync */
112 { &vnop_remove_desc
, (VOPFUNC
)err_remove
}, /* remove */
113 { &vnop_link_desc
, (VOPFUNC
)err_link
}, /* link */
114 { &vnop_rename_desc
, (VOPFUNC
)err_rename
}, /* rename */
115 { &vnop_mkdir_desc
, (VOPFUNC
)err_mkdir
}, /* mkdir */
116 { &vnop_rmdir_desc
, (VOPFUNC
)err_rmdir
}, /* rmdir */
117 { &vnop_symlink_desc
, (VOPFUNC
)err_symlink
}, /* symlink */
118 { &vnop_readdir_desc
, (VOPFUNC
)err_readdir
}, /* readdir */
119 { &vnop_readlink_desc
, (VOPFUNC
)err_readlink
}, /* readlink */
120 { &vnop_inactive_desc
, (VOPFUNC
)nop_inactive
}, /* inactive */
121 { &vnop_reclaim_desc
, (VOPFUNC
)nop_reclaim
}, /* reclaim */
122 { &vnop_strategy_desc
, (VOPFUNC
)spec_strategy
}, /* strategy */
123 { &vnop_pathconf_desc
, (VOPFUNC
)spec_pathconf
}, /* pathconf */
124 { &vnop_advlock_desc
, (VOPFUNC
)err_advlock
}, /* advlock */
125 { &vnop_bwrite_desc
, (VOPFUNC
)spec_bwrite
}, /* bwrite */
126 { &vnop_devblocksize_desc
, (VOPFUNC
)spec_devblocksize
}, /* devblocksize */
127 { &vnop_pagein_desc
, (VOPFUNC
)err_pagein
}, /* Pagein */
128 { &vnop_pageout_desc
, (VOPFUNC
)err_pageout
}, /* Pageout */
129 { &vnop_copyfile_desc
, (VOPFUNC
)err_copyfile
}, /* Copyfile */
130 { &vnop_blktooff_desc
, (VOPFUNC
)spec_blktooff
}, /* blktooff */
131 { &vnop_offtoblk_desc
, (VOPFUNC
)spec_offtoblk
}, /* offtoblk */
132 { &vnop_blockmap_desc
, (VOPFUNC
)spec_blockmap
}, /* blockmap */
133 { (struct vnodeop_desc
*)NULL
, (int(*)())NULL
}
135 struct vnodeopv_desc spec_vnodeop_opv_desc
=
136 { &spec_vnodeop_p
, spec_vnodeop_entries
};
139 static void set_blocksize(vnode_t
, dev_t
);
143 * Trivial lookup routine that always fails.
147 struct vnop_lookup_args
/* {
149 struct vnode **a_vpp;
150 struct componentname *a_cnp;
151 vfs_context_t a_context;
160 set_blocksize(struct vnode
*vp
, dev_t dev
)
165 if ((major(dev
) < nblkdev
) && (size
= bdevsw
[major(dev
)].d_psize
)) {
166 rsize
= (*size
)(dev
);
167 if (rsize
<= 0) /* did size fail? */
168 vp
->v_specsize
= DEV_BSIZE
;
170 vp
->v_specsize
= rsize
;
173 vp
->v_specsize
= DEV_BSIZE
;
177 set_fsblocksize(struct vnode
*vp
)
180 if (vp
->v_type
== VBLK
) {
181 dev_t dev
= (dev_t
)vp
->v_rdev
;
182 int maj
= major(dev
);
184 if ((u_int
)maj
>= (u_int
)nblkdev
)
188 set_blocksize(vp
, dev
);
196 * Open a special file.
200 struct vnop_open_args
/* {
203 vfs_context_t a_context;
206 struct proc
*p
= vfs_context_proc(ap
->a_context
);
207 kauth_cred_t cred
= vfs_context_ucred(ap
->a_context
);
208 struct vnode
*vp
= ap
->a_vp
;
209 dev_t bdev
, dev
= (dev_t
)vp
->v_rdev
;
210 int maj
= major(dev
);
214 * Don't allow open if fs is mounted -nodev.
216 if (vp
->v_mount
&& (vp
->v_mount
->mnt_flag
& MNT_NODEV
))
219 switch (vp
->v_type
) {
222 if ((u_int
)maj
>= (u_int
)nchrdev
)
224 if (cred
!= FSCRED
&& (ap
->a_mode
& FWRITE
)) {
226 * When running in very secure mode, do not allow
227 * opens for writing of any disk character devices.
229 if (securelevel
>= 2 && isdisk(dev
, VCHR
))
232 * When running in secure mode, do not allow opens
233 * for writing of /dev/mem, /dev/kmem, or character
234 * devices whose corresponding block devices are
237 if (securelevel
>= 1) {
238 if ((bdev
= chrtoblk(dev
)) != NODEV
&& check_mountedon(bdev
, VBLK
, &error
))
244 if (cdevsw
[maj
].d_type
== D_TTY
) {
246 vp
->v_flag
|= VISTTY
;
249 error
= (*cdevsw
[maj
].d_open
)(dev
, ap
->a_mode
, S_IFCHR
, p
);
253 if ((u_int
)maj
>= (u_int
)nblkdev
)
256 * When running in very secure mode, do not allow
257 * opens for writing of any disk block devices.
259 if (securelevel
>= 2 && cred
!= FSCRED
&&
260 (ap
->a_mode
& FWRITE
) && bdevsw
[maj
].d_type
== D_DISK
)
263 * Do not allow opens of block devices that are
266 if ( (error
= vfs_mountedon(vp
)) )
268 error
= (*bdevsw
[maj
].d_open
)(dev
, ap
->a_mode
, S_IFBLK
, p
);
273 u_int32_t size512
= 512;
276 if (!VNOP_IOCTL(vp
, DKIOCGETBLOCKSIZE
, (caddr_t
)&blksize
, 0, ap
->a_context
)) {
277 /* Switch to 512 byte sectors (temporarily) */
279 if (!VNOP_IOCTL(vp
, DKIOCSETBLOCKSIZE
, (caddr_t
)&size512
, FWRITE
, ap
->a_context
)) {
280 /* Get the number of 512 byte physical blocks. */
281 if (!VNOP_IOCTL(vp
, DKIOCGETBLOCKCOUNT
, (caddr_t
)&blkcnt
, 0, ap
->a_context
)) {
285 /* If it doesn't set back, we can't recover */
286 if (VNOP_IOCTL(vp
, DKIOCSETBLOCKSIZE
, (caddr_t
)&blksize
, FWRITE
, ap
->a_context
))
292 set_blocksize(vp
, dev
);
295 * Cache the size in bytes of the block device for later
296 * use by spec_write().
299 vp
->v_specdevsize
= blkcnt
* (u_int64_t
)size512
;
301 vp
->v_specdevsize
= (u_int64_t
)0; /* Default: Can't get */
308 panic("spec_open type");
318 struct vnop_read_args
/* {
322 vfs_context_t a_context;
325 register struct vnode
*vp
= ap
->a_vp
;
326 register struct uio
*uio
= ap
->a_uio
;
328 daddr64_t bn
, nextbn
;
336 if (uio
->uio_rw
!= UIO_READ
)
337 panic("spec_read mode");
338 if (UIO_SEG_IS_USER_SPACE(uio
->uio_segflg
))
339 panic("spec_read proc");
341 if (uio_resid(uio
) == 0)
344 switch (vp
->v_type
) {
347 error
= (*cdevsw
[major(vp
->v_rdev
)].d_read
)
348 (vp
->v_rdev
, uio
, ap
->a_ioflag
);
352 if (uio
->uio_offset
< 0)
357 devBlockSize
= vp
->v_specsize
;
359 if (devBlockSize
> PAGE_SIZE
)
362 bscale
= PAGE_SIZE
/ devBlockSize
;
363 bsize
= bscale
* devBlockSize
;
366 on
= uio
->uio_offset
% bsize
;
368 bn
= (daddr64_t
)((uio
->uio_offset
/ devBlockSize
) &~ (bscale
- 1));
370 if (vp
->v_speclastr
+ bscale
== bn
) {
371 nextbn
= bn
+ bscale
;
372 error
= buf_breadn(vp
, bn
, (int)bsize
, &nextbn
,
373 (int *)&bsize
, 1, NOCRED
, &bp
);
375 error
= buf_bread(vp
, bn
, (int)bsize
, NOCRED
, &bp
);
378 vp
->v_speclastr
= bn
;
381 n
= bsize
- buf_resid(bp
);
382 if ((on
> n
) || error
) {
388 // LP64todo - fix this!
389 n
= min((unsigned)(n
- on
), uio_resid(uio
));
391 error
= uiomove((char *)buf_dataptr(bp
) + on
, n
, uio
);
395 } while (error
== 0 && uio_resid(uio
) > 0 && n
!= 0);
399 panic("spec_read type");
411 struct vnop_write_args
/* {
415 vfs_context_t a_context;
418 register struct vnode
*vp
= ap
->a_vp
;
419 register struct uio
*uio
= ap
->a_uio
;
422 int bsize
, blkmask
, bscale
;
423 register int io_sync
;
424 register int io_size
;
431 if (uio
->uio_rw
!= UIO_WRITE
)
432 panic("spec_write mode");
433 if (UIO_SEG_IS_USER_SPACE(uio
->uio_segflg
))
434 panic("spec_write proc");
437 switch (vp
->v_type
) {
440 error
= (*cdevsw
[major(vp
->v_rdev
)].d_write
)
441 (vp
->v_rdev
, uio
, ap
->a_ioflag
);
445 if (uio_resid(uio
) == 0)
447 if (uio
->uio_offset
< 0)
450 io_sync
= (ap
->a_ioflag
& IO_SYNC
);
451 // LP64todo - fix this!
452 io_size
= uio_resid(uio
);
456 devBlockSize
= vp
->v_specsize
;
457 if (devBlockSize
> PAGE_SIZE
)
460 bscale
= PAGE_SIZE
/ devBlockSize
;
461 blkmask
= bscale
- 1;
462 bsize
= bscale
* devBlockSize
;
466 bn
= (daddr64_t
)((uio
->uio_offset
/ devBlockSize
) &~ blkmask
);
467 on
= uio
->uio_offset
% bsize
;
469 // LP64todo - fix this!
470 n
= min((unsigned)(bsize
- on
), uio_resid(uio
));
473 * Use buf_getblk() as an optimization IFF:
475 * 1) We are reading exactly a block on a block
477 * 2) We know the size of the device from spec_open
478 * 3) The read doesn't span the end of the device
480 * Otherwise, we fall back on buf_bread().
483 vp
->v_specdevsize
!= (u_int64_t
)0 &&
484 (uio
->uio_offset
+ (u_int64_t
)n
) > vp
->v_specdevsize
) {
485 /* reduce the size of the read to what is there */
486 n
= (uio
->uio_offset
+ (u_int64_t
)n
) - vp
->v_specdevsize
;
490 bp
= buf_getblk(vp
, bn
, bsize
, 0, 0, BLK_WRITE
);
492 error
= (int)buf_bread(vp
, bn
, bsize
, NOCRED
, &bp
);
494 /* Translate downstream error for upstream, if needed */
496 error
= (int)buf_error(bp
);
501 n
= min(n
, bsize
- buf_resid(bp
));
503 error
= uiomove((char *)buf_dataptr(bp
) + on
, n
, uio
);
511 error
= buf_bwrite(bp
);
513 if ((n
+ on
) == bsize
)
514 error
= buf_bawrite(bp
);
516 error
= buf_bdwrite(bp
);
518 } while (error
== 0 && uio_resid(uio
) > 0 && n
!= 0);
522 panic("spec_write type");
530 * Device ioctl operation.
534 struct vnop_ioctl_args
/* {
539 vfs_context_t a_context;
542 proc_t p
= vfs_context_proc(ap
->a_context
);
543 dev_t dev
= ap
->a_vp
->v_rdev
;
545 switch (ap
->a_vp
->v_type
) {
548 return ((*cdevsw
[major(dev
)].d_ioctl
)(dev
, ap
->a_command
, ap
->a_data
,
552 if (ap
->a_command
== 0 && (int)ap
->a_data
== B_TAPE
) {
553 if (bdevsw
[major(dev
)].d_type
== D_TAPE
)
558 return ((*bdevsw
[major(dev
)].d_ioctl
)(dev
, ap
->a_command
, ap
->a_data
,
570 struct vnop_select_args
/* {
575 vfs_context_t a_context;
578 proc_t p
= vfs_context_proc(ap
->a_context
);
581 switch (ap
->a_vp
->v_type
) {
584 return (1); /* XXX */
587 dev
= ap
->a_vp
->v_rdev
;
588 return (*cdevsw
[major(dev
)].d_select
)(dev
, ap
->a_which
, ap
->a_wql
, p
);
593 * Synch buffers associated with a block device
596 spec_fsync_internal(vnode_t vp
, int waitfor
, __unused vfs_context_t context
)
598 if (vp
->v_type
== VCHR
)
601 * Flush all dirty buffers associated with a block device.
603 buf_flushdirtyblks(vp
, waitfor
== MNT_WAIT
, 0, (char *)"spec_fsync");
610 struct vnop_fsync_args
/* {
613 vfs_context_t a_context;
616 return spec_fsync_internal(ap
->a_vp
, ap
->a_waitfor
, ap
->a_context
);
620 * Just call the device strategy routine
622 extern int hard_throttle_on_root
;
625 #define LOWPRI_DELAY_MSECS 200
626 #define LOWPRI_WINDOW_MSECS 200
628 int lowpri_IO_window_msecs
= LOWPRI_WINDOW_MSECS
;
629 int lowpri_IO_delay_msecs
= LOWPRI_DELAY_MSECS
;
631 struct timeval last_normal_IO_timestamp
;
632 struct timeval last_lowpri_IO_timestamp
;
633 struct timeval lowpri_IO_window
= { 0, LOWPRI_WINDOW_MSECS
* 1000 };
637 struct vnop_strategy_args
/* {
645 struct timeval elapsed
;
648 bdev
= buf_device(bp
);
649 bflags
= buf_flags(bp
);
656 if (bflags
& B_ASYNC
)
661 else if (bflags
& B_PAGEIO
)
664 KERNEL_DEBUG_CONSTANT(FSDBG_CODE(DBG_DKRW
, code
) | DBG_FUNC_NONE
,
665 (unsigned int)bp
, bdev
, (int)buf_blkno(bp
), buf_count(bp
), 0);
667 if (((bflags
& (B_PAGEIO
| B_READ
)) == (B_PAGEIO
| B_READ
)) &&
668 (buf_vnode(bp
)->v_mount
->mnt_kern_flag
& MNTK_ROOTDEV
))
669 hard_throttle_on_root
= 1;
671 if ( lowpri_IO_delay_msecs
&& lowpri_IO_window_msecs
) {
674 if ( (p
== NULL
) || !(p
->p_lflag
& P_LLOW_PRI_IO
)) {
675 if (!(p
->p_lflag
& P_LBACKGROUND_IO
))
676 microuptime(&last_normal_IO_timestamp
);
678 microuptime(&last_lowpri_IO_timestamp
);
680 elapsed
= last_lowpri_IO_timestamp
;
681 timevalsub(&elapsed
, &last_normal_IO_timestamp
);
683 lowpri_IO_window
.tv_sec
= lowpri_IO_window_msecs
/ 1000;
684 lowpri_IO_window
.tv_usec
= (lowpri_IO_window_msecs
% 1000) * 1000;
686 if (timevalcmp(&elapsed
, &lowpri_IO_window
, <)) {
690 * I'd really like to do the IOSleep here, but
691 * we may be holding all kinds of filesystem related locks
692 * and the pages for this I/O marked 'busy'...
693 * we don't want to cause a normal task to block on
694 * one of these locks while we're throttling a task marked
695 * for low priority I/O... we'll mark the uthread and
696 * do the delay just before we return from the system
697 * call that triggered this I/O or from vnode_pagein
699 ut
= get_bsdthread_info(current_thread());
700 ut
->uu_lowpri_delay
= lowpri_IO_delay_msecs
;
704 (*bdevsw
[major(bdev
)].d_strategy
)(bp
);
711 * This is a noop, simply returning what one has been given.
714 spec_blockmap(__unused
struct vnop_blockmap_args
*ap
)
721 * Device close routine
725 struct vnop_close_args
/* {
728 vfs_context_t a_context;
731 register struct vnode
*vp
= ap
->a_vp
;
732 dev_t dev
= vp
->v_rdev
;
733 int (*devclose
)(dev_t
, int, int, struct proc
*);
735 struct proc
*p
= vfs_context_proc(ap
->a_context
);
737 switch (vp
->v_type
) {
741 * Hack: a tty device that is a controlling terminal
742 * has a reference from the session structure.
743 * We cannot easily tell that a character device is
744 * a controlling terminal, unless it is the closing
745 * process' controlling terminal. In that case,
746 * if the reference count is 2 (this last descriptor
747 * plus the session), release the reference from the session.
749 if (vcount(vp
) == 2 && p
&&
750 vp
== p
->p_session
->s_ttyvp
) {
751 p
->p_session
->s_ttyvp
= NULL
;
755 * close on last reference.
759 devclose
= cdevsw
[major(dev
)].d_close
;
764 #ifdef DEVFS_IMPLEMENTS_LOCKING
766 * On last close of a block device (that isn't mounted)
767 * we must invalidate any in core blocks, so that
768 * we can, for instance, change floppy disks.
770 if ((error
= spec_fsync_internal(vp
, MNT_WAIT
, ap
->a_context
)))
773 error
= buf_invalidateblks(vp
, BUF_WRITE_DATA
, 0, 0);
777 * Since every use (buffer, vnode, swap, blockmap)
778 * holds a reference to the vnode, and because we mark
779 * any other vnodes that alias this device, when the
780 * sum of the reference counts on all the aliased
781 * vnodes descends to one, we are on last close.
785 #else /* DEVFS_IMPLEMENTS_LOCKING */
787 * Since every use (buffer, vnode, swap, blockmap)
788 * holds a reference to the vnode, and because we mark
789 * any other vnodes that alias this device, when the
790 * sum of the reference counts on all the aliased
791 * vnodes descends to one, we are on last close.
797 * On last close of a block device (that isn't mounted)
798 * we must invalidate any in core blocks, so that
799 * we can, for instance, change floppy disks.
801 if ((error
= spec_fsync_internal(vp
, MNT_WAIT
, ap
->a_context
)))
804 error
= buf_invalidateblks(vp
, BUF_WRITE_DATA
, 0, 0);
807 #endif /* DEVFS_IMPLEMENTS_LOCKING */
808 devclose
= bdevsw
[major(dev
)].d_close
;
813 panic("spec_close: not special");
816 return ((*devclose
)(dev
, ap
->a_fflag
, mode
, p
));
820 * Return POSIX pathconf information applicable to special devices.
824 struct vnop_pathconf_args
/* {
828 vfs_context_t a_context;
832 switch (ap
->a_name
) {
834 *ap
->a_retval
= LINK_MAX
;
837 *ap
->a_retval
= MAX_CANON
;
840 *ap
->a_retval
= MAX_INPUT
;
843 *ap
->a_retval
= PIPE_BUF
;
845 case _PC_CHOWN_RESTRICTED
:
849 *ap
->a_retval
= _POSIX_VDISABLE
;
858 spec_devblocksize(ap
)
859 struct vnop_devblocksize_args
/* {
864 *ap
->a_retval
= (ap
->a_vp
->v_specsize
);
869 * Special device failed operation
872 spec_ebadf(__unused
void *dummy
)
879 * Special device bad operation
885 panic("spec_badop called");
889 /* Blktooff derives file offset from logical block number */
892 struct vnop_blktooff_args
/* {
898 register struct vnode
*vp
= ap
->a_vp
;
900 switch (vp
->v_type
) {
902 *ap
->a_offset
= (off_t
)-1; /* failure */
906 printf("spec_blktooff: not implemented for VBLK\n");
907 *ap
->a_offset
= (off_t
)-1; /* failure */
911 panic("spec_blktooff type");
918 /* Offtoblk derives logical block number from file offset */
921 struct vnop_offtoblk_args
/* {
927 register struct vnode
*vp
= ap
->a_vp
;
929 switch (vp
->v_type
) {
931 *ap
->a_lblkno
= (daddr64_t
)-1; /* failure */
935 printf("spec_offtoblk: not implemented for VBLK\n");
936 *ap
->a_lblkno
= (daddr64_t
)-1; /* failure */
940 panic("spec_offtoblk type");