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