]>
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 * 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 EOPNOTSUPP
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>
48 struct vop_create_args
/* {
51 struct componentname *a_cnp;
56 nop_create(struct vop_create_args
*ap
)
59 if ((ap
->a_cnp
->cn_flags
& HASBUF
) == 0)
60 panic("nop_create: no name");
62 VOP_ABORTOP(ap
->a_dvp
, ap
->a_cnp
);
68 err_create(struct vop_create_args
*ap
)
75 struct vop_whiteout_args
/* {
77 struct componentname *a_cnp;
82 nop_whiteout(struct vop_whiteout_args
*ap
)
88 err_whiteout(struct vop_whiteout_args
*ap
)
94 struct vop_mknod_args
/* {
97 struct componentname *a_cnp;
102 nop_mknod(struct vop_mknod_args
*ap
)
105 if ((ap
->a_cnp
->cn_flags
& HASBUF
) == 0)
106 panic("nop_mknod: no name");
108 VOP_ABORTOP(ap
->a_dvp
, ap
->a_cnp
);
114 err_mknod(struct vop_mknod_args
*ap
)
121 struct vop_mkcomplex_args
/* {
123 struct vnode **a_vpp,
124 struct componentname *a_cnp,
130 nop_mkcomplex(struct vop_mkcomplex_args
*ap
)
133 if ((ap
->a_cnp
->cn_flags
& HASBUF
) == 0)
134 panic("nop_mkcomplex: no name");
136 VOP_ABORTOP(ap
->a_dvp
, ap
->a_cnp
);
142 err_mkcomplex(struct vop_mkcomplex_args
*ap
)
144 (void)nop_mkcomplex(ap
);
149 struct vop_open_args
/* {
152 struct ucred *a_cred;
157 nop_open(struct vop_open_args
*ap
)
163 err_open(struct vop_open_args
*ap
)
169 struct vop_close_args
/* {
172 struct ucred *a_cred;
177 nop_close(struct vop_close_args
*ap
)
183 err_close(struct vop_close_args
*ap
)
189 struct vop_access_args
/* {
192 struct ucred *a_cred;
197 nop_access(struct vop_access_args
*ap
)
203 err_access(struct vop_access_args
*ap
)
209 struct vop_getattr_args
/* {
212 struct ucred *a_cred;
217 nop_getattr(struct vop_getattr_args
*ap
)
223 err_getattr(struct vop_getattr_args
*ap
)
229 struct vop_setattr_args
/* {
232 struct ucred *a_cred;
237 nop_setattr(struct vop_setattr_args
*ap
)
243 err_setattr(struct vop_setattr_args
*ap
)
249 struct vop_getattrlist_args
/* {
251 struct attrlist *a_alist;
253 struct ucred *a_cred;
258 nop_getattrlist(struct vop_getattrlist_args
*ap
)
264 err_getattrlist(struct vop_getattrlist_args
*ap
)
270 struct vop_setattrlist_args
/* {
272 struct attrlist *a_alist;
274 struct ucred *a_cred;
279 nop_setattrlist(struct vop_setattrlist_args
*ap
)
285 err_setattrlist(struct vop_setattrlist_args
*ap
)
291 struct vop_read_args
/* {
295 struct ucred *a_cred;
299 nop_read(struct vop_read_args
*ap
)
305 err_read(struct vop_read_args
*ap
)
311 struct vop_write_args
/* {
315 struct ucred *a_cred;
319 nop_write(struct vop_write_args
*ap
)
325 err_write(struct vop_write_args
*ap
)
331 struct vop_lease_args
/* {
334 struct ucred *a_cred;
339 nop_lease(struct vop_lease_args
*ap
)
345 err_lease(struct vop_lease_args
*ap
)
351 struct vop_ioctl_args
/* {
356 struct ucred *a_cred;
361 nop_ioctl(struct vop_ioctl_args
*ap
)
367 err_ioctl(struct vop_ioctl_args
*ap
)
373 struct vop_select_args
/* {
377 struct ucred *a_cred;
383 nop_select(struct vop_select_args
*ap
)
389 err_select(struct vop_select_args
*ap
)
395 struct vop_exchange_args
/* {
398 struct ucred *a_cred;
403 nop_exchange(struct vop_exchange_args
*ap
)
409 err_exchange(struct vop_exchange_args
*ap
)
415 struct vop_revoke_args
/* {
421 nop_revoke(struct vop_revoke_args
*ap
)
423 return (vop_revoke(ap
));
427 err_revoke(struct vop_revoke_args
*ap
)
429 (void)nop_revoke(ap
);
434 struct vop_mmap_args
/* {
437 struct ucred *a_cred;
442 nop_mmap(struct vop_mmap_args
*ap
)
448 err_mmap(struct vop_mmap_args
*ap
)
454 struct vop_fsync_args
/* {
456 struct ucred *a_cred;
462 nop_fsync(struct vop_fsync_args
*ap
)
468 err_fsync(struct vop_fsync_args
*ap
)
474 struct vop_seek_args
/* {
478 struct ucred *a_cred;
482 nop_seek(struct vop_seek_args
*ap
)
488 err_seek(struct vop_seek_args
*ap
)
494 struct vop_remove_args
/* {
497 struct componentname *a_cnp;
501 nop_remove(struct vop_remove_args
*ap
)
503 if (ap
->a_dvp
== ap
->a_vp
)
512 err_remove(struct vop_remove_args
*ap
)
514 (void)nop_remove(ap
);
519 struct vop_link_args
/* {
521 struct vnode *a_tdvp;
522 struct componentname *a_cnp;
526 nop_link(struct vop_link_args
*ap
)
529 if ((ap
->a_cnp
->cn_flags
& HASBUF
) == 0)
530 panic("nop_link: no name");
532 VOP_ABORTOP(ap
->a_tdvp
, ap
->a_cnp
);
538 err_link(struct vop_link_args
*ap
)
545 struct vop_rename_args
/* {
546 struct vnode *a_fdvp;
548 struct componentname *a_fcnp;
549 struct vnode *a_tdvp;
551 struct componentname *a_tcnp;
555 nop_rename(struct vop_rename_args
*ap
)
558 if ((ap
->a_tcnp
->cn_flags
& HASBUF
) == 0 ||
559 (ap
->a_fcnp
->cn_flags
& HASBUF
) == 0)
560 panic("nop_rename: no name");
562 VOP_ABORTOP(ap
->a_tdvp
, ap
->a_tcnp
);
563 if (ap
->a_tdvp
== ap
->a_tvp
)
569 VOP_ABORTOP(ap
->a_fdvp
, ap
->a_fcnp
);
576 err_rename(struct vop_rename_args
*ap
)
578 (void)nop_rename(ap
);
583 struct vop_mkdir_args
/* {
585 struct vnode **a_vpp;
586 struct componentname *a_cnp;
591 nop_mkdir(struct vop_mkdir_args
*ap
)
594 if ((ap
->a_cnp
->cn_flags
& HASBUF
) == 0)
595 panic("nop_mkdir: no name");
597 VOP_ABORTOP(ap
->a_dvp
, ap
->a_cnp
);
603 err_mkdir(struct vop_mkdir_args
*ap
)
610 struct vop_rmdir_args
/* {
613 struct componentname *a_cnp;
617 nop_rmdir(struct vop_rmdir_args
*ap
)
625 err_rmdir(struct vop_rmdir_args
*ap
)
632 struct vop_symlink_args
/* {
634 struct vnode **a_vpp;
635 struct componentname *a_cnp;
641 nop_symlink(struct vop_symlink_args
*ap
)
644 if ((ap
->a_cnp
->cn_flags
& HASBUF
) == 0)
645 panic("nop_symlink: no name");
647 VOP_ABORTOP(ap
->a_dvp
, ap
->a_cnp
);
653 err_symlink(struct vop_symlink_args
*ap
)
655 (void)nop_symlink(ap
);
660 struct vop_readdir_args
/* {
663 struct ucred *a_cred;
670 nop_readdir(struct vop_readdir_args
*ap
)
676 err_readdir(struct vop_readdir_args
*ap
)
682 struct vop_readdirattr_args
/* {
684 struct attrlist *a_alist;
690 u_long *a_actualcount;
692 struct ucred *a_cred;
696 nop_readdirattr(struct vop_readdirattr_args
*ap
)
698 *(ap
->a_actualcount
) = 0;
699 *(ap
->a_eofflag
) = 0;
704 err_readdirattr(struct vop_readdirattr_args
*ap
)
706 (void)nop_readdirattr(ap
);
711 struct vop_readlink_args
/* {
718 nop_readlink(struct vop_readlink_args
*ap
)
724 err_readlink(struct vop_readlink_args
*ap
)
730 struct vop_abortop_args
/* {
732 struct componentname *a_cnp;
736 nop_abortop(struct vop_abortop_args
*ap
)
738 if ((ap
->a_cnp
->cn_flags
& (HASBUF
| SAVESTART
)) == HASBUF
) {
739 char *tmp
= ap
->a_cnp
->cn_pnbuf
;
740 ap
->a_cnp
->cn_pnbuf
= NULL
;
741 ap
->a_cnp
->cn_flags
&= ~HASBUF
;
742 FREE_ZONE(tmp
, ap
->a_cnp
->cn_pnlen
, M_NAMEI
);
749 err_abortop(struct vop_abortop_args
*ap
)
751 (void)nop_abortop(ap
);
756 struct vop_inactive_args
/* {
762 nop_inactive(struct vop_inactive_args
*ap
)
764 VOP_UNLOCK(ap
->a_vp
, 0, ap
->a_p
);
769 err_inactive(struct vop_inactive_args
*ap
)
771 (void)nop_inactive(ap
);
776 struct vop_reclaim_args
/* {
782 nop_reclaim(struct vop_reclaim_args
*ap
)
788 err_reclaim(struct vop_reclaim_args
*ap
)
794 struct vop_lock_args
/* {
801 nop_lock(struct vop_lock_args
*ap
)
803 return (vop_nolock(ap
));
807 err_lock(struct vop_lock_args
*ap
)
814 struct vop_unlock_args
/* {
821 nop_unlock(struct vop_unlock_args
*ap
)
823 return (vop_nounlock(ap
));
827 err_unlock(struct vop_unlock_args
*ap
)
829 (void)nop_unlock(ap
);
834 struct vop_bmap_args
/* {
843 nop_bmap(struct vop_bmap_args
*ap
)
849 err_bmap(struct vop_bmap_args
*ap
)
855 struct vop_strategy_args
/* {
860 nop_strategy(struct vop_strategy_args
*ap
)
866 err_strategy(struct vop_strategy_args
*ap
)
872 struct vop_print_args
/* {
877 nop_print(struct vop_print_args
*ap
)
883 err_print(struct vop_print_args
*ap
)
889 struct vop_islocked_args
/* {
894 nop_islocked(struct vop_islocked_args
*ap
)
896 return (vop_noislocked(ap
));
900 err_islocked(struct vop_islocked_args
*ap
)
902 (void)nop_islocked(ap
);
907 struct vop_pathconf_args
/* {
910 register_t *a_retval;
914 nop_pathconf(struct vop_pathconf_args
*ap
)
920 err_pathconf(struct vop_pathconf_args
*ap
)
926 struct vop_advlock_args
/* {
935 nop_advlock(struct vop_advlock_args
*ap
)
941 err_advlock(struct vop_advlock_args
*ap
)
947 struct vop_blkatoff_args
/* {
955 nop_blkatoff(struct vop_blkatoff_args
*ap
)
962 err_blkatoff(struct vop_blkatoff_args
*ap
)
964 (void)nop_blkatoff(ap
);
969 struct vop_valloc_args
/* {
972 struct ucred *a_cred;
973 struct vnode **a_vpp;
977 nop_valloc(struct vop_valloc_args
*ap
)
984 err_valloc(struct vop_valloc_args
*ap
)
986 (void)nop_valloc(ap
);
991 struct vop_reallocblks_args
/* {
993 struct cluster_save *a_buflist;
997 nop_reallocblks(struct vop_reallocblks_args
*ap
)
1003 err_reallocblks(struct vop_reallocblks_args
*ap
)
1005 return (EOPNOTSUPP
);
1009 struct vop_vfree_args
/* {
1010 struct vnode *a_pvp;
1016 nop_vfree(struct vop_vfree_args
*ap
)
1022 err_vfree(struct vop_vfree_args
*ap
)
1024 return (EOPNOTSUPP
);
1028 struct vop_truncate_args
/* {
1032 struct ucred *a_cred;
1037 nop_truncate(struct vop_truncate_args
*ap
)
1043 err_truncate(struct vop_truncate_args
*ap
)
1045 return (EOPNOTSUPP
);
1049 struct vop_allocate_args
/* {
1053 off_t *a_bytesallocated;
1055 struct ucred *a_cred;
1060 nop_allocate(struct vop_allocate_args
*ap
)
1062 *(ap
->a_bytesallocated
) = 0;
1067 err_allocate(struct vop_allocate_args
*ap
)
1069 (void)nop_allocate(ap
);
1070 return (EOPNOTSUPP
);
1074 struct vop_update_args
/* {
1076 struct timeval *a_access;
1077 struct timeval *a_modify;
1082 nop_update(struct vop_update_args
*ap
)
1088 err_update(struct vop_update_args
*ap
)
1090 return (EOPNOTSUPP
);
1094 struct vop_pgrd_args
/* {
1097 struct ucred *a_cred;
1101 nop_pgrd(struct vop_pgrd_args
*ap
)
1107 err_pgrd(struct vop_pgrd_args
*ap
)
1109 return (EOPNOTSUPP
);
1113 struct vop_pgwr_args
/* {
1116 struct ucred *a_cred;
1117 vm_offset_t a_offset;
1121 nop_pgwr(struct vop_pgwr_args
*ap
)
1127 err_pgwr(struct vop_pgwr_args
*ap
)
1129 return (EOPNOTSUPP
);
1133 struct vop_bwrite_args
/* {
1138 nop_bwrite(struct vop_bwrite_args
*ap
)
1140 return (bwrite(ap
->a_bp
));
1144 err_bwrite(struct vop_bwrite_args
*ap
)
1146 return (EOPNOTSUPP
);
1150 struct vop_pagein_args
/* {
1153 vm_offset_t a_pl_offset,
1156 struct ucred *a_cred,
1161 nop_pagein(struct vop_pagein_args
*ap
)
1163 ubc_upl_abort(ap
->a_pl
, UPL_ABORT_ERROR
);
1168 err_pagein(struct vop_pagein_args
*ap
)
1170 ubc_upl_abort(ap
->a_pl
, UPL_ABORT_ERROR
);
1171 return (EOPNOTSUPP
);
1175 struct vop_pageout_args
/* {
1178 vm_offset_t a_pl_offset,
1181 struct ucred *a_cred,
1186 nop_pageout(struct vop_pageout_args
*ap
)
1188 ubc_upl_abort(ap
->a_pl
, UPL_ABORT_ERROR
);
1193 err_pageout(struct vop_pageout_args
*ap
)
1195 ubc_upl_abort(ap
->a_pl
, UPL_ABORT_ERROR
);
1196 return (EOPNOTSUPP
);
1200 struct vop_devblocksize_args
/* {
1202 register_t *a_retval;
1206 nop_devblocksize(struct vop_devblocksize_args
*ap
)
1208 /* XXX default value because the call sites do not check error */
1209 *ap
->a_retval
= 512;
1214 err_devblocksize(struct vop_devblocksize_args
*ap
)
1216 (void)nop_devblocksize(ap
);
1217 return (EOPNOTSUPP
);
1221 struct vop_searchfs
/* {
1223 void *a_searchparams1;
1224 void *a_searchparams2;
1225 struct attrlist *a_searchattrs;
1226 u_long a_maxmatches;
1227 struct timeval *a_timelimit;
1228 struct attrlist *a_returnattrs;
1229 u_long *a_nummatches;
1230 u_long a_scriptcode;
1233 struct searchstate *a_searchstate;
1237 nop_searchfs(struct vop_searchfs_args
*ap
)
1239 *(ap
->a_nummatches
) = 0;
1244 err_searchfs(struct vop_searchfs_args
*ap
)
1246 (void)nop_searchfs(ap
);
1247 return (EOPNOTSUPP
);
1250 struct vop_copyfile_args
/*{
1251 struct vnodeop_desc *a_desc;
1252 struct vnode *a_fvp;
1253 struct vnode *a_tdvp;
1254 struct vnode *a_tvp;
1255 struct componentname *a_tcnp;
1260 nop_copyfile(struct vop_copyfile_args
*ap
)
1262 if (ap
->a_tdvp
== ap
->a_tvp
)
1274 err_copyfile(struct vop_copyfile_args
*ap
)
1276 (void)nop_copyfile(ap
);
1277 return (EOPNOTSUPP
);
1281 struct vop_blktooff_args
/* {
1288 nop_blktooff(struct vop_blktooff_args
*ap
)
1290 *ap
->a_offset
= (off_t
)-1; /* failure */
1295 err_blktooff(struct vop_blktooff_args
*ap
)
1297 (void)nop_blktooff(ap
);
1298 return (EOPNOTSUPP
);
1301 struct vop_offtoblk_args
/* {
1308 nop_offtoblk(struct vop_offtoblk_args
*ap
)
1310 *ap
->a_lblkno
= (daddr_t
)-1; /* failure */
1315 err_offtoblk(struct vop_offtoblk_args
*ap
)
1317 (void)nop_offtoblk(ap
);
1318 return (EOPNOTSUPP
);
1321 struct vop_cmap_args
/* {
1330 int nop_cmap(struct vop_cmap_args
*ap
)
1335 int err_cmap(struct vop_cmap_args
*ap
)
1337 return (EOPNOTSUPP
);