vfs_default.c revision 30492
1/* 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed 6 * to Berkeley by John Heidemann of the UCLA Ficus project. 7 * 8 * Source: * @(#)i405_init.c 2.10 92/04/27 UCLA Ficus project 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the University of 21 * California, Berkeley and its contributors. 22 * 4. Neither the name of the University nor the names of its contributors 23 * may be used to endorse or promote products derived from this software 24 * without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 */ 39 40#include <sys/param.h> 41#include <sys/systm.h> 42#include <sys/kernel.h> 43#include <sys/mount.h> 44#include <sys/unistd.h> 45#include <sys/vnode.h> 46 47static int vop_nostrategy __P((struct vop_strategy_args *)); 48 49/* 50 * This vnode table stores what we want to do if the filesystem doesn't 51 * implement a particular VOP. 52 * 53 * If there is no specific entry here, we will return EOPNOTSUPP. 54 * 55 */ 56 57vop_t **default_vnodeop_p; 58static struct vnodeopv_entry_desc default_vnodeop_entries[] = { 59 { &vop_default_desc, (vop_t *) vop_eopnotsupp }, 60 { &vop_abortop_desc, (vop_t *) nullop }, 61 { &vop_advlock_desc, (vop_t *) vop_einval }, 62 { &vop_bwrite_desc, (vop_t *) vn_bwrite }, 63 { &vop_close_desc, (vop_t *) vop_null }, 64 { &vop_fsync_desc, (vop_t *) vop_null }, 65 { &vop_ioctl_desc, (vop_t *) vop_enotty }, 66 { &vop_lease_desc, (vop_t *) lease_check }, 67 { &vop_mmap_desc, (vop_t *) vop_einval }, 68 { &vop_open_desc, (vop_t *) vop_null }, 69 { &vop_pathconf_desc, (vop_t *) vop_einval }, 70 { &vop_poll_desc, (vop_t *) vop_nopoll }, 71 { &vop_readlink_desc, (vop_t *) vop_einval }, 72 { &vop_reallocblks_desc, (vop_t *) vop_eopnotsupp }, 73 { &vop_revoke_desc, (vop_t *) vop_revoke }, 74 { &vop_strategy_desc, (vop_t *) vop_nostrategy }, 75 { NULL, NULL } 76}; 77 78static struct vnodeopv_desc default_vnodeop_opv_desc = 79 { &default_vnodeop_p, default_vnodeop_entries }; 80 81VNODEOP_SET(default_vnodeop_opv_desc); 82 83int 84vop_eopnotsupp(struct vop_generic_args *ap) 85{ 86 /* 87 printf("vop_notsupp[%s]\n", ap->a_desc->vdesc_name); 88 */ 89 90 return (EOPNOTSUPP); 91} 92 93int 94vop_ebadf(struct vop_generic_args *ap) 95{ 96 97 return (EBADF); 98} 99 100int 101vop_enotty(struct vop_generic_args *ap) 102{ 103 104 return (ENOTTY); 105} 106 107int 108vop_einval(struct vop_generic_args *ap) 109{ 110 111 return (EINVAL); 112} 113 114int 115vop_null(struct vop_generic_args *ap) 116{ 117 118 return (0); 119} 120 121int 122vop_defaultop(struct vop_generic_args *ap) 123{ 124 125 return (VOCALL(default_vnodeop_p, ap->a_desc->vdesc_offset, ap)); 126} 127 128static int 129vop_nostrategy (struct vop_strategy_args *ap) 130{ 131 printf("No strategy for buffer at %p\n", ap->a_bp); 132 vprint("", ap->a_bp->b_vp); 133 ap->a_bp->b_flags |= B_ERROR; 134 ap->a_bp->b_error = EOPNOTSUPP; 135 biodone(ap->a_bp); 136 return (EOPNOTSUPP); 137} 138 139int 140vop_stdpathconf(ap) 141 struct vop_pathconf_args /* { 142 struct vnode *a_vp; 143 int a_name; 144 int *a_retval; 145 } */ *ap; 146{ 147 148 switch (ap->a_name) { 149 case _PC_LINK_MAX: 150 *ap->a_retval = LINK_MAX; 151 return (0); 152 case _PC_MAX_CANON: 153 *ap->a_retval = MAX_CANON; 154 return (0); 155 case _PC_MAX_INPUT: 156 *ap->a_retval = MAX_INPUT; 157 return (0); 158 case _PC_PIPE_BUF: 159 *ap->a_retval = PIPE_BUF; 160 return (0); 161 case _PC_CHOWN_RESTRICTED: 162 *ap->a_retval = 1; 163 return (0); 164 case _PC_VDISABLE: 165 *ap->a_retval = _POSIX_VDISABLE; 166 return (0); 167 default: 168 return (EINVAL); 169 } 170 /* NOTREACHED */ 171} 172