]> git.saurik.com Git - apple/xnu.git/blob - bsd/vfs/vfs_support.c
xnu-792.12.6.tar.gz
[apple/xnu.git] / bsd / vfs / vfs_support.c
1 /*
2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
5 *
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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 /*
31 * Copyright (c) 1998-1999 Apple Computer, Inc. All rights reserved.
32 *
33 * File: vfs/vfs_support.c
34 *
35 * The default VFS routines. A VFS plugin can use these
36 * functions in case it does not want to implement all. These functions
37 * take care of releasing locks and free up memory that they are
38 * supposed to.
39 *
40 * nop_* routines always return 0 [success]
41 * err_* routines always return ENOTSUP
42 *
43 * This file could be auto-generated from vnode_if.src. but that needs
44 * support for freeing cnp.
45 *
46 * HISTORY
47 * 15-Jul-1998 Earsh Nandkeshwar (earsh@apple.com)
48 * Fixed up readdirattr for its existance now.
49 * 18-Aug-1998 Umesh Vaishampayan (umeshv@apple.com)
50 * Created.
51 */
52
53 #include <vfs/vfs_support.h>
54 #include <sys/kauth.h>
55
56
57 struct vnop_create_args /* {
58 struct vnode *a_dvp;
59 struct vnode **a_vpp;
60 struct componentname *a_cnp;
61 struct vnode_vattr *a_vap;
62 vfs_context_t a_context;
63 } */;
64
65 int
66 nop_create(struct vnop_create_args *ap)
67 {
68 #if DIAGNOSTIC
69 if ((ap->a_cnp->cn_flags & HASBUF) == 0)
70 panic("nop_create: no name");
71 #endif
72 return (0);
73 }
74
75 int
76 err_create(struct vnop_create_args *ap)
77 {
78 (void)nop_create(ap);
79 return (ENOTSUP);
80 }
81
82
83 struct vnop_whiteout_args /* {
84 struct vnode *a_dvp;
85 struct componentname *a_cnp;
86 int a_flags;
87 vfs_context_t a_context;
88 } */;
89
90 int
91 nop_whiteout(struct vnop_whiteout_args *ap)
92 {
93 return (0);
94 }
95
96 int
97 err_whiteout(struct vnop_whiteout_args *ap)
98 {
99 return (ENOTSUP);
100 }
101
102
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;
109 } */;
110
111 int
112 nop_mknod(struct vnop_mknod_args *ap)
113 {
114 #if DIAGNOSTIC
115 if ((ap->a_cnp->cn_flags & HASBUF) == 0)
116 panic("nop_mknod: no name");
117 #endif
118 return (0);
119 }
120
121 int
122 err_mknod(struct vnop_mknod_args *ap)
123 {
124 (void)nop_mknod(ap);
125 return (ENOTSUP);
126 }
127
128 struct vnop_open_args /* {
129 struct vnode *a_vp;
130 int a_mode;
131 vfs_context_t a_context;
132 } */;
133
134 int
135 nop_open(struct vnop_open_args *ap)
136 {
137 return (0);
138 }
139
140 int
141 err_open(struct vnop_open_args *ap)
142 {
143 return (ENOTSUP);
144 }
145
146
147 struct vnop_close_args /* {
148 struct vnode *a_vp;
149 int a_fflag;
150 vfs_context_t a_context;
151 } */;
152
153 int
154 nop_close(struct vnop_close_args *ap)
155 {
156 return (0);
157 }
158
159 int
160 err_close(struct vnop_close_args *ap)
161 {
162 return (ENOTSUP);
163 }
164
165
166 struct vnop_access_args /* {
167 struct vnode *a_vp;
168 int a_mode;
169 vfs_context_t a_context;
170 } */;
171
172 int
173 nop_access(struct vnop_access_args *ap)
174 {
175 return (0);
176 }
177
178 int
179 err_access(struct vnop_access_args *ap)
180 {
181 return (ENOTSUP);
182 }
183
184
185 struct vnop_getattr_args /* {
186 struct vnode *a_vp;
187 struct vnode_vattr *a_vap;
188 vfs_context_t a_context;
189 } */;
190
191 int
192 nop_getattr(struct vnop_getattr_args *ap)
193 {
194 return (0);
195 }
196
197 int
198 err_getattr(struct vnop_getattr_args *ap)
199 {
200 return (ENOTSUP);
201 }
202
203
204 struct vnop_setattr_args /* {
205 struct vnode *a_vp;
206 struct vnode_vattr *a_vap;
207 vfs_context_t a_context;
208 } */;
209
210 int
211 nop_setattr(struct vnop_setattr_args *ap)
212 {
213 return (0);
214 }
215
216 int
217 err_setattr(struct vnop_setattr_args *ap)
218 {
219 return (ENOTSUP);
220 }
221
222
223 struct vnop_getattrlist_args /* {
224 struct vnode *a_vp;
225 struct attrlist *a_alist;
226 struct uio *a_uio;
227 int a_options;
228 vfs_context a_context;
229 } */;
230
231 int
232 nop_getattrlist(struct vnop_getattrlist_args *ap)
233 {
234 return (0);
235 }
236
237 int
238 err_getattrlist(struct vnop_getattrlist_args *ap)
239 {
240 return (ENOTSUP);
241 }
242
243
244 struct vnop_setattrlist_args /* {
245 struct vnode *a_vp;
246 struct attrlist *a_alist;
247 struct uio *a_uio;
248 int a_options;
249 vfs_context_t a_context;
250 } */;
251
252 int
253 nop_setattrlist(struct vnop_setattrlist_args *ap)
254 {
255 return (0);
256 }
257
258 int
259 err_setattrlist(struct vnop_setattrlist_args *ap)
260 {
261 return (ENOTSUP);
262 }
263
264
265 struct vnop_read_args /* {
266 struct vnode *a_vp;
267 struct uio *a_uio;
268 int a_ioflag;
269 vfs_context_t a_context;
270 } */;
271
272 int
273 nop_read(struct vnop_read_args *ap)
274 {
275 return (0);
276 }
277
278 int
279 err_read(struct vnop_read_args *ap)
280 {
281 return (ENOTSUP);
282 }
283
284
285 struct vnop_write_args /* {
286 struct vnode *a_vp;
287 struct uio *a_uio;
288 int a_ioflag;
289 vfs_context_t a_context;
290 } */;
291
292 int
293 nop_write(struct vnop_write_args *ap)
294 {
295 return (0);
296 }
297
298 int
299 err_write(struct vnop_write_args *ap)
300 {
301 return (ENOTSUP);
302 }
303
304
305 struct vnop_ioctl_args /* {
306 struct vnode *a_vp;
307 u_long a_command;
308 caddr_t a_data;
309 int a_fflag;
310 kauth_cred_t a_cred;
311 struct proc *a_p;
312 } */;
313
314 int
315 nop_ioctl(__unused struct vnop_ioctl_args *ap)
316 {
317 return (0);
318 }
319
320 int
321 err_ioctl(struct vnop_ioctl_args *ap)
322 {
323 return (ENOTSUP);
324 }
325
326
327 struct vnop_select_args /* {
328 struct vnode *a_vp;
329 int a_which;
330 int a_fflags;
331 kauth_cred_t a_cred;
332 void *a_wql;
333 struct proc *a_p;
334 } */;
335
336 int
337 nop_select(__unused struct vnop_select_args *ap)
338 {
339 return (0);
340 }
341
342 int
343 err_select(struct vnop_select_args *ap)
344 {
345 return (ENOTSUP);
346 }
347
348
349 struct vnop_exchange_args /* {
350 struct vnode *a_fvp;
351 struct vnode *a_tvp;
352 int a_options;
353 vfs_context_t a_context;
354 } */;
355
356 int
357 nop_exchange(struct vnop_exchange_args *ap)
358 {
359 return (0);
360 }
361
362 int
363 err_exchange(struct vnop_exchange_args *ap)
364 {
365 return (ENOTSUP);
366 }
367
368
369 struct vnop_revoke_args /* {
370 struct vnode *a_vp;
371 int a_flags;
372 vfs_context_t a_context;
373 } */;
374
375 int
376 nop_revoke(struct vnop_revoke_args *ap)
377 {
378 return vn_revoke(ap->a_vp, ap->a_flags, ap->a_context);
379 }
380
381 int
382 err_revoke(struct vnop_revoke_args *ap)
383 {
384 (void)nop_revoke(ap);
385 return (ENOTSUP);
386 }
387
388
389 struct vnop_mmap_args /* {
390 struct vnode *a_vp;
391 int a_fflags;
392 kauth_cred_t a_cred;
393 struct proc *a_p;
394 } */;
395
396 int
397 nop_mmap(__unused struct vnop_mmap_args *ap)
398 {
399 return (0);
400 }
401
402 int
403 err_mmap(struct vnop_mmap_args *ap)
404 {
405 return (ENOTSUP);
406 }
407
408
409 struct vnop_fsync_args /* {
410 struct vnode *a_vp;
411 int a_waitfor;
412 vfs_context_t a_context;
413 } */;
414
415 int
416 nop_fsync(struct vnop_fsync_args *ap)
417 {
418 return (0);
419 }
420
421 int
422 err_fsync(struct vnop_fsync_args *ap)
423 {
424 return (ENOTSUP);
425 }
426
427
428 struct vnop_remove_args /* {
429 struct vnode *a_dvp;
430 struct vnode *a_vp;
431 struct componentname *a_cnp;
432 int a_flags;
433 vfs_context_t a_context;
434 } */;
435
436 int
437 nop_remove(struct vnop_remove_args *ap)
438 {
439 return (0);
440 }
441
442 int
443 err_remove(struct vnop_remove_args *ap)
444 {
445 (void)nop_remove(ap);
446 return (ENOTSUP);
447 }
448
449
450 struct vnop_link_args /* {
451 struct vnode *a_vp;
452 struct vnode *a_tdvp;
453 struct componentname *a_cnp;
454 vfs_context_t a_context;
455 } */;
456
457 int
458 nop_link(struct vnop_link_args *ap)
459 {
460 return (0);
461 }
462
463 int
464 err_link(struct vnop_link_args *ap)
465 {
466 (void)nop_link(ap);
467 return (ENOTSUP);
468 }
469
470
471 struct vnop_rename_args /* {
472 struct vnode *a_fdvp;
473 struct vnode *a_fvp;
474 struct componentname *a_fcnp;
475 struct vnode *a_tdvp;
476 struct vnode *a_tvp;
477 struct componentname *a_tcnp;
478 vfs_context_t a_context;
479 } */;
480
481 int
482 nop_rename(struct vnop_rename_args *ap)
483 {
484 return (0);
485 }
486
487 int
488 err_rename(struct vnop_rename_args *ap)
489 {
490 (void)nop_rename(ap);
491 return (ENOTSUP);
492 }
493
494
495 struct vnop_mkdir_args /* {
496 struct vnode *a_dvp;
497 struct vnode **a_vpp;
498 struct componentname *a_cnp;
499 struct vnode_vattr *a_vap;
500 vfs_context_t a_context;
501 } */;
502
503 int
504 nop_mkdir(struct vnop_mkdir_args *ap)
505 {
506 return (0);
507 }
508
509 int
510 err_mkdir(struct vnop_mkdir_args *ap)
511 {
512 return (ENOTSUP);
513 }
514
515
516 struct vnop_rmdir_args /* {
517 struct vnode *a_dvp;
518 struct vnode *a_vp;
519 struct componentname *a_cnp;
520 vfs_context_t a_context;
521 } */;
522
523 int
524 nop_rmdir(struct vnop_rmdir_args *ap)
525 {
526 return (0);
527 }
528
529 int
530 err_rmdir(struct vnop_rmdir_args *ap)
531 {
532 (void)nop_rmdir(ap);
533 return (ENOTSUP);
534 }
535
536
537 struct vnop_symlink_args /* {
538 struct vnode *a_dvp;
539 struct vnode **a_vpp;
540 struct componentname *a_cnp;
541 struct vnode_vattr *a_vap;
542 char *a_target;
543 vfs_context_t a_context;
544 } */;
545
546 int
547 nop_symlink(struct vnop_symlink_args *ap)
548 {
549 #if DIAGNOSTIC
550 if ((ap->a_cnp->cn_flags & HASBUF) == 0)
551 panic("nop_symlink: no name");
552 #endif
553 return (0);
554 }
555
556 int
557 err_symlink(struct vnop_symlink_args *ap)
558 {
559 (void)nop_symlink(ap);
560 return (ENOTSUP);
561 }
562
563
564 struct vnop_readdir_args /* {
565 vnode_t a_vp;
566 struct uio *a_uio;
567 int a_flags;
568 int *a_eofflag;
569 int *a_numdirent;
570 vfs_context_t a_context;
571 } */;
572
573 int
574 nop_readdir(struct vnop_readdir_args *ap)
575 {
576 return (0);
577 }
578
579 int
580 err_readdir(struct vnop_readdir_args *ap)
581 {
582 return (ENOTSUP);
583 }
584
585
586 struct vnop_readdirattr_args /* {
587 struct vnode *a_vp;
588 struct attrlist *a_alist;
589 struct uio *a_uio;
590 u_long a_maxcount;
591 u_long a_options;
592 int *a_newstate;
593 int *a_eofflag;
594 u_long *a_actualcount;
595 vfs_context_t a_context;
596 } */;
597
598 int
599 nop_readdirattr(struct vnop_readdirattr_args *ap)
600 {
601 *(ap->a_actualcount) = 0;
602 *(ap->a_eofflag) = 0;
603 return (0);
604 }
605
606 int
607 err_readdirattr(struct vnop_readdirattr_args *ap)
608 {
609 (void)nop_readdirattr(ap);
610 return (ENOTSUP);
611 }
612
613
614 struct vnop_readlink_args /* {
615 struct vnode *vp;
616 struct uio *uio;
617 vfs_context_t a_context;
618 } */;
619
620 int
621 nop_readlink(struct vnop_readlink_args *ap)
622 {
623 return (0);
624 }
625
626 int
627 err_readlink(struct vnop_readlink_args *ap)
628 {
629 return (ENOTSUP);
630 }
631
632
633 struct vnop_inactive_args /* {
634 struct vnode *a_vp;
635 vfs_context_t a_context;
636 } */;
637
638 int
639 nop_inactive(struct vnop_inactive_args *ap)
640 {
641 return (0);
642 }
643
644 int
645 err_inactive(struct vnop_inactive_args *ap)
646 {
647 (void)nop_inactive(ap);
648 return (ENOTSUP);
649 }
650
651
652 struct vnop_reclaim_args /* {
653 struct vnode *a_vp;
654 vfs_context_t a_context;
655 } */;
656
657 int
658 nop_reclaim(struct vnop_reclaim_args *ap)
659 {
660 return (0);
661 }
662
663 int
664 err_reclaim(struct vnop_reclaim_args *ap)
665 {
666 return (ENOTSUP);
667 }
668
669
670 struct vnop_strategy_args /* {
671 struct buf *a_bp;
672 } */;
673
674 int
675 nop_strategy(struct vnop_strategy_args *ap)
676 {
677 return (0);
678 }
679
680 int
681 err_strategy(struct vnop_strategy_args *ap)
682 {
683 return (ENOTSUP);
684 }
685
686
687 struct vnop_pathconf_args /* {
688 struct vnode *a_vp;
689 int a_name;
690 register_t *a_retval;
691 vfs_context_t a_context;
692 } */;
693
694 int
695 nop_pathconf(struct vnop_pathconf_args *ap)
696 {
697 return (0);
698 }
699
700 int
701 err_pathconf(struct vnop_pathconf_args *ap)
702 {
703 return (ENOTSUP);
704 }
705
706
707 struct vnop_advlock_args /* {
708 struct vnode *a_vp;
709 caddr_t a_id;
710 int a_op;
711 struct flock *a_fl;
712 int a_flags;
713 vfs_context_t a_context;
714 } */;
715
716 int
717 nop_advlock(struct vnop_advlock_args *ap)
718 {
719 return (0);
720 }
721
722 int
723 err_advlock(struct vnop_advlock_args *ap)
724 {
725 return (ENOTSUP);
726 }
727
728
729
730 struct vnop_allocate_args /* {
731 struct vnode *a_vp;
732 off_t a_length;
733 u_int32_t a_flags;
734 off_t *a_bytesallocated;
735 off_t a_offset;
736 vfs_context_t a_context;
737 } */;
738
739 int
740 nop_allocate(struct vnop_allocate_args *ap)
741 {
742 *(ap->a_bytesallocated) = 0;
743 return (0);
744 }
745
746 int
747 err_allocate(struct vnop_allocate_args *ap)
748 {
749 (void)nop_allocate(ap);
750 return (ENOTSUP);
751 }
752
753 struct vnop_bwrite_args /* {
754 struct buf *a_bp;
755 } */;
756
757 int
758 nop_bwrite(struct vnop_bwrite_args *ap)
759 {
760 return ((int)buf_bwrite(ap->a_bp));
761 }
762
763 int
764 err_bwrite(struct vnop_bwrite_args *ap)
765 {
766 return (ENOTSUP);
767 }
768
769
770 struct vnop_pagein_args /* {
771 struct vnode *a_vp,
772 upl_t a_pl,
773 vm_offset_t a_pl_offset,
774 off_t a_foffset,
775 size_t a_size,
776 int a_flags
777 vfs_context_t a_context;
778 } */;
779
780 int
781 nop_pagein(struct vnop_pagein_args *ap)
782 {
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);
785 return (EINVAL);
786 }
787
788 int
789 err_pagein(struct vnop_pagein_args *ap)
790 {
791 if ( !(ap->a_flags & UPL_NOCOMMIT))
792 ubc_upl_abort_range(ap->a_pl, ap->a_pl_offset, ap->a_size, UPL_ABORT_FREE_ON_EMPTY | UPL_ABORT_ERROR);
793 return (ENOTSUP);
794 }
795
796
797 struct vnop_pageout_args /* {
798 struct vnode *a_vp,
799 upl_t a_pl,
800 vm_offset_t a_pl_offset,
801 off_t a_foffset,
802 size_t a_size,
803 int a_flags
804 vfs_context_t a_context;
805 } */;
806
807 int
808 nop_pageout(struct vnop_pageout_args *ap)
809 {
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);
812 return (EINVAL);
813 }
814
815 int
816 err_pageout(struct vnop_pageout_args *ap)
817 {
818 if ( !(ap->a_flags & UPL_NOCOMMIT))
819 ubc_upl_abort_range(ap->a_pl, ap->a_pl_offset, ap->a_size, UPL_ABORT_FREE_ON_EMPTY | UPL_ABORT_ERROR);
820 return (ENOTSUP);
821 }
822
823
824 struct vnop_devblocksize_args /* {
825 struct vnode *a_vp;
826 register_t *a_retval;
827 } */;
828
829 int
830 nop_devblocksize(struct vnop_devblocksize_args *ap)
831 {
832 /* XXX default value because the call sites do not check error */
833 *ap->a_retval = 512;
834 return (0);
835 }
836
837 int
838 err_devblocksize(struct vnop_devblocksize_args *ap)
839 {
840 (void)nop_devblocksize(ap);
841 return (ENOTSUP);
842 }
843
844
845 struct vnop_searchfs /* {
846 struct vnode *a_vp;
847 void *a_searchparams1;
848 void *a_searchparams2;
849 struct attrlist *a_searchattrs;
850 u_long a_maxmatches;
851 struct timeval *a_timelimit;
852 struct attrlist *a_returnattrs;
853 u_long *a_nummatches;
854 u_long a_scriptcode;
855 u_long a_options;
856 struct uio *a_uio;
857 struct searchstate *a_searchstate;
858 vfs_context_t a_context;
859 } */;
860
861 int
862 nop_searchfs(struct vnop_searchfs_args *ap)
863 {
864 *(ap->a_nummatches) = 0;
865 return (0);
866 }
867
868 int
869 err_searchfs(struct vnop_searchfs_args *ap)
870 {
871 (void)nop_searchfs(ap);
872 return (ENOTSUP);
873 }
874
875 struct vnop_copyfile_args /*{
876 struct vnodeop_desc *a_desc;
877 struct vnode *a_fvp;
878 struct vnode *a_tdvp;
879 struct vnode *a_tvp;
880 struct componentname *a_tcnp;
881 int a_flags;
882 }*/;
883
884 int
885 nop_copyfile(struct vnop_copyfile_args *ap)
886 {
887 return (0);
888 }
889
890
891 int
892 err_copyfile(struct vnop_copyfile_args *ap)
893 {
894 (void)nop_copyfile(ap);
895 return (ENOTSUP);
896 }
897
898
899 struct vnop_blktooff_args /* {
900 struct vnode *a_vp;
901 daddr64_t a_lblkno;
902 off_t *a_offset;
903 } */;
904
905 int
906 nop_blktooff(struct vnop_blktooff_args *ap)
907 {
908 *ap->a_offset = (off_t)-1; /* failure */
909 return (0);
910 }
911
912 int
913 err_blktooff(struct vnop_blktooff_args *ap)
914 {
915 (void)nop_blktooff(ap);
916 return (ENOTSUP);
917 }
918
919 struct vnop_offtoblk_args /* {
920 struct vnode *a_vp;
921 off_t a_offset;
922 daddr64_t *a_lblkno;
923 } */;
924
925 int
926 nop_offtoblk(struct vnop_offtoblk_args *ap)
927 {
928 *ap->a_lblkno = (daddr64_t)-1; /* failure */
929 return (0);
930 }
931
932 int
933 err_offtoblk(struct vnop_offtoblk_args *ap)
934 {
935 (void)nop_offtoblk(ap);
936 return (ENOTSUP);
937 }
938
939 struct vnop_blockmap_args /* {
940 struct vnode *a_vp;
941 off_t a_foffset;
942 size_t a_size;
943 daddr64_t *a_bpn;
944 size_t *a_run;
945 void *a_poff;
946 int a_flags;
947 } */;
948
949 int nop_blockmap(struct vnop_blockmap_args *ap)
950 {
951 return (0);
952 }
953
954 int err_blockmap(struct vnop_blockmap_args *ap)
955 {
956 return (ENOTSUP);
957 }
958