vfs_default.c revision 30513
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_islocked_desc, (vop_t *) vop_noislocked }, 67 { &vop_lease_desc, (vop_t *) lease_check }, 68 { &vop_lock_desc, (vop_t *) vop_nolock }, 69 { &vop_mmap_desc, (vop_t *) vop_einval }, 70 { &vop_open_desc, (vop_t *) vop_null }, 71 { &vop_pathconf_desc, (vop_t *) vop_einval }, 72 { &vop_poll_desc, (vop_t *) vop_nopoll }, 73 { &vop_readlink_desc, (vop_t *) vop_einval }, 74 { &vop_reallocblks_desc, (vop_t *) vop_eopnotsupp }, 75 { &vop_revoke_desc, (vop_t *) vop_revoke }, 76 { &vop_strategy_desc, (vop_t *) vop_nostrategy }, 77 { &vop_unlock_desc, (vop_t *) vop_nounlock }, 78 { NULL, NULL } 79}; 80 81static struct vnodeopv_desc default_vnodeop_opv_desc = 82 { &default_vnodeop_p, default_vnodeop_entries }; 83 84VNODEOP_SET(default_vnodeop_opv_desc); 85 86int 87vop_eopnotsupp(struct vop_generic_args *ap) 88{ 89 /* 90 printf("vop_notsupp[%s]\n", ap->a_desc->vdesc_name); 91 */ 92 93 return (EOPNOTSUPP); 94} 95 96int 97vop_ebadf(struct vop_generic_args *ap) 98{ 99 100 return (EBADF); 101} 102 103int 104vop_enotty(struct vop_generic_args *ap) 105{ 106 107 return (ENOTTY); 108} 109 110int 111vop_einval(struct vop_generic_args *ap) 112{ 113 114 return (EINVAL); 115} 116 117int 118vop_null(struct vop_generic_args *ap) 119{ 120 121 return (0); 122} 123 124int 125vop_defaultop(struct vop_generic_args *ap) 126{ 127 128 return (VOCALL(default_vnodeop_p, ap->a_desc->vdesc_offset, ap)); 129} 130 131static int 132vop_nostrategy (struct vop_strategy_args *ap) 133{ 134 printf("No strategy for buffer at %p\n", ap->a_bp); 135 vprint("", ap->a_bp->b_vp); 136 ap->a_bp->b_flags |= B_ERROR; 137 ap->a_bp->b_error = EOPNOTSUPP; 138 biodone(ap->a_bp); 139 return (EOPNOTSUPP); 140} 141 142int 143vop_stdpathconf(ap) 144 struct vop_pathconf_args /* { 145 struct vnode *a_vp; 146 int a_name; 147 int *a_retval; 148 } */ *ap; 149{ 150 151 switch (ap->a_name) { 152 case _PC_LINK_MAX: 153 *ap->a_retval = LINK_MAX; 154 return (0); 155 case _PC_MAX_CANON: 156 *ap->a_retval = MAX_CANON; 157 return (0); 158 case _PC_MAX_INPUT: 159 *ap->a_retval = MAX_INPUT; 160 return (0); 161 case _PC_PIPE_BUF: 162 *ap->a_retval = PIPE_BUF; 163 return (0); 164 case _PC_CHOWN_RESTRICTED: 165 *ap->a_retval = 1; 166 return (0); 167 case _PC_VDISABLE: 168 *ap->a_retval = _POSIX_VDISABLE; 169 return (0); 170 default: 171 return (EINVAL); 172 } 173 /* NOTREACHED */ 174} 175 176/* 177 * Standard lock, unlock and islocked functions. 178 * 179 * These depend on the lock structure being the first element in the 180 * inode, ie: vp->v_data points to the the lock! 181 */ 182int 183vop_stdlock(ap) 184 struct vop_lock_args /* { 185 struct vnode *a_vp; 186 int a_flags; 187 struct proc *a_p; 188 } */ *ap; 189{ 190 struct lock *l = (struct lock*)ap->a_vp->v_data; 191 192 return (lockmgr(l, ap->a_flags, &ap->a_vp->v_interlock, ap->a_p)); 193} 194 195int 196vop_stdunlock(ap) 197 struct vop_unlock_args /* { 198 struct vnode *a_vp; 199 int a_flags; 200 struct proc *a_p; 201 } */ *ap; 202{ 203 struct lock *l = (struct lock*)ap->a_vp->v_data; 204 205 return (lockmgr(l, ap->a_flags | LK_RELEASE, &ap->a_vp->v_interlock, 206 ap->a_p)); 207} 208 209int 210vop_stdislocked(ap) 211 struct vop_islocked_args /* { 212 struct vnode *a_vp; 213 } */ *ap; 214{ 215 struct lock *l = (struct lock*)ap->a_vp->v_data; 216 217 return (lockstatus(l)); 218} 219 220