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