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) 1982, 1986, 1989, 1993
25 * The Regents of the University of California. All rights reserved.
26 * (c) UNIX System Laboratories, Inc.
27 * All or some portions of this file are derived from material licensed
28 * to the University of California by American Telephone and Telegraph
29 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
30 * the permission of UNIX System Laboratories, Inc.
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
35 * 1. Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * 2. Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in the
39 * documentation and/or other materials provided with the distribution.
40 * 3. All advertising materials mentioning features or use of this software
41 * must display the following acknowledgement:
42 * This product includes software developed by the University of
43 * California, Berkeley and its contributors.
44 * 4. Neither the name of the University nor the names of its contributors
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
48 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * @(#)vfs_vnops.c 8.14 (Berkeley) 6/15/95
64 #include <sys/param.h>
65 #include <sys/types.h>
66 #include <sys/systm.h>
67 #include <sys/kernel.h>
68 #include <sys/file_internal.h>
70 #include <sys/proc_internal.h>
71 #include <sys/kauth.h>
72 #include <sys/mount_internal.h>
73 #include <sys/namei.h>
74 #include <sys/vnode_internal.h>
75 #include <sys/ioctl.h>
80 #include <sys/fsevents.h>
81 #include <sys/kdebug.h>
82 #include <sys/xattr.h>
83 #include <sys/ubc_internal.h>
84 #include <sys/uio_internal.h>
86 #include <vm/vm_kern.h>
87 #include <vm/vm_map.h>
89 #include <miscfs/specfs/specdev.h>
93 static int vn_closefile(struct fileglob
*fp
, struct proc
*p
);
94 static int vn_ioctl(struct fileproc
*fp
, u_long com
, caddr_t data
, struct proc
*p
);
95 static int vn_read(struct fileproc
*fp
, struct uio
*uio
,
96 kauth_cred_t cred
, int flags
, struct proc
*p
);
97 static int vn_write(struct fileproc
*fp
, struct uio
*uio
,
98 kauth_cred_t cred
, int flags
, struct proc
*p
);
99 static int vn_select( struct fileproc
*fp
, int which
, void * wql
, struct proc
*p
);
100 static int vn_kqfilt_add(struct fileproc
*fp
, struct knote
*kn
, struct proc
*p
);
102 static int vn_kqfilt_remove(struct vnode
*vp
, uintptr_t ident
, struct proc
*p
);
105 struct fileops vnops
=
106 { vn_read
, vn_write
, vn_ioctl
, vn_select
, vn_closefile
, vn_kqfilt_add
, 0 };
109 * Common code for vnode open operations.
110 * Check permissions, and call the VNOP_OPEN or VNOP_CREATE routine.
112 * XXX the profusion of interfaces here is probably a bad thing.
115 vn_open(struct nameidata
*ndp
, int fmode
, int cmode
)
117 return(vn_open_modflags(ndp
, &fmode
, cmode
));
121 vn_open_modflags(struct nameidata
*ndp
, int *fmodep
, int cmode
)
123 struct vnode_attr va
;
126 VATTR_SET(&va
, va_mode
, cmode
);
128 return(vn_open_auth(ndp
, fmodep
, &va
));
132 vn_open_auth(struct nameidata
*ndp
, int *fmodep
, struct vnode_attr
*vap
)
136 vfs_context_t ctx
= ndp
->ni_cnd
.cn_context
;
139 kauth_action_t action
;
145 if (fmode
& O_CREAT
) {
146 ndp
->ni_cnd
.cn_nameiop
= CREATE
;
147 ndp
->ni_cnd
.cn_flags
= LOCKPARENT
| LOCKLEAF
| AUDITVNPATH1
;
149 if ((fmode
& O_EXCL
) == 0)
150 ndp
->ni_cnd
.cn_flags
|= FOLLOW
;
151 if ( (error
= namei(ndp
)) )
156 /* not found, create */
158 /* must have attributes for a new file */
164 /* authorize before creating */
165 if ((error
= vnode_authorize(dvp
, NULL
, KAUTH_VNODE_ADD_FILE
, ctx
)) != 0)
168 VATTR_SET(vap
, va_type
, VREG
);
170 vap
->va_vaflags
|= VA_EXCLUSIVE
;
172 if ((error
= vn_create(dvp
, &ndp
->ni_vp
, &ndp
->ni_cnd
, vap
, 0, ctx
)) != 0)
178 int update_flags
= 0;
180 // Make sure the name & parent pointers are hooked up
181 if (vp
->v_name
== NULL
)
182 update_flags
|= VNODE_UPDATE_NAME
;
183 if (vp
->v_parent
== NULLVP
)
184 update_flags
|= VNODE_UPDATE_PARENT
;
187 vnode_update_identity(vp
, dvp
, ndp
->ni_cnd
.cn_nameptr
, ndp
->ni_cnd
.cn_namelen
, ndp
->ni_cnd
.cn_hash
, update_flags
);
189 if (need_fsevent(FSE_CREATE_FILE
, vp
)) {
190 add_fsevent(FSE_CREATE_FILE
, ctx
,
196 * nameidone has to happen before we vnode_put(dvp)
197 * and clear the ni_dvp field, since it may need
198 * to release the fs_nodelock on the dvp
207 * Check for a creation race.
209 if ((error
== EEXIST
) && !(fmode
& O_EXCL
)) {
220 if (fmode
& O_EXCL
) {
227 ndp
->ni_cnd
.cn_nameiop
= LOOKUP
;
228 ndp
->ni_cnd
.cn_flags
= FOLLOW
| LOCKLEAF
| AUDITVNPATH1
;
229 if ( (error
= namei(ndp
)) )
235 if (vp
->v_type
== VSOCK
&& vp
->v_tag
!= VT_FDESC
) {
236 error
= EOPNOTSUPP
; /* Operation not supported on socket */
241 if (UBCINFOMISSING(vp
))
242 panic("vn_open: ubc_info_init");
243 #endif /* DIAGNOSTIC */
245 /* authorize open of an existing file */
246 if ((fmode
& O_CREAT
) == 0) {
248 /* disallow write operations on directories */
249 if (vnode_isdir(vp
) && (fmode
& (FWRITE
| O_TRUNC
))) {
254 /* compute action to be authorized */
257 action
|= KAUTH_VNODE_READ_DATA
;
258 if (fmode
& (FWRITE
| O_TRUNC
))
259 action
|= KAUTH_VNODE_WRITE_DATA
;
260 if ((error
= vnode_authorize(vp
, NULL
, action
, ctx
)) != 0)
265 if ( (error
= VNOP_OPEN(vp
, fmode
, ctx
)) ) {
268 if ( (error
= vnode_ref_ext(vp
, fmode
)) )
271 /* call out to allow 3rd party notification of open.
272 * Ignore result of kauth_authorize_fileop call.
274 kauth_authorize_fileop(vfs_context_ucred(ctx
), KAUTH_FILEOP_OPEN
,
284 * Check for a race against unlink. We had a vnode
285 * but according to vnode_authorize or VNOP_OPEN it
288 if ((error
== ENOENT
) && (*fmodep
& O_CREAT
)) {
297 * Authorize an action against a vnode. This has been the canonical way to
298 * ensure that the credential/process/etc. referenced by a vfs_context
299 * is granted the rights called out in 'mode' against the vnode 'vp'.
301 * Unfortunately, the use of VREAD/VWRITE/VEXEC makes it very difficult
302 * to add support for more rights. As such, this interface will be deprecated
303 * and callers will use vnode_authorize instead.
305 #warning vn_access is deprecated
307 vn_access(vnode_t vp
, int mode
, vfs_context_t context
)
309 kauth_action_t action
;
313 action
|= KAUTH_VNODE_READ_DATA
;
315 action
|= KAUTH_VNODE_WRITE_DATA
;
317 action
|= KAUTH_VNODE_EXECUTE
;
319 return(vnode_authorize(vp
, NULL
, action
, context
));
326 vn_close(struct vnode
*vp
, int flags
, kauth_cred_t cred
, struct proc
*p
)
328 struct vfs_context context
;
332 context
.vc_ucred
= cred
;
334 if (flags
& FWASWRITTEN
) {
335 if (need_fsevent(FSE_CONTENT_MODIFIED
, vp
)) {
336 add_fsevent(FSE_CONTENT_MODIFIED
, &context
,
342 error
= VNOP_CLOSE(vp
, flags
, &context
);
343 (void)vnode_rele_ext(vp
, flags
, 0);
353 static char *swap_read_zero_page
= NULL
;
355 off_t swap_count
, this_count
;
356 off_t file_end
, read_end
;
360 * Reading from a swap file will get you all zeroes.
363 swap_count
= uio_resid(uio
);
365 file_end
= ubc_getsize(vp
);
366 read_end
= uio
->uio_offset
+ uio_resid(uio
);
367 if (uio
->uio_offset
>= file_end
) {
368 /* uio starts after end of file: nothing to read */
370 } else if (read_end
> file_end
) {
371 /* uio extends beyond end of file: stop before that */
372 swap_count
-= (read_end
- file_end
);
375 while (swap_count
> 0) {
376 if (swap_read_zero_page
== NULL
) {
381 * Take kernel funnel so that only one thread
382 * sets up "swap_read_zero_page".
384 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
386 if (swap_read_zero_page
== NULL
) {
387 MALLOC(my_zero_page
, char *, PAGE_SIZE
,
389 memset(my_zero_page
, '?', PAGE_SIZE
);
391 * Adding a newline character here
392 * and there prevents "less(1)", for
393 * example, from getting too confused
394 * about a file with one really really
397 my_zero_page
[PAGE_SIZE
-1] = '\n';
398 if (swap_read_zero_page
== NULL
) {
399 swap_read_zero_page
= my_zero_page
;
401 FREE(my_zero_page
, M_TEMP
);
405 * Someone else raced us here and won;
406 * just use their page.
409 thread_funnel_set(kernel_flock
, funnel_state
);
412 this_count
= swap_count
;
413 if (this_count
> PAGE_SIZE
) {
414 this_count
= PAGE_SIZE
;
417 prev_resid
= uio_resid(uio
);
418 error
= uiomove((caddr_t
) swap_read_zero_page
,
424 swap_count
-= (prev_resid
- uio_resid(uio
));
430 * Package up an I/O request on a vnode into a uio and do it.
445 return vn_rdwr_64(rw
,
447 (uint64_t)(uintptr_t)base
,
473 struct vfs_context context
;
475 char uio_buf
[ UIO_SIZEOF(1) ];
478 context
.vc_ucred
= cred
;
480 if (UIO_SEG_IS_USER_SPACE(segflg
)) {
481 spacetype
= proc_is64bit(p
) ? UIO_USERSPACE64
: UIO_USERSPACE32
;
484 spacetype
= UIO_SYSSPACE
;
486 auio
= uio_createwithbuffer(1, offset
, spacetype
, rw
,
487 &uio_buf
[0], sizeof(uio_buf
));
488 uio_addiov(auio
, base
, len
);
490 if (rw
== UIO_READ
) {
491 if (vp
->v_flag
& VSWAP
) {
492 error
= vn_read_swapfile(vp
, auio
);
494 error
= VNOP_READ(vp
, auio
, ioflg
, &context
);
497 error
= VNOP_WRITE(vp
, auio
, ioflg
, &context
);
501 // LP64todo - fix this
502 *aresid
= uio_resid(auio
);
504 if (uio_resid(auio
) && error
== 0)
510 * File table vnode read routine.
513 vn_read(struct fileproc
*fp
, struct uio
*uio
, kauth_cred_t cred
,
514 int flags
, struct proc
*p
)
519 struct vfs_context context
;
522 context
.vc_ucred
= cred
;
524 vp
= (struct vnode
*)fp
->f_fglob
->fg_data
;
525 if ( (error
= vnode_getwithref(vp
)) ) {
529 if (fp
->f_fglob
->fg_flag
& FNONBLOCK
)
532 if ((flags
& FOF_OFFSET
) == 0)
533 uio
->uio_offset
= fp
->f_fglob
->fg_offset
;
534 count
= uio_resid(uio
);
536 if (vp
->v_flag
& VSWAP
) {
537 /* special case for swap files */
538 error
= vn_read_swapfile(vp
, uio
);
540 error
= VNOP_READ(vp
, uio
, ioflag
, &context
);
542 if ((flags
& FOF_OFFSET
) == 0)
543 fp
->f_fglob
->fg_offset
+= count
- uio_resid(uio
);
551 * File table vnode write routine.
554 vn_write(struct fileproc
*fp
, struct uio
*uio
, kauth_cred_t cred
,
555 int flags
, struct proc
*p
)
560 struct vfs_context context
;
563 context
.vc_ucred
= cred
;
565 vp
= (struct vnode
*)fp
->f_fglob
->fg_data
;
566 if ( (error
= vnode_getwithref(vp
)) ) {
570 if (vp
->v_type
== VREG
&& (fp
->f_fglob
->fg_flag
& O_APPEND
))
572 if (fp
->f_fglob
->fg_flag
& FNONBLOCK
)
574 if ((fp
->f_fglob
->fg_flag
& O_FSYNC
) ||
575 (vp
->v_mount
&& (vp
->v_mount
->mnt_flag
& MNT_SYNCHRONOUS
)))
578 if ((flags
& FOF_OFFSET
) == 0) {
579 uio
->uio_offset
= fp
->f_fglob
->fg_offset
;
580 count
= uio_resid(uio
);
582 if (p
&& (vp
->v_type
== VREG
) &&
583 (((uio
->uio_offset
+ uio_uio_resid(uio
)) > p
->p_rlimit
[RLIMIT_FSIZE
].rlim_cur
) ||
584 (uio_uio_resid(uio
) > (p
->p_rlimit
[RLIMIT_FSIZE
].rlim_cur
- uio
->uio_offset
)))) {
590 error
= VNOP_WRITE(vp
, uio
, ioflag
, &context
);
592 if ((flags
& FOF_OFFSET
) == 0) {
593 if (ioflag
& IO_APPEND
)
594 fp
->f_fglob
->fg_offset
= uio
->uio_offset
;
596 fp
->f_fglob
->fg_offset
+= count
- uio_resid(uio
);
600 * Set the credentials on successful writes
602 if ((error
== 0) && (vp
->v_tag
== VT_NFS
) && (UBCINFOEXISTS(vp
))) {
610 * File table vnode stat routine.
613 vn_stat_noauth(struct vnode
*vp
, struct stat
*sb
, kauth_filesec_t
*xsec
, vfs_context_t ctx
)
615 struct vnode_attr va
;
618 kauth_filesec_t fsec
;
621 VATTR_WANTED(&va
, va_fsid
);
622 VATTR_WANTED(&va
, va_fileid
);
623 VATTR_WANTED(&va
, va_mode
);
624 VATTR_WANTED(&va
, va_type
);
625 VATTR_WANTED(&va
, va_nlink
);
626 VATTR_WANTED(&va
, va_uid
);
627 VATTR_WANTED(&va
, va_gid
);
628 VATTR_WANTED(&va
, va_rdev
);
629 VATTR_WANTED(&va
, va_data_size
);
630 VATTR_WANTED(&va
, va_access_time
);
631 VATTR_WANTED(&va
, va_modify_time
);
632 VATTR_WANTED(&va
, va_change_time
);
633 VATTR_WANTED(&va
, va_flags
);
634 VATTR_WANTED(&va
, va_gen
);
635 VATTR_WANTED(&va
, va_iosize
);
636 /* lower layers will synthesise va_total_alloc from va_data_size if required */
637 VATTR_WANTED(&va
, va_total_alloc
);
639 VATTR_WANTED(&va
, va_uuuid
);
640 VATTR_WANTED(&va
, va_guuid
);
641 VATTR_WANTED(&va
, va_acl
);
643 error
= vnode_getattr(vp
, &va
, ctx
);
647 * Copy from vattr table
649 sb
->st_dev
= va
.va_fsid
;
650 sb
->st_ino
= (ino_t
)va
.va_fileid
;
652 switch (vp
->v_type
) {
679 sb
->st_nlink
= VATTR_IS_SUPPORTED(&va
, va_nlink
) ? (u_int16_t
)va
.va_nlink
: 1;
680 sb
->st_uid
= va
.va_uid
;
681 sb
->st_gid
= va
.va_gid
;
682 sb
->st_rdev
= va
.va_rdev
;
683 sb
->st_size
= va
.va_data_size
;
684 sb
->st_atimespec
= va
.va_access_time
;
685 sb
->st_mtimespec
= va
.va_modify_time
;
686 sb
->st_ctimespec
= va
.va_change_time
;
687 sb
->st_blksize
= va
.va_iosize
;
688 sb
->st_flags
= va
.va_flags
;
689 sb
->st_blocks
= roundup(va
.va_total_alloc
, 512) / 512;
691 /* if we're interested in exended security data and we got an ACL */
693 if (!VATTR_IS_SUPPORTED(&va
, va_acl
) &&
694 !VATTR_IS_SUPPORTED(&va
, va_uuuid
) &&
695 !VATTR_IS_SUPPORTED(&va
, va_guuid
)) {
696 *xsec
= KAUTH_FILESEC_NONE
;
699 if (VATTR_IS_SUPPORTED(&va
, va_acl
) && (va
.va_acl
!= NULL
)) {
700 fsec
= kauth_filesec_alloc(va
.va_acl
->acl_entrycount
);
702 fsec
= kauth_filesec_alloc(0);
708 fsec
->fsec_magic
= KAUTH_FILESEC_MAGIC
;
709 if (VATTR_IS_SUPPORTED(&va
, va_uuuid
)) {
710 fsec
->fsec_owner
= va
.va_uuuid
;
712 fsec
->fsec_owner
= kauth_null_guid
;
714 if (VATTR_IS_SUPPORTED(&va
, va_guuid
)) {
715 fsec
->fsec_group
= va
.va_guuid
;
717 fsec
->fsec_group
= kauth_null_guid
;
719 if (VATTR_IS_SUPPORTED(&va
, va_acl
) && (va
.va_acl
!= NULL
)) {
720 bcopy(va
.va_acl
, &(fsec
->fsec_acl
), KAUTH_ACL_COPYSIZE(va
.va_acl
));
722 fsec
->fsec_acl
.acl_entrycount
= KAUTH_FILESEC_NOACL
;
728 /* Do not give the generation number out to unpriviledged users */
729 if (va
.va_gen
&& !vfs_context_issuser(ctx
))
732 sb
->st_gen
= va
.va_gen
;
736 if (VATTR_IS_SUPPORTED(&va
, va_acl
) && va
.va_acl
!= NULL
)
737 kauth_acl_free(va
.va_acl
);
742 vn_stat(struct vnode
*vp
, struct stat
*sb
, kauth_filesec_t
*xsec
, vfs_context_t ctx
)
747 if ((error
= vnode_authorize(vp
, NULL
, KAUTH_VNODE_READ_ATTRIBUTES
| KAUTH_VNODE_READ_SECURITY
, ctx
)) != 0)
751 return(vn_stat_noauth(vp
, sb
, xsec
, ctx
));
756 * File table vnode ioctl routine.
759 vn_ioctl(fp
, com
, data
, p
)
765 register struct vnode
*vp
= ((struct vnode
*)fp
->f_fglob
->fg_data
);
766 struct vfs_context context
;
772 if ( (error
= vnode_getwithref(vp
)) ) {
776 context
.vc_ucred
= p
->p_ucred
; /* XXX kauth_cred_get() ??? */
778 switch (vp
->v_type
) {
782 if (com
== FIONREAD
) {
783 if ((error
= vnode_size(vp
, &file_size
, &context
)) != 0)
785 *(int *)data
= file_size
- fp
->f_fglob
->fg_offset
;
788 if (com
== FIONBIO
|| com
== FIOASYNC
) { /* XXX */
801 /* Should not be able to set block size from user space */
802 if (com
== DKIOCSETBLOCKSIZE
) {
807 if (com
== FIODTYPE
) {
808 if (vp
->v_type
== VBLK
) {
809 if (major(vp
->v_rdev
) >= nblkdev
) {
813 *(int *)data
= bdevsw
[major(vp
->v_rdev
)].d_type
;
815 } else if (vp
->v_type
== VCHR
) {
816 if (major(vp
->v_rdev
) >= nchrdev
) {
820 *(int *)data
= cdevsw
[major(vp
->v_rdev
)].d_type
;
827 error
= VNOP_IOCTL(vp
, com
, data
, fp
->f_fglob
->fg_flag
, &context
);
829 if (error
== 0 && com
== TIOCSCTTY
) {
832 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
833 ttyvp
= p
->p_session
->s_ttyvp
;
834 p
->p_session
->s_ttyvp
= vp
;
835 thread_funnel_set(kernel_flock
, funnel_state
);
847 * File table vnode select routine.
850 vn_select(fp
, which
, wql
, p
)
857 struct vnode
* vp
= (struct vnode
*)fp
->f_fglob
->fg_data
;
858 struct vfs_context context
;
860 if ( (error
= vnode_getwithref(vp
)) == 0 ) {
862 context
.vc_ucred
= fp
->f_fglob
->fg_cred
;
864 error
= VNOP_SELECT(vp
, which
, fp
->f_fglob
->fg_flag
, wql
, &context
);
873 * Check that the vnode is still valid, and if so
874 * acquire requested lock.
877 vn_lock(__unused vnode_t vp
, __unused
int flags
, __unused proc_t p
)
883 * File table vnode close routine.
890 struct vnode
*vp
= (struct vnode
*)fg
->fg_data
;
893 if ( (error
= vnode_getwithref(vp
)) == 0 ) {
894 error
= vn_close(vp
, fg
->fg_flag
, fg
->fg_cred
, p
);
902 vn_pathconf(vnode_t vp
, int name
, register_t
*retval
, vfs_context_t ctx
)
907 case _PC_EXTENDED_SECURITY_NP
:
908 *retval
= vfs_extendedsecurity(vnode_mount(vp
));
910 case _PC_AUTH_OPAQUE_NP
:
911 *retval
= vfs_authopaque(vnode_mount(vp
));
914 error
= VNOP_PATHCONF(vp
, name
, retval
, ctx
);
922 vn_kqfilt_add(fp
, kn
, p
)
927 struct vnode
*vp
= (struct vnode
*)fp
->f_fglob
->fg_data
;
928 struct vfs_context context
;
932 if ( (error
= vnode_getwithref(vp
)) == 0 ) {
934 context
.vc_ucred
= p
->p_ucred
; /* XXX kauth_cred_get() ??? */
936 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
937 error
= VNOP_KQFILT_ADD(vp
, kn
, &context
);
938 thread_funnel_set(kernel_flock
, funnel_state
);
946 /* No one calls this yet. */
948 vn_kqfilt_remove(vp
, ident
, p
)
953 struct vfs_context context
;
957 if ( (error
= vnode_getwithref(vp
)) == 0 ) {
959 context
.vc_ucred
= p
->p_ucred
; /* XXX kauth_cred_get() ??? */
961 funnel_state
= thread_funnel_set(kernel_flock
, TRUE
);
962 error
= VNOP_KQFILT_REMOVE(vp
, ident
, &context
);
963 thread_funnel_set(kernel_flock
, funnel_state
);