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