]>
git.saurik.com Git - apple/xnu.git/blob - bsd/vfs/vfs_support.c
2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * Copyright (c) 1998-1999 Apple Computer, Inc. All rights reserved.
31 * File: vfs/vfs_support.c
33 * The default VFS routines. A VFS plugin can use these
34 * functions in case it does not want to implement all. These functions
35 * take care of releasing locks and free up memory that they are
38 * nop_* routines always return 0 [success]
39 * err_* routines always return ENOTSUP
41 * This file could be auto-generated from vnode_if.src. but that needs
42 * support for freeing cnp.
45 * 15-Jul-1998 Earsh Nandkeshwar (earsh@apple.com)
46 * Fixed up readdirattr for its existance now.
47 * 18-Aug-1998 Umesh Vaishampayan (umeshv@apple.com)
51 #include <vfs/vfs_support.h>
52 #include <sys/kauth.h>
53 #include <sys/ubc.h> /* ubc_upl_abort_range() */
56 struct vnop_create_args
/* {
57 * struct vnode *a_dvp;
58 * struct vnode **a_vpp;
59 * struct componentname *a_cnp;
60 * struct vnode_vattr *a_vap;
61 * vfs_context_t a_context;
65 nop_create(__unused
struct vnop_create_args
*ap
)
68 if ((ap
->a_cnp
->cn_flags
& HASBUF
) == 0) {
69 panic("nop_create: no name");
76 err_create(struct vnop_create_args
*ap
)
83 struct vnop_whiteout_args
/* {
84 * struct vnode *a_dvp;
85 * struct componentname *a_cnp;
87 * vfs_context_t a_context;
91 nop_whiteout(__unused
struct vnop_whiteout_args
*ap
)
97 err_whiteout(__unused
struct vnop_whiteout_args
*ap
)
103 struct vnop_mknod_args
/* {
104 * struct vnode *a_dvp;
105 * struct vnode **a_vpp;
106 * struct componentname *a_cnp;
107 * struct vnode_vattr *a_vap;
108 * vfs_context_t a_context;
112 nop_mknod(__unused
struct vnop_mknod_args
*ap
)
115 if ((ap
->a_cnp
->cn_flags
& HASBUF
) == 0) {
116 panic("nop_mknod: no name");
123 err_mknod(struct vnop_mknod_args
*ap
)
129 struct vnop_open_args
/* {
130 * struct vnode *a_vp;
132 * vfs_context_t a_context;
136 nop_open(__unused
struct vnop_open_args
*ap
)
142 err_open(__unused
struct vnop_open_args
*ap
)
148 struct vnop_close_args
/* {
149 * struct vnode *a_vp;
151 * vfs_context_t a_context;
155 nop_close(__unused
struct vnop_close_args
*ap
)
161 err_close(__unused
struct vnop_close_args
*ap
)
167 struct vnop_access_args
/* {
168 * struct vnode *a_vp;
170 * vfs_context_t a_context;
174 nop_access(__unused
struct vnop_access_args
*ap
)
180 err_access(__unused
struct vnop_access_args
*ap
)
186 struct vnop_getattr_args
/* {
187 * struct vnode *a_vp;
188 * struct vnode_vattr *a_vap;
189 * vfs_context_t a_context;
193 nop_getattr(__unused
struct vnop_getattr_args
*ap
)
199 err_getattr(__unused
struct vnop_getattr_args
*ap
)
205 struct vnop_setattr_args
/* {
206 * struct vnode *a_vp;
207 * struct vnode_vattr *a_vap;
208 * vfs_context_t a_context;
212 nop_setattr(__unused
struct vnop_setattr_args
*ap
)
218 err_setattr(__unused
struct vnop_setattr_args
*ap
)
223 struct vnop_read_args
/* {
224 * struct vnode *a_vp;
227 * vfs_context_t a_context;
231 nop_read(__unused
struct vnop_read_args
*ap
)
237 err_read(__unused
struct vnop_read_args
*ap
)
243 struct vnop_write_args
/* {
244 * struct vnode *a_vp;
247 * vfs_context_t a_context;
251 nop_write(__unused
struct vnop_write_args
*ap
)
257 err_write(__unused
struct vnop_write_args
*ap
)
263 struct vnop_ioctl_args
/* {
264 * struct vnode *a_vp;
268 * kauth_cred_t a_cred;
273 nop_ioctl(__unused
struct vnop_ioctl_args
*ap
)
279 err_ioctl(__unused
struct vnop_ioctl_args
*ap
)
285 struct vnop_select_args
/* {
286 * struct vnode *a_vp;
289 * kauth_cred_t a_cred;
295 nop_select(__unused
struct vnop_select_args
*ap
)
301 err_select(__unused
struct vnop_select_args
*ap
)
307 struct vnop_exchange_args
/* {
308 * struct vnode *a_fvp;
309 * struct vnode *a_tvp;
311 * vfs_context_t a_context;
315 nop_exchange(__unused
struct vnop_exchange_args
*ap
)
321 err_exchange(__unused
struct vnop_exchange_args
*ap
)
327 struct vnop_revoke_args
/* {
328 * struct vnode *a_vp;
330 * vfs_context_t a_context;
334 nop_revoke(struct vnop_revoke_args
*ap
)
336 return vn_revoke(ap
->a_vp
, ap
->a_flags
, ap
->a_context
);
340 err_revoke(struct vnop_revoke_args
*ap
)
342 (void)nop_revoke(ap
);
347 struct vnop_mmap_args
/* {
348 * struct vnode *a_vp;
350 * kauth_cred_t a_cred;
355 nop_mmap(__unused
struct vnop_mmap_args
*ap
)
361 err_mmap(__unused
struct vnop_mmap_args
*ap
)
367 struct vnop_fsync_args
/* {
368 * struct vnode *a_vp;
370 * vfs_context_t a_context;
374 nop_fsync(__unused
struct vnop_fsync_args
*ap
)
380 err_fsync(__unused
struct vnop_fsync_args
*ap
)
386 struct vnop_remove_args
/* {
387 * struct vnode *a_dvp;
388 * struct vnode *a_vp;
389 * struct componentname *a_cnp;
391 * vfs_context_t a_context;
395 nop_remove(__unused
struct vnop_remove_args
*ap
)
401 err_remove(struct vnop_remove_args
*ap
)
403 (void)nop_remove(ap
);
408 struct vnop_link_args
/* {
409 * struct vnode *a_vp;
410 * struct vnode *a_tdvp;
411 * struct componentname *a_cnp;
412 * vfs_context_t a_context;
416 nop_link(__unused
struct vnop_link_args
*ap
)
422 err_link(struct vnop_link_args
*ap
)
429 struct vnop_rename_args
/* {
430 * struct vnode *a_fdvp;
431 * struct vnode *a_fvp;
432 * struct componentname *a_fcnp;
433 * struct vnode *a_tdvp;
434 * struct vnode *a_tvp;
435 * struct componentname *a_tcnp;
436 * vfs_context_t a_context;
440 nop_rename(__unused
struct vnop_rename_args
*ap
)
446 err_rename(struct vnop_rename_args
*ap
)
448 (void)nop_rename(ap
);
453 struct vnop_mkdir_args
/* {
454 * struct vnode *a_dvp;
455 * struct vnode **a_vpp;
456 * struct componentname *a_cnp;
457 * struct vnode_vattr *a_vap;
458 * vfs_context_t a_context;
462 nop_mkdir(__unused
struct vnop_mkdir_args
*ap
)
468 err_mkdir(__unused
struct vnop_mkdir_args
*ap
)
474 struct vnop_rmdir_args
/* {
475 * struct vnode *a_dvp;
476 * struct vnode *a_vp;
477 * struct componentname *a_cnp;
478 * vfs_context_t a_context;
482 nop_rmdir(__unused
struct vnop_rmdir_args
*ap
)
488 err_rmdir(struct vnop_rmdir_args
*ap
)
495 struct vnop_symlink_args
/* {
496 * struct vnode *a_dvp;
497 * struct vnode **a_vpp;
498 * struct componentname *a_cnp;
499 * struct vnode_vattr *a_vap;
501 * vfs_context_t a_context;
505 nop_symlink(__unused
struct vnop_symlink_args
*ap
)
508 if ((ap
->a_cnp
->cn_flags
& HASBUF
) == 0) {
509 panic("nop_symlink: no name");
516 err_symlink(struct vnop_symlink_args
*ap
)
518 (void)nop_symlink(ap
);
523 struct vnop_readdir_args
/* {
529 * vfs_context_t a_context;
533 nop_readdir(__unused
struct vnop_readdir_args
*ap
)
539 err_readdir(__unused
struct vnop_readdir_args
*ap
)
545 struct vnop_readdirattr_args
/* {
546 * struct vnodeop_desc *a_desc;
548 * struct attrlist *a_alist;
552 * u_long *a_newstate;
554 * u_long *a_actualcount;
555 * vfs_context_t a_context;
559 nop_readdirattr(struct vnop_readdirattr_args
*ap
)
561 *(ap
->a_actualcount
) = 0;
562 *(ap
->a_eofflag
) = 0;
567 err_readdirattr(struct vnop_readdirattr_args
*ap
)
569 (void)nop_readdirattr(ap
);
574 struct vnop_readlink_args
/* {
577 * vfs_context_t a_context;
581 nop_readlink(__unused
struct vnop_readlink_args
*ap
)
587 err_readlink(__unused
struct vnop_readlink_args
*ap
)
593 struct vnop_inactive_args
/* {
594 * struct vnode *a_vp;
595 * vfs_context_t a_context;
599 nop_inactive(__unused
struct vnop_inactive_args
*ap
)
605 err_inactive(struct vnop_inactive_args
*ap
)
607 (void)nop_inactive(ap
);
612 struct vnop_reclaim_args
/* {
613 * struct vnode *a_vp;
614 * vfs_context_t a_context;
618 nop_reclaim(__unused
struct vnop_reclaim_args
*ap
)
624 err_reclaim(__unused
struct vnop_reclaim_args
*ap
)
630 struct vnop_strategy_args
/* {
635 nop_strategy(__unused
struct vnop_strategy_args
*ap
)
641 err_strategy(__unused
struct vnop_strategy_args
*ap
)
647 struct vnop_pathconf_args
/* {
648 * struct vnode *a_vp;
651 * vfs_context_t a_context;
655 nop_pathconf(__unused
struct vnop_pathconf_args
*ap
)
661 err_pathconf(__unused
struct vnop_pathconf_args
*ap
)
667 struct vnop_advlock_args
/* {
668 * struct vnode *a_vp;
671 * struct flock *a_fl;
673 * vfs_context_t a_context;
677 nop_advlock(__unused
struct vnop_advlock_args
*ap
)
683 err_advlock(__unused
struct vnop_advlock_args
*ap
)
690 struct vnop_allocate_args
/* {
691 * struct vnode *a_vp;
694 * off_t *a_bytesallocated;
696 * vfs_context_t a_context;
700 nop_allocate(struct vnop_allocate_args
*ap
)
702 *(ap
->a_bytesallocated
) = 0;
707 err_allocate(struct vnop_allocate_args
*ap
)
709 (void)nop_allocate(ap
);
713 struct vnop_bwrite_args
/* {
718 nop_bwrite(struct vnop_bwrite_args
*ap
)
720 return (int)buf_bwrite(ap
->a_bp
);
724 err_bwrite(__unused
struct vnop_bwrite_args
*ap
)
730 struct vnop_pagein_args
/* {
731 * struct vnode *a_vp,
733 * vm_offset_t a_pl_offset,
737 * vfs_context_t a_context;
741 nop_pagein(struct vnop_pagein_args
*ap
)
743 if (!(ap
->a_flags
& UPL_NOCOMMIT
)) {
744 assert(ap
->a_size
<= UINT32_MAX
);
745 ubc_upl_abort_range(ap
->a_pl
, ap
->a_pl_offset
, (upl_size_t
)ap
->a_size
, UPL_ABORT_FREE_ON_EMPTY
| UPL_ABORT_ERROR
);
751 err_pagein(struct vnop_pagein_args
*ap
)
753 if (!(ap
->a_flags
& UPL_NOCOMMIT
)) {
754 assert(ap
->a_size
<= UINT32_MAX
);
755 ubc_upl_abort_range(ap
->a_pl
, ap
->a_pl_offset
, (upl_size_t
)ap
->a_size
, UPL_ABORT_FREE_ON_EMPTY
| UPL_ABORT_ERROR
);
761 struct vnop_pageout_args
/* {
762 * struct vnode *a_vp,
764 * vm_offset_t a_pl_offset,
768 * vfs_context_t a_context;
772 nop_pageout(struct vnop_pageout_args
*ap
)
774 if (!(ap
->a_flags
& UPL_NOCOMMIT
)) {
775 assert(ap
->a_size
<= UINT32_MAX
);
776 ubc_upl_abort_range(ap
->a_pl
, ap
->a_pl_offset
, (upl_size_t
)ap
->a_size
, UPL_ABORT_FREE_ON_EMPTY
| UPL_ABORT_ERROR
);
782 err_pageout(struct vnop_pageout_args
*ap
)
784 if (!(ap
->a_flags
& UPL_NOCOMMIT
)) {
785 assert(ap
->a_size
<= UINT32_MAX
);
786 ubc_upl_abort_range(ap
->a_pl
, ap
->a_pl_offset
, (upl_size_t
)ap
->a_size
, UPL_ABORT_FREE_ON_EMPTY
| UPL_ABORT_ERROR
);
792 struct vnop_searchfs
/* {
793 * struct vnode *a_vp;
794 * void *a_searchparams1;
795 * void *a_searchparams2;
796 * struct attrlist *a_searchattrs;
797 * u_long a_maxmatches;
798 * struct timeval *a_timelimit;
799 * struct attrlist *a_returnattrs;
800 * u_long *a_nummatches;
801 * u_long a_scriptcode;
804 * struct searchstate *a_searchstate;
805 * vfs_context_t a_context;
809 nop_searchfs(struct vnop_searchfs_args
*ap
)
811 *(ap
->a_nummatches
) = 0;
816 err_searchfs(struct vnop_searchfs_args
*ap
)
818 (void)nop_searchfs(ap
);
822 struct vnop_copyfile_args
/*{
823 * struct vnodeop_desc *a_desc;
824 * struct vnode *a_fvp;
825 * struct vnode *a_tdvp;
826 * struct vnode *a_tvp;
827 * struct componentname *a_tcnp;
832 nop_copyfile(__unused
struct vnop_copyfile_args
*ap
)
839 err_copyfile(struct vnop_copyfile_args
*ap
)
841 (void)nop_copyfile(ap
);
846 struct vnop_blktooff_args
/* {
847 * struct vnode *a_vp;
848 * daddr64_t a_lblkno;
853 nop_blktooff(struct vnop_blktooff_args
*ap
)
855 *ap
->a_offset
= (off_t
)-1; /* failure */
860 err_blktooff(struct vnop_blktooff_args
*ap
)
862 (void)nop_blktooff(ap
);
866 struct vnop_offtoblk_args
/* {
867 * struct vnode *a_vp;
869 * daddr64_t *a_lblkno;
873 nop_offtoblk(struct vnop_offtoblk_args
*ap
)
875 *ap
->a_lblkno
= (daddr64_t
)-1; /* failure */
880 err_offtoblk(struct vnop_offtoblk_args
*ap
)
882 (void)nop_offtoblk(ap
);
886 struct vnop_blockmap_args
/* {
887 * struct vnode *a_vp;
897 nop_blockmap(__unused
struct vnop_blockmap_args
*ap
)
903 err_blockmap(__unused
struct vnop_blockmap_args
*ap
)