]>
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>
55 struct vnop_create_args
/* {
58 struct componentname *a_cnp;
59 struct vnode_vattr *a_vap;
60 vfs_context_t a_context;
64 nop_create(struct vnop_create_args
*ap
)
67 if ((ap
->a_cnp
->cn_flags
& HASBUF
) == 0)
68 panic("nop_create: no name");
74 err_create(struct vnop_create_args
*ap
)
81 struct vnop_whiteout_args
/* {
83 struct componentname *a_cnp;
85 vfs_context_t a_context;
89 nop_whiteout(struct vnop_whiteout_args
*ap
)
95 err_whiteout(struct vnop_whiteout_args
*ap
)
101 struct vnop_mknod_args
/* {
103 struct vnode **a_vpp;
104 struct componentname *a_cnp;
105 struct vnode_vattr *a_vap;
106 vfs_context_t a_context;
110 nop_mknod(struct vnop_mknod_args
*ap
)
113 if ((ap
->a_cnp
->cn_flags
& HASBUF
) == 0)
114 panic("nop_mknod: no name");
120 err_mknod(struct vnop_mknod_args
*ap
)
126 struct vnop_open_args
/* {
129 vfs_context_t a_context;
133 nop_open(struct vnop_open_args
*ap
)
139 err_open(struct vnop_open_args
*ap
)
145 struct vnop_close_args
/* {
148 vfs_context_t a_context;
152 nop_close(struct vnop_close_args
*ap
)
158 err_close(struct vnop_close_args
*ap
)
164 struct vnop_access_args
/* {
167 vfs_context_t a_context;
171 nop_access(struct vnop_access_args
*ap
)
177 err_access(struct vnop_access_args
*ap
)
183 struct vnop_getattr_args
/* {
185 struct vnode_vattr *a_vap;
186 vfs_context_t a_context;
190 nop_getattr(struct vnop_getattr_args
*ap
)
196 err_getattr(struct vnop_getattr_args
*ap
)
202 struct vnop_setattr_args
/* {
204 struct vnode_vattr *a_vap;
205 vfs_context_t a_context;
209 nop_setattr(struct vnop_setattr_args
*ap
)
215 err_setattr(struct vnop_setattr_args
*ap
)
221 struct vnop_getattrlist_args
/* {
223 struct attrlist *a_alist;
226 vfs_context a_context;
230 nop_getattrlist(struct vnop_getattrlist_args
*ap
)
236 err_getattrlist(struct vnop_getattrlist_args
*ap
)
242 struct vnop_setattrlist_args
/* {
244 struct attrlist *a_alist;
247 vfs_context_t a_context;
251 nop_setattrlist(struct vnop_setattrlist_args
*ap
)
257 err_setattrlist(struct vnop_setattrlist_args
*ap
)
263 struct vnop_read_args
/* {
267 vfs_context_t a_context;
271 nop_read(struct vnop_read_args
*ap
)
277 err_read(struct vnop_read_args
*ap
)
283 struct vnop_write_args
/* {
287 vfs_context_t a_context;
291 nop_write(struct vnop_write_args
*ap
)
297 err_write(struct vnop_write_args
*ap
)
303 struct vnop_ioctl_args
/* {
313 nop_ioctl(__unused
struct vnop_ioctl_args
*ap
)
319 err_ioctl(struct vnop_ioctl_args
*ap
)
325 struct vnop_select_args
/* {
335 nop_select(__unused
struct vnop_select_args
*ap
)
341 err_select(struct vnop_select_args
*ap
)
347 struct vnop_exchange_args
/* {
351 vfs_context_t a_context;
355 nop_exchange(struct vnop_exchange_args
*ap
)
361 err_exchange(struct vnop_exchange_args
*ap
)
367 struct vnop_revoke_args
/* {
370 vfs_context_t a_context;
374 nop_revoke(struct vnop_revoke_args
*ap
)
376 return vn_revoke(ap
->a_vp
, ap
->a_flags
, ap
->a_context
);
380 err_revoke(struct vnop_revoke_args
*ap
)
382 (void)nop_revoke(ap
);
387 struct vnop_mmap_args
/* {
395 nop_mmap(__unused
struct vnop_mmap_args
*ap
)
401 err_mmap(struct vnop_mmap_args
*ap
)
407 struct vnop_fsync_args
/* {
410 vfs_context_t a_context;
414 nop_fsync(struct vnop_fsync_args
*ap
)
420 err_fsync(struct vnop_fsync_args
*ap
)
426 struct vnop_remove_args
/* {
429 struct componentname *a_cnp;
431 vfs_context_t a_context;
435 nop_remove(struct vnop_remove_args
*ap
)
441 err_remove(struct vnop_remove_args
*ap
)
443 (void)nop_remove(ap
);
448 struct vnop_link_args
/* {
450 struct vnode *a_tdvp;
451 struct componentname *a_cnp;
452 vfs_context_t a_context;
456 nop_link(struct vnop_link_args
*ap
)
462 err_link(struct vnop_link_args
*ap
)
469 struct vnop_rename_args
/* {
470 struct vnode *a_fdvp;
472 struct componentname *a_fcnp;
473 struct vnode *a_tdvp;
475 struct componentname *a_tcnp;
476 vfs_context_t a_context;
480 nop_rename(struct vnop_rename_args
*ap
)
486 err_rename(struct vnop_rename_args
*ap
)
488 (void)nop_rename(ap
);
493 struct vnop_mkdir_args
/* {
495 struct vnode **a_vpp;
496 struct componentname *a_cnp;
497 struct vnode_vattr *a_vap;
498 vfs_context_t a_context;
502 nop_mkdir(struct vnop_mkdir_args
*ap
)
508 err_mkdir(struct vnop_mkdir_args
*ap
)
514 struct vnop_rmdir_args
/* {
517 struct componentname *a_cnp;
518 vfs_context_t a_context;
522 nop_rmdir(struct vnop_rmdir_args
*ap
)
528 err_rmdir(struct vnop_rmdir_args
*ap
)
535 struct vnop_symlink_args
/* {
537 struct vnode **a_vpp;
538 struct componentname *a_cnp;
539 struct vnode_vattr *a_vap;
541 vfs_context_t a_context;
545 nop_symlink(struct vnop_symlink_args
*ap
)
548 if ((ap
->a_cnp
->cn_flags
& HASBUF
) == 0)
549 panic("nop_symlink: no name");
555 err_symlink(struct vnop_symlink_args
*ap
)
557 (void)nop_symlink(ap
);
562 struct vnop_readdir_args
/* {
568 vfs_context_t a_context;
572 nop_readdir(struct vnop_readdir_args
*ap
)
578 err_readdir(struct vnop_readdir_args
*ap
)
584 struct vnop_readdirattr_args
/* {
586 struct attrlist *a_alist;
592 u_long *a_actualcount;
593 vfs_context_t a_context;
597 nop_readdirattr(struct vnop_readdirattr_args
*ap
)
599 *(ap
->a_actualcount
) = 0;
600 *(ap
->a_eofflag
) = 0;
605 err_readdirattr(struct vnop_readdirattr_args
*ap
)
607 (void)nop_readdirattr(ap
);
612 struct vnop_readlink_args
/* {
615 vfs_context_t a_context;
619 nop_readlink(struct vnop_readlink_args
*ap
)
625 err_readlink(struct vnop_readlink_args
*ap
)
631 struct vnop_inactive_args
/* {
633 vfs_context_t a_context;
637 nop_inactive(struct vnop_inactive_args
*ap
)
643 err_inactive(struct vnop_inactive_args
*ap
)
645 (void)nop_inactive(ap
);
650 struct vnop_reclaim_args
/* {
652 vfs_context_t a_context;
656 nop_reclaim(struct vnop_reclaim_args
*ap
)
662 err_reclaim(struct vnop_reclaim_args
*ap
)
668 struct vnop_strategy_args
/* {
673 nop_strategy(struct vnop_strategy_args
*ap
)
679 err_strategy(struct vnop_strategy_args
*ap
)
685 struct vnop_pathconf_args
/* {
688 register_t *a_retval;
689 vfs_context_t a_context;
693 nop_pathconf(struct vnop_pathconf_args
*ap
)
699 err_pathconf(struct vnop_pathconf_args
*ap
)
705 struct vnop_advlock_args
/* {
711 vfs_context_t a_context;
715 nop_advlock(struct vnop_advlock_args
*ap
)
721 err_advlock(struct vnop_advlock_args
*ap
)
728 struct vnop_allocate_args
/* {
732 off_t *a_bytesallocated;
734 vfs_context_t a_context;
738 nop_allocate(struct vnop_allocate_args
*ap
)
740 *(ap
->a_bytesallocated
) = 0;
745 err_allocate(struct vnop_allocate_args
*ap
)
747 (void)nop_allocate(ap
);
751 struct vnop_bwrite_args
/* {
756 nop_bwrite(struct vnop_bwrite_args
*ap
)
758 return ((int)buf_bwrite(ap
->a_bp
));
762 err_bwrite(struct vnop_bwrite_args
*ap
)
768 struct vnop_pagein_args
/* {
771 vm_offset_t a_pl_offset,
775 vfs_context_t a_context;
779 nop_pagein(struct vnop_pagein_args
*ap
)
781 if ( !(ap
->a_flags
& UPL_NOCOMMIT
))
782 ubc_upl_abort_range(ap
->a_pl
, ap
->a_pl_offset
, ap
->a_size
, UPL_ABORT_FREE_ON_EMPTY
| UPL_ABORT_ERROR
);
787 err_pagein(struct vnop_pagein_args
*ap
)
789 if ( !(ap
->a_flags
& UPL_NOCOMMIT
))
790 ubc_upl_abort_range(ap
->a_pl
, ap
->a_pl_offset
, ap
->a_size
, UPL_ABORT_FREE_ON_EMPTY
| UPL_ABORT_ERROR
);
795 struct vnop_pageout_args
/* {
798 vm_offset_t a_pl_offset,
802 vfs_context_t a_context;
806 nop_pageout(struct vnop_pageout_args
*ap
)
808 if ( !(ap
->a_flags
& UPL_NOCOMMIT
))
809 ubc_upl_abort_range(ap
->a_pl
, ap
->a_pl_offset
, ap
->a_size
, UPL_ABORT_FREE_ON_EMPTY
| UPL_ABORT_ERROR
);
814 err_pageout(struct vnop_pageout_args
*ap
)
816 if ( !(ap
->a_flags
& UPL_NOCOMMIT
))
817 ubc_upl_abort_range(ap
->a_pl
, ap
->a_pl_offset
, ap
->a_size
, UPL_ABORT_FREE_ON_EMPTY
| UPL_ABORT_ERROR
);
822 struct vnop_searchfs
/* {
824 void *a_searchparams1;
825 void *a_searchparams2;
826 struct attrlist *a_searchattrs;
828 struct timeval *a_timelimit;
829 struct attrlist *a_returnattrs;
830 u_long *a_nummatches;
834 struct searchstate *a_searchstate;
835 vfs_context_t a_context;
839 nop_searchfs(struct vnop_searchfs_args
*ap
)
841 *(ap
->a_nummatches
) = 0;
846 err_searchfs(struct vnop_searchfs_args
*ap
)
848 (void)nop_searchfs(ap
);
852 struct vnop_copyfile_args
/*{
853 struct vnodeop_desc *a_desc;
855 struct vnode *a_tdvp;
857 struct componentname *a_tcnp;
862 nop_copyfile(struct vnop_copyfile_args
*ap
)
869 err_copyfile(struct vnop_copyfile_args
*ap
)
871 (void)nop_copyfile(ap
);
876 struct vnop_blktooff_args
/* {
883 nop_blktooff(struct vnop_blktooff_args
*ap
)
885 *ap
->a_offset
= (off_t
)-1; /* failure */
890 err_blktooff(struct vnop_blktooff_args
*ap
)
892 (void)nop_blktooff(ap
);
896 struct vnop_offtoblk_args
/* {
903 nop_offtoblk(struct vnop_offtoblk_args
*ap
)
905 *ap
->a_lblkno
= (daddr64_t
)-1; /* failure */
910 err_offtoblk(struct vnop_offtoblk_args
*ap
)
912 (void)nop_offtoblk(ap
);
916 struct vnop_blockmap_args
/* {
926 int nop_blockmap(struct vnop_blockmap_args
*ap
)
931 int err_blockmap(struct vnop_blockmap_args
*ap
)