]>
git.saurik.com Git - apple/xnu.git/blob - bsd/vfs/vfs_support.c
2 * Copyright (c) 2000-2002 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
26 * Copyright (c) 1998-1999 Apple Computer, Inc. All rights reserved.
28 * File: vfs/vfs_support.c
30 * The default VFS routines. A VFS plugin can use these
31 * functions in case it does not want to implement all. These functions
32 * take care of releasing locks and free up memory that they are
35 * nop_* routines always return 0 [success]
36 * err_* routines always return EOPNOTSUPP
38 * This file could be auto-generated from vnode_if.src. but that needs
39 * support for freeing cnp.
42 * 15-Jul-1998 Earsh Nandkeshwar (earsh@apple.com)
43 * Fixed up readdirattr for its existance now.
44 * 18-Aug-1998 Umesh Vaishampayan (umeshv@apple.com)
48 #include <vfs/vfs_support.h>
51 struct vop_create_args
/* {
54 struct componentname *a_cnp;
59 nop_create(struct vop_create_args
*ap
)
62 if ((ap
->a_cnp
->cn_flags
& HASBUF
) == 0)
63 panic("nop_create: no name");
65 VOP_ABORTOP(ap
->a_dvp
, ap
->a_cnp
);
71 err_create(struct vop_create_args
*ap
)
78 struct vop_whiteout_args
/* {
80 struct componentname *a_cnp;
85 nop_whiteout(struct vop_whiteout_args
*ap
)
91 err_whiteout(struct vop_whiteout_args
*ap
)
97 struct vop_mknod_args
/* {
100 struct componentname *a_cnp;
105 nop_mknod(struct vop_mknod_args
*ap
)
108 if ((ap
->a_cnp
->cn_flags
& HASBUF
) == 0)
109 panic("nop_mknod: no name");
111 VOP_ABORTOP(ap
->a_dvp
, ap
->a_cnp
);
117 err_mknod(struct vop_mknod_args
*ap
)
124 struct vop_mkcomplex_args
/* {
126 struct vnode **a_vpp,
127 struct componentname *a_cnp,
133 nop_mkcomplex(struct vop_mkcomplex_args
*ap
)
136 if ((ap
->a_cnp
->cn_flags
& HASBUF
) == 0)
137 panic("nop_mkcomplex: no name");
139 VOP_ABORTOP(ap
->a_dvp
, ap
->a_cnp
);
145 err_mkcomplex(struct vop_mkcomplex_args
*ap
)
147 (void)nop_mkcomplex(ap
);
152 struct vop_open_args
/* {
155 struct ucred *a_cred;
160 nop_open(struct vop_open_args
*ap
)
166 err_open(struct vop_open_args
*ap
)
172 struct vop_close_args
/* {
175 struct ucred *a_cred;
180 nop_close(struct vop_close_args
*ap
)
186 err_close(struct vop_close_args
*ap
)
192 struct vop_access_args
/* {
195 struct ucred *a_cred;
200 nop_access(struct vop_access_args
*ap
)
206 err_access(struct vop_access_args
*ap
)
212 struct vop_getattr_args
/* {
215 struct ucred *a_cred;
220 nop_getattr(struct vop_getattr_args
*ap
)
226 err_getattr(struct vop_getattr_args
*ap
)
232 struct vop_setattr_args
/* {
235 struct ucred *a_cred;
240 nop_setattr(struct vop_setattr_args
*ap
)
246 err_setattr(struct vop_setattr_args
*ap
)
252 struct vop_getattrlist_args
/* {
254 struct attrlist *a_alist;
256 struct ucred *a_cred;
261 nop_getattrlist(struct vop_getattrlist_args
*ap
)
267 err_getattrlist(struct vop_getattrlist_args
*ap
)
273 struct vop_setattrlist_args
/* {
275 struct attrlist *a_alist;
277 struct ucred *a_cred;
282 nop_setattrlist(struct vop_setattrlist_args
*ap
)
288 err_setattrlist(struct vop_setattrlist_args
*ap
)
294 struct vop_read_args
/* {
298 struct ucred *a_cred;
302 nop_read(struct vop_read_args
*ap
)
308 err_read(struct vop_read_args
*ap
)
314 struct vop_write_args
/* {
318 struct ucred *a_cred;
322 nop_write(struct vop_write_args
*ap
)
328 err_write(struct vop_write_args
*ap
)
334 struct vop_lease_args
/* {
337 struct ucred *a_cred;
342 nop_lease(struct vop_lease_args
*ap
)
348 err_lease(struct vop_lease_args
*ap
)
354 struct vop_ioctl_args
/* {
359 struct ucred *a_cred;
364 nop_ioctl(struct vop_ioctl_args
*ap
)
370 err_ioctl(struct vop_ioctl_args
*ap
)
376 struct vop_select_args
/* {
380 struct ucred *a_cred;
386 nop_select(struct vop_select_args
*ap
)
392 err_select(struct vop_select_args
*ap
)
398 struct vop_exchange_args
/* {
401 struct ucred *a_cred;
406 nop_exchange(struct vop_exchange_args
*ap
)
412 err_exchange(struct vop_exchange_args
*ap
)
418 struct vop_revoke_args
/* {
424 nop_revoke(struct vop_revoke_args
*ap
)
426 return (vop_revoke(ap
));
430 err_revoke(struct vop_revoke_args
*ap
)
432 (void)nop_revoke(ap
);
437 struct vop_mmap_args
/* {
440 struct ucred *a_cred;
445 nop_mmap(struct vop_mmap_args
*ap
)
451 err_mmap(struct vop_mmap_args
*ap
)
457 struct vop_fsync_args
/* {
459 struct ucred *a_cred;
465 nop_fsync(struct vop_fsync_args
*ap
)
471 err_fsync(struct vop_fsync_args
*ap
)
477 struct vop_seek_args
/* {
481 struct ucred *a_cred;
485 nop_seek(struct vop_seek_args
*ap
)
491 err_seek(struct vop_seek_args
*ap
)
497 struct vop_remove_args
/* {
500 struct componentname *a_cnp;
504 nop_remove(struct vop_remove_args
*ap
)
506 if (ap
->a_dvp
== ap
->a_vp
)
515 err_remove(struct vop_remove_args
*ap
)
517 (void)nop_remove(ap
);
522 struct vop_link_args
/* {
524 struct vnode *a_tdvp;
525 struct componentname *a_cnp;
529 nop_link(struct vop_link_args
*ap
)
532 if ((ap
->a_cnp
->cn_flags
& HASBUF
) == 0)
533 panic("nop_link: no name");
535 VOP_ABORTOP(ap
->a_tdvp
, ap
->a_cnp
);
541 err_link(struct vop_link_args
*ap
)
548 struct vop_rename_args
/* {
549 struct vnode *a_fdvp;
551 struct componentname *a_fcnp;
552 struct vnode *a_tdvp;
554 struct componentname *a_tcnp;
558 nop_rename(struct vop_rename_args
*ap
)
561 if ((ap
->a_tcnp
->cn_flags
& HASBUF
) == 0 ||
562 (ap
->a_fcnp
->cn_flags
& HASBUF
) == 0)
563 panic("nop_rename: no name");
565 VOP_ABORTOP(ap
->a_tdvp
, ap
->a_tcnp
);
566 if (ap
->a_tdvp
== ap
->a_tvp
)
572 VOP_ABORTOP(ap
->a_fdvp
, ap
->a_fcnp
);
579 err_rename(struct vop_rename_args
*ap
)
581 (void)nop_rename(ap
);
586 struct vop_mkdir_args
/* {
588 struct vnode **a_vpp;
589 struct componentname *a_cnp;
594 nop_mkdir(struct vop_mkdir_args
*ap
)
597 if ((ap
->a_cnp
->cn_flags
& HASBUF
) == 0)
598 panic("nop_mkdir: no name");
600 VOP_ABORTOP(ap
->a_dvp
, ap
->a_cnp
);
606 err_mkdir(struct vop_mkdir_args
*ap
)
613 struct vop_rmdir_args
/* {
616 struct componentname *a_cnp;
620 nop_rmdir(struct vop_rmdir_args
*ap
)
628 err_rmdir(struct vop_rmdir_args
*ap
)
635 struct vop_symlink_args
/* {
637 struct vnode **a_vpp;
638 struct componentname *a_cnp;
644 nop_symlink(struct vop_symlink_args
*ap
)
647 if ((ap
->a_cnp
->cn_flags
& HASBUF
) == 0)
648 panic("nop_symlink: no name");
650 VOP_ABORTOP(ap
->a_dvp
, ap
->a_cnp
);
656 err_symlink(struct vop_symlink_args
*ap
)
658 (void)nop_symlink(ap
);
663 struct vop_readdir_args
/* {
666 struct ucred *a_cred;
673 nop_readdir(struct vop_readdir_args
*ap
)
679 err_readdir(struct vop_readdir_args
*ap
)
685 struct vop_readdirattr_args
/* {
687 struct attrlist *a_alist;
693 u_long *a_actualcount;
695 struct ucred *a_cred;
699 nop_readdirattr(struct vop_readdirattr_args
*ap
)
701 *(ap
->a_actualcount
) = 0;
702 *(ap
->a_eofflag
) = 0;
707 err_readdirattr(struct vop_readdirattr_args
*ap
)
709 (void)nop_readdirattr(ap
);
714 struct vop_readlink_args
/* {
721 nop_readlink(struct vop_readlink_args
*ap
)
727 err_readlink(struct vop_readlink_args
*ap
)
733 struct vop_abortop_args
/* {
735 struct componentname *a_cnp;
739 nop_abortop(struct vop_abortop_args
*ap
)
741 if ((ap
->a_cnp
->cn_flags
& (HASBUF
| SAVESTART
)) == HASBUF
) {
742 char *tmp
= ap
->a_cnp
->cn_pnbuf
;
743 ap
->a_cnp
->cn_pnbuf
= NULL
;
744 ap
->a_cnp
->cn_flags
&= ~HASBUF
;
745 FREE_ZONE(tmp
, ap
->a_cnp
->cn_pnlen
, M_NAMEI
);
752 err_abortop(struct vop_abortop_args
*ap
)
754 (void)nop_abortop(ap
);
759 struct vop_inactive_args
/* {
765 nop_inactive(struct vop_inactive_args
*ap
)
767 VOP_UNLOCK(ap
->a_vp
, 0, ap
->a_p
);
772 err_inactive(struct vop_inactive_args
*ap
)
774 (void)nop_inactive(ap
);
779 struct vop_reclaim_args
/* {
785 nop_reclaim(struct vop_reclaim_args
*ap
)
791 err_reclaim(struct vop_reclaim_args
*ap
)
797 struct vop_lock_args
/* {
804 nop_lock(struct vop_lock_args
*ap
)
806 return (vop_nolock(ap
));
810 err_lock(struct vop_lock_args
*ap
)
817 struct vop_unlock_args
/* {
824 nop_unlock(struct vop_unlock_args
*ap
)
826 return (vop_nounlock(ap
));
830 err_unlock(struct vop_unlock_args
*ap
)
832 (void)nop_unlock(ap
);
837 struct vop_bmap_args
/* {
846 nop_bmap(struct vop_bmap_args
*ap
)
852 err_bmap(struct vop_bmap_args
*ap
)
858 struct vop_strategy_args
/* {
863 nop_strategy(struct vop_strategy_args
*ap
)
869 err_strategy(struct vop_strategy_args
*ap
)
875 struct vop_print_args
/* {
880 nop_print(struct vop_print_args
*ap
)
886 err_print(struct vop_print_args
*ap
)
892 struct vop_islocked_args
/* {
897 nop_islocked(struct vop_islocked_args
*ap
)
899 return (vop_noislocked(ap
));
903 err_islocked(struct vop_islocked_args
*ap
)
905 (void)nop_islocked(ap
);
910 struct vop_pathconf_args
/* {
913 register_t *a_retval;
917 nop_pathconf(struct vop_pathconf_args
*ap
)
923 err_pathconf(struct vop_pathconf_args
*ap
)
929 struct vop_advlock_args
/* {
938 nop_advlock(struct vop_advlock_args
*ap
)
944 err_advlock(struct vop_advlock_args
*ap
)
950 struct vop_blkatoff_args
/* {
958 nop_blkatoff(struct vop_blkatoff_args
*ap
)
965 err_blkatoff(struct vop_blkatoff_args
*ap
)
967 (void)nop_blkatoff(ap
);
972 struct vop_valloc_args
/* {
975 struct ucred *a_cred;
976 struct vnode **a_vpp;
980 nop_valloc(struct vop_valloc_args
*ap
)
987 err_valloc(struct vop_valloc_args
*ap
)
989 (void)nop_valloc(ap
);
994 struct vop_reallocblks_args
/* {
996 struct cluster_save *a_buflist;
1000 nop_reallocblks(struct vop_reallocblks_args
*ap
)
1006 err_reallocblks(struct vop_reallocblks_args
*ap
)
1008 return (EOPNOTSUPP
);
1012 struct vop_vfree_args
/* {
1013 struct vnode *a_pvp;
1019 nop_vfree(struct vop_vfree_args
*ap
)
1025 err_vfree(struct vop_vfree_args
*ap
)
1027 return (EOPNOTSUPP
);
1031 struct vop_truncate_args
/* {
1035 struct ucred *a_cred;
1040 nop_truncate(struct vop_truncate_args
*ap
)
1046 err_truncate(struct vop_truncate_args
*ap
)
1048 return (EOPNOTSUPP
);
1052 struct vop_allocate_args
/* {
1056 off_t *a_bytesallocated;
1058 struct ucred *a_cred;
1063 nop_allocate(struct vop_allocate_args
*ap
)
1065 *(ap
->a_bytesallocated
) = 0;
1070 err_allocate(struct vop_allocate_args
*ap
)
1072 (void)nop_allocate(ap
);
1073 return (EOPNOTSUPP
);
1077 struct vop_update_args
/* {
1079 struct timeval *a_access;
1080 struct timeval *a_modify;
1085 nop_update(struct vop_update_args
*ap
)
1091 err_update(struct vop_update_args
*ap
)
1093 return (EOPNOTSUPP
);
1097 struct vop_pgrd_args
/* {
1100 struct ucred *a_cred;
1104 nop_pgrd(struct vop_pgrd_args
*ap
)
1110 err_pgrd(struct vop_pgrd_args
*ap
)
1112 return (EOPNOTSUPP
);
1116 struct vop_pgwr_args
/* {
1119 struct ucred *a_cred;
1120 vm_offset_t a_offset;
1124 nop_pgwr(struct vop_pgwr_args
*ap
)
1130 err_pgwr(struct vop_pgwr_args
*ap
)
1132 return (EOPNOTSUPP
);
1136 struct vop_bwrite_args
/* {
1141 nop_bwrite(struct vop_bwrite_args
*ap
)
1143 return (bwrite(ap
->a_bp
));
1147 err_bwrite(struct vop_bwrite_args
*ap
)
1149 return (EOPNOTSUPP
);
1153 struct vop_pagein_args
/* {
1156 vm_offset_t a_pl_offset,
1159 struct ucred *a_cred,
1164 nop_pagein(struct vop_pagein_args
*ap
)
1166 ubc_upl_abort(ap
->a_pl
, UPL_ABORT_ERROR
);
1171 err_pagein(struct vop_pagein_args
*ap
)
1173 ubc_upl_abort(ap
->a_pl
, UPL_ABORT_ERROR
);
1174 return (EOPNOTSUPP
);
1178 struct vop_pageout_args
/* {
1181 vm_offset_t a_pl_offset,
1184 struct ucred *a_cred,
1189 nop_pageout(struct vop_pageout_args
*ap
)
1191 ubc_upl_abort(ap
->a_pl
, UPL_ABORT_ERROR
);
1196 err_pageout(struct vop_pageout_args
*ap
)
1198 ubc_upl_abort(ap
->a_pl
, UPL_ABORT_ERROR
);
1199 return (EOPNOTSUPP
);
1203 struct vop_devblocksize_args
/* {
1205 register_t *a_retval;
1209 nop_devblocksize(struct vop_devblocksize_args
*ap
)
1211 /* XXX default value because the call sites do not check error */
1212 *ap
->a_retval
= 512;
1217 err_devblocksize(struct vop_devblocksize_args
*ap
)
1219 (void)nop_devblocksize(ap
);
1220 return (EOPNOTSUPP
);
1224 struct vop_searchfs
/* {
1226 void *a_searchparams1;
1227 void *a_searchparams2;
1228 struct attrlist *a_searchattrs;
1229 u_long a_maxmatches;
1230 struct timeval *a_timelimit;
1231 struct attrlist *a_returnattrs;
1232 u_long *a_nummatches;
1233 u_long a_scriptcode;
1236 struct searchstate *a_searchstate;
1240 nop_searchfs(struct vop_searchfs_args
*ap
)
1242 *(ap
->a_nummatches
) = 0;
1247 err_searchfs(struct vop_searchfs_args
*ap
)
1249 (void)nop_searchfs(ap
);
1250 return (EOPNOTSUPP
);
1253 struct vop_copyfile_args
/*{
1254 struct vnodeop_desc *a_desc;
1255 struct vnode *a_fvp;
1256 struct vnode *a_tdvp;
1257 struct vnode *a_tvp;
1258 struct componentname *a_tcnp;
1263 nop_copyfile(struct vop_copyfile_args
*ap
)
1265 if (ap
->a_tdvp
== ap
->a_tvp
)
1277 err_copyfile(struct vop_copyfile_args
*ap
)
1279 (void)nop_copyfile(ap
);
1280 return (EOPNOTSUPP
);
1284 struct vop_blktooff_args
/* {
1291 nop_blktooff(struct vop_blktooff_args
*ap
)
1293 *ap
->a_offset
= (off_t
)-1; /* failure */
1298 err_blktooff(struct vop_blktooff_args
*ap
)
1300 (void)nop_blktooff(ap
);
1301 return (EOPNOTSUPP
);
1304 struct vop_offtoblk_args
/* {
1311 nop_offtoblk(struct vop_offtoblk_args
*ap
)
1313 *ap
->a_lblkno
= (daddr_t
)-1; /* failure */
1318 err_offtoblk(struct vop_offtoblk_args
*ap
)
1320 (void)nop_offtoblk(ap
);
1321 return (EOPNOTSUPP
);
1324 struct vop_cmap_args
/* {
1333 int nop_cmap(struct vop_cmap_args
*ap
)
1338 int err_cmap(struct vop_cmap_args
*ap
)
1340 return (EOPNOTSUPP
);