]>
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_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@
23 * Copyright (c) 1998-1999 Apple Computer, Inc. All rights reserved.
25 * File: vfs/vfs_support.c
27 * The default VFS routines. A VFS plugin can use these
28 * functions in case it does not want to implement all. These functions
29 * take care of releasing locks and free up memory that they are
32 * nop_* routines always return 0 [success]
33 * err_* routines always return ENOTSUP
35 * This file could be auto-generated from vnode_if.src. but that needs
36 * support for freeing cnp.
39 * 15-Jul-1998 Earsh Nandkeshwar (earsh@apple.com)
40 * Fixed up readdirattr for its existance now.
41 * 18-Aug-1998 Umesh Vaishampayan (umeshv@apple.com)
45 #include <vfs/vfs_support.h>
46 #include <sys/kauth.h>
49 struct vnop_create_args
/* {
52 struct componentname *a_cnp;
53 struct vnode_vattr *a_vap;
54 vfs_context_t a_context;
58 nop_create(struct vnop_create_args
*ap
)
61 if ((ap
->a_cnp
->cn_flags
& HASBUF
) == 0)
62 panic("nop_create: no name");
68 err_create(struct vnop_create_args
*ap
)
75 struct vnop_whiteout_args
/* {
77 struct componentname *a_cnp;
79 vfs_context_t a_context;
83 nop_whiteout(struct vnop_whiteout_args
*ap
)
89 err_whiteout(struct vnop_whiteout_args
*ap
)
95 struct vnop_mknod_args
/* {
98 struct componentname *a_cnp;
99 struct vnode_vattr *a_vap;
100 vfs_context_t a_context;
104 nop_mknod(struct vnop_mknod_args
*ap
)
107 if ((ap
->a_cnp
->cn_flags
& HASBUF
) == 0)
108 panic("nop_mknod: no name");
114 err_mknod(struct vnop_mknod_args
*ap
)
120 struct vnop_open_args
/* {
123 vfs_context_t a_context;
127 nop_open(struct vnop_open_args
*ap
)
133 err_open(struct vnop_open_args
*ap
)
139 struct vnop_close_args
/* {
142 vfs_context_t a_context;
146 nop_close(struct vnop_close_args
*ap
)
152 err_close(struct vnop_close_args
*ap
)
158 struct vnop_access_args
/* {
161 vfs_context_t a_context;
165 nop_access(struct vnop_access_args
*ap
)
171 err_access(struct vnop_access_args
*ap
)
177 struct vnop_getattr_args
/* {
179 struct vnode_vattr *a_vap;
180 vfs_context_t a_context;
184 nop_getattr(struct vnop_getattr_args
*ap
)
190 err_getattr(struct vnop_getattr_args
*ap
)
196 struct vnop_setattr_args
/* {
198 struct vnode_vattr *a_vap;
199 vfs_context_t a_context;
203 nop_setattr(struct vnop_setattr_args
*ap
)
209 err_setattr(struct vnop_setattr_args
*ap
)
215 struct vnop_getattrlist_args
/* {
217 struct attrlist *a_alist;
220 vfs_context a_context;
224 nop_getattrlist(struct vnop_getattrlist_args
*ap
)
230 err_getattrlist(struct vnop_getattrlist_args
*ap
)
236 struct vnop_setattrlist_args
/* {
238 struct attrlist *a_alist;
241 vfs_context_t a_context;
245 nop_setattrlist(struct vnop_setattrlist_args
*ap
)
251 err_setattrlist(struct vnop_setattrlist_args
*ap
)
257 struct vnop_read_args
/* {
261 vfs_context_t a_context;
265 nop_read(struct vnop_read_args
*ap
)
271 err_read(struct vnop_read_args
*ap
)
277 struct vnop_write_args
/* {
281 vfs_context_t a_context;
285 nop_write(struct vnop_write_args
*ap
)
291 err_write(struct vnop_write_args
*ap
)
297 struct vnop_ioctl_args
/* {
307 nop_ioctl(__unused
struct vnop_ioctl_args
*ap
)
313 err_ioctl(struct vnop_ioctl_args
*ap
)
319 struct vnop_select_args
/* {
329 nop_select(__unused
struct vnop_select_args
*ap
)
335 err_select(struct vnop_select_args
*ap
)
341 struct vnop_exchange_args
/* {
345 vfs_context_t a_context;
349 nop_exchange(struct vnop_exchange_args
*ap
)
355 err_exchange(struct vnop_exchange_args
*ap
)
361 struct vnop_revoke_args
/* {
364 vfs_context_t a_context;
368 nop_revoke(struct vnop_revoke_args
*ap
)
370 return vn_revoke(ap
->a_vp
, ap
->a_flags
, ap
->a_context
);
374 err_revoke(struct vnop_revoke_args
*ap
)
376 (void)nop_revoke(ap
);
381 struct vnop_mmap_args
/* {
389 nop_mmap(__unused
struct vnop_mmap_args
*ap
)
395 err_mmap(struct vnop_mmap_args
*ap
)
401 struct vnop_fsync_args
/* {
404 vfs_context_t a_context;
408 nop_fsync(struct vnop_fsync_args
*ap
)
414 err_fsync(struct vnop_fsync_args
*ap
)
420 struct vnop_remove_args
/* {
423 struct componentname *a_cnp;
425 vfs_context_t a_context;
429 nop_remove(struct vnop_remove_args
*ap
)
435 err_remove(struct vnop_remove_args
*ap
)
437 (void)nop_remove(ap
);
442 struct vnop_link_args
/* {
444 struct vnode *a_tdvp;
445 struct componentname *a_cnp;
446 vfs_context_t a_context;
450 nop_link(struct vnop_link_args
*ap
)
456 err_link(struct vnop_link_args
*ap
)
463 struct vnop_rename_args
/* {
464 struct vnode *a_fdvp;
466 struct componentname *a_fcnp;
467 struct vnode *a_tdvp;
469 struct componentname *a_tcnp;
470 vfs_context_t a_context;
474 nop_rename(struct vnop_rename_args
*ap
)
480 err_rename(struct vnop_rename_args
*ap
)
482 (void)nop_rename(ap
);
487 struct vnop_mkdir_args
/* {
489 struct vnode **a_vpp;
490 struct componentname *a_cnp;
491 struct vnode_vattr *a_vap;
492 vfs_context_t a_context;
496 nop_mkdir(struct vnop_mkdir_args
*ap
)
502 err_mkdir(struct vnop_mkdir_args
*ap
)
508 struct vnop_rmdir_args
/* {
511 struct componentname *a_cnp;
512 vfs_context_t a_context;
516 nop_rmdir(struct vnop_rmdir_args
*ap
)
522 err_rmdir(struct vnop_rmdir_args
*ap
)
529 struct vnop_symlink_args
/* {
531 struct vnode **a_vpp;
532 struct componentname *a_cnp;
533 struct vnode_vattr *a_vap;
535 vfs_context_t a_context;
539 nop_symlink(struct vnop_symlink_args
*ap
)
542 if ((ap
->a_cnp
->cn_flags
& HASBUF
) == 0)
543 panic("nop_symlink: no name");
549 err_symlink(struct vnop_symlink_args
*ap
)
551 (void)nop_symlink(ap
);
556 struct vnop_readdir_args
/* {
562 vfs_context_t a_context;
566 nop_readdir(struct vnop_readdir_args
*ap
)
572 err_readdir(struct vnop_readdir_args
*ap
)
578 struct vnop_readdirattr_args
/* {
580 struct attrlist *a_alist;
586 u_long *a_actualcount;
587 vfs_context_t a_context;
591 nop_readdirattr(struct vnop_readdirattr_args
*ap
)
593 *(ap
->a_actualcount
) = 0;
594 *(ap
->a_eofflag
) = 0;
599 err_readdirattr(struct vnop_readdirattr_args
*ap
)
601 (void)nop_readdirattr(ap
);
606 struct vnop_readlink_args
/* {
609 vfs_context_t a_context;
613 nop_readlink(struct vnop_readlink_args
*ap
)
619 err_readlink(struct vnop_readlink_args
*ap
)
625 struct vnop_inactive_args
/* {
627 vfs_context_t a_context;
631 nop_inactive(struct vnop_inactive_args
*ap
)
637 err_inactive(struct vnop_inactive_args
*ap
)
639 (void)nop_inactive(ap
);
644 struct vnop_reclaim_args
/* {
646 vfs_context_t a_context;
650 nop_reclaim(struct vnop_reclaim_args
*ap
)
656 err_reclaim(struct vnop_reclaim_args
*ap
)
662 struct vnop_strategy_args
/* {
667 nop_strategy(struct vnop_strategy_args
*ap
)
673 err_strategy(struct vnop_strategy_args
*ap
)
679 struct vnop_pathconf_args
/* {
682 register_t *a_retval;
683 vfs_context_t a_context;
687 nop_pathconf(struct vnop_pathconf_args
*ap
)
693 err_pathconf(struct vnop_pathconf_args
*ap
)
699 struct vnop_advlock_args
/* {
705 vfs_context_t a_context;
709 nop_advlock(struct vnop_advlock_args
*ap
)
715 err_advlock(struct vnop_advlock_args
*ap
)
722 struct vnop_allocate_args
/* {
726 off_t *a_bytesallocated;
728 vfs_context_t a_context;
732 nop_allocate(struct vnop_allocate_args
*ap
)
734 *(ap
->a_bytesallocated
) = 0;
739 err_allocate(struct vnop_allocate_args
*ap
)
741 (void)nop_allocate(ap
);
745 struct vnop_bwrite_args
/* {
750 nop_bwrite(struct vnop_bwrite_args
*ap
)
752 return ((int)buf_bwrite(ap
->a_bp
));
756 err_bwrite(struct vnop_bwrite_args
*ap
)
762 struct vnop_pagein_args
/* {
765 vm_offset_t a_pl_offset,
769 vfs_context_t a_context;
773 nop_pagein(struct vnop_pagein_args
*ap
)
775 if ( !(ap
->a_flags
& UPL_NOCOMMIT
))
776 ubc_upl_abort_range(ap
->a_pl
, ap
->a_pl_offset
, ap
->a_size
, UPL_ABORT_FREE_ON_EMPTY
| UPL_ABORT_ERROR
);
781 err_pagein(struct vnop_pagein_args
*ap
)
783 if ( !(ap
->a_flags
& UPL_NOCOMMIT
))
784 ubc_upl_abort_range(ap
->a_pl
, ap
->a_pl_offset
, ap
->a_size
, UPL_ABORT_FREE_ON_EMPTY
| UPL_ABORT_ERROR
);
789 struct vnop_pageout_args
/* {
792 vm_offset_t a_pl_offset,
796 vfs_context_t a_context;
800 nop_pageout(struct vnop_pageout_args
*ap
)
802 if ( !(ap
->a_flags
& UPL_NOCOMMIT
))
803 ubc_upl_abort_range(ap
->a_pl
, ap
->a_pl_offset
, ap
->a_size
, UPL_ABORT_FREE_ON_EMPTY
| UPL_ABORT_ERROR
);
808 err_pageout(struct vnop_pageout_args
*ap
)
810 if ( !(ap
->a_flags
& UPL_NOCOMMIT
))
811 ubc_upl_abort_range(ap
->a_pl
, ap
->a_pl_offset
, ap
->a_size
, UPL_ABORT_FREE_ON_EMPTY
| UPL_ABORT_ERROR
);
816 struct vnop_devblocksize_args
/* {
818 register_t *a_retval;
822 nop_devblocksize(struct vnop_devblocksize_args
*ap
)
824 /* XXX default value because the call sites do not check error */
830 err_devblocksize(struct vnop_devblocksize_args
*ap
)
832 (void)nop_devblocksize(ap
);
837 struct vnop_searchfs
/* {
839 void *a_searchparams1;
840 void *a_searchparams2;
841 struct attrlist *a_searchattrs;
843 struct timeval *a_timelimit;
844 struct attrlist *a_returnattrs;
845 u_long *a_nummatches;
849 struct searchstate *a_searchstate;
850 vfs_context_t a_context;
854 nop_searchfs(struct vnop_searchfs_args
*ap
)
856 *(ap
->a_nummatches
) = 0;
861 err_searchfs(struct vnop_searchfs_args
*ap
)
863 (void)nop_searchfs(ap
);
867 struct vnop_copyfile_args
/*{
868 struct vnodeop_desc *a_desc;
870 struct vnode *a_tdvp;
872 struct componentname *a_tcnp;
877 nop_copyfile(struct vnop_copyfile_args
*ap
)
884 err_copyfile(struct vnop_copyfile_args
*ap
)
886 (void)nop_copyfile(ap
);
891 struct vnop_blktooff_args
/* {
898 nop_blktooff(struct vnop_blktooff_args
*ap
)
900 *ap
->a_offset
= (off_t
)-1; /* failure */
905 err_blktooff(struct vnop_blktooff_args
*ap
)
907 (void)nop_blktooff(ap
);
911 struct vnop_offtoblk_args
/* {
918 nop_offtoblk(struct vnop_offtoblk_args
*ap
)
920 *ap
->a_lblkno
= (daddr64_t
)-1; /* failure */
925 err_offtoblk(struct vnop_offtoblk_args
*ap
)
927 (void)nop_offtoblk(ap
);
931 struct vnop_blockmap_args
/* {
941 int nop_blockmap(struct vnop_blockmap_args
*ap
)
946 int err_blockmap(struct vnop_blockmap_args
*ap
)