1/*- 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 4. Neither the name of the University nor the names of its contributors 14 * may be used to endorse or promote products derived from this software 15 * without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)dead_vnops.c 8.1 (Berkeley) 6/10/93
| 1/*- 2 * Copyright (c) 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 4. Neither the name of the University nor the names of its contributors 14 * may be used to endorse or promote products derived from this software 15 * without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * @(#)dead_vnops.c 8.1 (Berkeley) 6/10/93
|
30 * $FreeBSD: head/sys/fs/deadfs/dead_vnops.c 143506 2005-03-13 12:06:20Z jeff $
| 30 * $FreeBSD: head/sys/fs/deadfs/dead_vnops.c 155896 2006-02-22 06:11:59Z jeff $
|
31 */ 32 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/kernel.h> 36#include <sys/lock.h> 37#include <sys/mutex.h> 38#include <sys/poll.h> 39#include <sys/vnode.h> 40 41/* 42 * Prototypes for dead operations on vnodes. 43 */ 44static vop_bmap_t dead_bmap; 45static vop_ioctl_t dead_ioctl; 46static vop_lookup_t dead_lookup; 47static vop_open_t dead_open; 48static vop_poll_t dead_poll; 49static vop_read_t dead_read; 50static vop_write_t dead_write;
| 31 */ 32 33#include <sys/param.h> 34#include <sys/systm.h> 35#include <sys/kernel.h> 36#include <sys/lock.h> 37#include <sys/mutex.h> 38#include <sys/poll.h> 39#include <sys/vnode.h> 40 41/* 42 * Prototypes for dead operations on vnodes. 43 */ 44static vop_bmap_t dead_bmap; 45static vop_ioctl_t dead_ioctl; 46static vop_lookup_t dead_lookup; 47static vop_open_t dead_open; 48static vop_poll_t dead_poll; 49static vop_read_t dead_read; 50static vop_write_t dead_write;
|
| 51static vop_getwritemount_t dead_getwritemount;
|
51 52struct vop_vector dead_vnodeops = { 53 .vop_default = &default_vnodeops, 54 55 .vop_access = VOP_EBADF, 56 .vop_advlock = VOP_EBADF, 57 .vop_bmap = dead_bmap, 58 .vop_create = VOP_PANIC, 59 .vop_getattr = VOP_EBADF,
| 52 53struct vop_vector dead_vnodeops = { 54 .vop_default = &default_vnodeops, 55 56 .vop_access = VOP_EBADF, 57 .vop_advlock = VOP_EBADF, 58 .vop_bmap = dead_bmap, 59 .vop_create = VOP_PANIC, 60 .vop_getattr = VOP_EBADF,
|
| 61 .vop_getwritemount = dead_getwritemount,
|
60 .vop_inactive = VOP_NULL, 61 .vop_ioctl = dead_ioctl, 62 .vop_link = VOP_PANIC, 63 .vop_lookup = dead_lookup, 64 .vop_mkdir = VOP_PANIC, 65 .vop_mknod = VOP_PANIC, 66 .vop_open = dead_open, 67 .vop_pathconf = VOP_EBADF, /* per pathconf(2) */ 68 .vop_poll = dead_poll, 69 .vop_read = dead_read, 70 .vop_readdir = VOP_EBADF, 71 .vop_readlink = VOP_EBADF, 72 .vop_reclaim = VOP_NULL, 73 .vop_remove = VOP_PANIC, 74 .vop_rename = VOP_PANIC, 75 .vop_rmdir = VOP_PANIC, 76 .vop_setattr = VOP_EBADF, 77 .vop_symlink = VOP_PANIC, 78 .vop_write = dead_write, 79}; 80
| 62 .vop_inactive = VOP_NULL, 63 .vop_ioctl = dead_ioctl, 64 .vop_link = VOP_PANIC, 65 .vop_lookup = dead_lookup, 66 .vop_mkdir = VOP_PANIC, 67 .vop_mknod = VOP_PANIC, 68 .vop_open = dead_open, 69 .vop_pathconf = VOP_EBADF, /* per pathconf(2) */ 70 .vop_poll = dead_poll, 71 .vop_read = dead_read, 72 .vop_readdir = VOP_EBADF, 73 .vop_readlink = VOP_EBADF, 74 .vop_reclaim = VOP_NULL, 75 .vop_remove = VOP_PANIC, 76 .vop_rename = VOP_PANIC, 77 .vop_rmdir = VOP_PANIC, 78 .vop_setattr = VOP_EBADF, 79 .vop_symlink = VOP_PANIC, 80 .vop_write = dead_write, 81}; 82
|
| 83/* ARGSUSED */ 84static int 85dead_getwritemount(ap) 86 struct vop_getwritemount_args /* { 87 struct vnode *a_vp; 88 struct mount **a_mpp; 89 } */ *ap; 90{ 91 *(ap->a_mpp) = NULL; 92 return (0); 93} 94
|
81/* 82 * Trivial lookup routine that always fails. 83 */ 84/* ARGSUSED */ 85static int 86dead_lookup(ap) 87 struct vop_lookup_args /* { 88 struct vnode * a_dvp; 89 struct vnode ** a_vpp; 90 struct componentname * a_cnp; 91 } */ *ap; 92{ 93 94 *ap->a_vpp = NULL; 95 return (ENOTDIR); 96} 97 98/* 99 * Open always fails as if device did not exist. 100 */ 101/* ARGSUSED */ 102static int 103dead_open(ap) 104 struct vop_open_args /* { 105 struct vnode *a_vp; 106 int a_mode; 107 struct ucred *a_cred; 108 struct proc *a_p; 109 } */ *ap; 110{ 111 112 return (ENXIO); 113} 114 115/* 116 * Vnode op for read 117 */ 118/* ARGSUSED */ 119static int 120dead_read(ap) 121 struct vop_read_args /* { 122 struct vnode *a_vp; 123 struct uio *a_uio; 124 int a_ioflag; 125 struct ucred *a_cred; 126 } */ *ap; 127{ 128 /* 129 * Return EOF for tty devices, EIO for others 130 */ 131 if ((ap->a_vp->v_vflag & VV_ISTTY) == 0) 132 return (EIO); 133 return (0); 134} 135 136/* 137 * Vnode op for write 138 */ 139/* ARGSUSED */ 140static int 141dead_write(ap) 142 struct vop_write_args /* { 143 struct vnode *a_vp; 144 struct uio *a_uio; 145 int a_ioflag; 146 struct ucred *a_cred; 147 } */ *ap; 148{ 149 return (EIO); 150} 151 152/* 153 * Device ioctl operation. 154 */ 155/* ARGSUSED */ 156static int 157dead_ioctl(ap) 158 struct vop_ioctl_args /* { 159 struct vnode *a_vp; 160 u_long a_command; 161 caddr_t a_data; 162 int a_fflag; 163 struct ucred *a_cred; 164 struct proc *a_p; 165 } */ *ap; 166{ 167 /* XXX: Doesn't this just recurse back here ? */ 168 return (VOP_IOCTL_AP(ap)); 169} 170 171/* 172 * Wait until the vnode has finished changing state. 173 */ 174static int 175dead_bmap(ap) 176 struct vop_bmap_args /* { 177 struct vnode *a_vp; 178 daddr_t a_bn; 179 struct bufobj **a_bop; 180 daddr_t *a_bnp; 181 int *a_runp; 182 int *a_runb; 183 } */ *ap; 184{ 185 186 return (VOP_BMAP(ap->a_vp, ap->a_bn, ap->a_bop, ap->a_bnp, ap->a_runp, ap->a_runb)); 187} 188 189/* 190 * Trivial poll routine that always returns POLLHUP. 191 * This is necessary so that a process which is polling a file 192 * gets notified when that file is revoke()d. 193 */ 194static int 195dead_poll(ap) 196 struct vop_poll_args *ap; 197{ 198 return (POLLHUP); 199}
| 95/* 96 * Trivial lookup routine that always fails. 97 */ 98/* ARGSUSED */ 99static int 100dead_lookup(ap) 101 struct vop_lookup_args /* { 102 struct vnode * a_dvp; 103 struct vnode ** a_vpp; 104 struct componentname * a_cnp; 105 } */ *ap; 106{ 107 108 *ap->a_vpp = NULL; 109 return (ENOTDIR); 110} 111 112/* 113 * Open always fails as if device did not exist. 114 */ 115/* ARGSUSED */ 116static int 117dead_open(ap) 118 struct vop_open_args /* { 119 struct vnode *a_vp; 120 int a_mode; 121 struct ucred *a_cred; 122 struct proc *a_p; 123 } */ *ap; 124{ 125 126 return (ENXIO); 127} 128 129/* 130 * Vnode op for read 131 */ 132/* ARGSUSED */ 133static int 134dead_read(ap) 135 struct vop_read_args /* { 136 struct vnode *a_vp; 137 struct uio *a_uio; 138 int a_ioflag; 139 struct ucred *a_cred; 140 } */ *ap; 141{ 142 /* 143 * Return EOF for tty devices, EIO for others 144 */ 145 if ((ap->a_vp->v_vflag & VV_ISTTY) == 0) 146 return (EIO); 147 return (0); 148} 149 150/* 151 * Vnode op for write 152 */ 153/* ARGSUSED */ 154static int 155dead_write(ap) 156 struct vop_write_args /* { 157 struct vnode *a_vp; 158 struct uio *a_uio; 159 int a_ioflag; 160 struct ucred *a_cred; 161 } */ *ap; 162{ 163 return (EIO); 164} 165 166/* 167 * Device ioctl operation. 168 */ 169/* ARGSUSED */ 170static int 171dead_ioctl(ap) 172 struct vop_ioctl_args /* { 173 struct vnode *a_vp; 174 u_long a_command; 175 caddr_t a_data; 176 int a_fflag; 177 struct ucred *a_cred; 178 struct proc *a_p; 179 } */ *ap; 180{ 181 /* XXX: Doesn't this just recurse back here ? */ 182 return (VOP_IOCTL_AP(ap)); 183} 184 185/* 186 * Wait until the vnode has finished changing state. 187 */ 188static int 189dead_bmap(ap) 190 struct vop_bmap_args /* { 191 struct vnode *a_vp; 192 daddr_t a_bn; 193 struct bufobj **a_bop; 194 daddr_t *a_bnp; 195 int *a_runp; 196 int *a_runb; 197 } */ *ap; 198{ 199 200 return (VOP_BMAP(ap->a_vp, ap->a_bn, ap->a_bop, ap->a_bnp, ap->a_runp, ap->a_runb)); 201} 202 203/* 204 * Trivial poll routine that always returns POLLHUP. 205 * This is necessary so that a process which is polling a file 206 * gets notified when that file is revoke()d. 207 */ 208static int 209dead_poll(ap) 210 struct vop_poll_args *ap; 211{ 212 return (POLLHUP); 213}
|