/*-1* SPDX-License-Identifier: BSD-3-Clause2*3* Copyright (c) 1989, 19934* The Regents of the University of California. All rights reserved.5*6* Redistribution and use in source and binary forms, with or without7* modification, are permitted provided that the following conditions8* are met:9* 1. Redistributions of source code must retain the above copyright10* notice, this list of conditions and the following disclaimer.11* 2. Redistributions in binary form must reproduce the above copyright12* notice, this list of conditions and the following disclaimer in the13* documentation and/or other materials provided with the distribution.14* 3. Neither the name of the University nor the names of its contributors15* may be used to endorse or promote products derived from this software16* without specific prior written permission.17*18* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND19* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE20* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE21* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE22* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL23* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS24* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)25* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT26* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY27* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF28* SUCH DAMAGE.29*/3031#include <sys/param.h>32#include <sys/systm.h>33#include <sys/kernel.h>34#include <sys/lock.h>35#include <sys/mutex.h>36#include <sys/poll.h>37#include <sys/vnode.h>3839/*40* Prototypes for dead operations on vnodes.41*/42static vop_lookup_t dead_lookup;43static vop_open_t dead_open;44static vop_close_t dead_close;45static vop_getwritemount_t dead_getwritemount;46static vop_rename_t dead_rename;47static vop_unset_text_t dead_unset_text;4849struct vop_vector dead_vnodeops = {50.vop_default = &default_vnodeops,5152.vop_access = VOP_EBADF,53.vop_advlock = VOP_EBADF,54.vop_bmap = VOP_EBADF,55.vop_close = dead_close,56.vop_create = VOP_PANIC,57.vop_getattr = VOP_EBADF,58.vop_getwritemount = dead_getwritemount,59.vop_inactive = VOP_NULL,60.vop_ioctl = VOP_EBADF,61.vop_link = VOP_PANIC,62.vop_lookup = dead_lookup,63.vop_mkdir = VOP_PANIC,64.vop_mknod = VOP_PANIC,65.vop_open = dead_open,66.vop_pathconf = VOP_EBADF, /* per pathconf(2) */67.vop_poll = dead_poll,68.vop_read = dead_read,69.vop_readdir = VOP_EBADF,70.vop_readlink = VOP_EBADF,71.vop_reclaim = VOP_NULL,72.vop_remove = VOP_PANIC,73.vop_rename = dead_rename,74.vop_rmdir = VOP_PANIC,75.vop_setattr = VOP_EBADF,76.vop_symlink = VOP_PANIC,77.vop_vptocnp = VOP_EBADF,78.vop_unset_text = dead_unset_text,79.vop_write = dead_write,80.vop_fplookup_vexec = VOP_EOPNOTSUPP,81.vop_fplookup_symlink = VOP_EOPNOTSUPP,82};83VFS_VOP_VECTOR_REGISTER(dead_vnodeops);8485static int86dead_getwritemount(struct vop_getwritemount_args *ap)87{8889*(ap->a_mpp) = NULL;90return (0);91}9293/*94* Trivial lookup routine that always fails.95*/96static int97dead_lookup(struct vop_lookup_args *ap)98{99100*ap->a_vpp = NULL;101return (ENOTDIR);102}103104/*105* Silently succeed open and close.106*/107static int108dead_open(struct vop_open_args *ap)109{110return (0);111}112113static int114dead_close(struct vop_close_args *ap)115{116return (0);117}118119int120dead_read(struct vop_read_args *ap)121{122123/*124* Return EOF for tty devices, EIO for others125*/126if ((ap->a_vp->v_vflag & VV_ISTTY) == 0)127return (EIO);128return (0);129}130131int132dead_write(struct vop_write_args *ap)133{134135return (EIO);136}137138int139dead_poll(struct vop_poll_args *ap)140{141142if (ap->a_events & ~POLLSTANDARD)143return (POLLNVAL);144145/*146* Let the user find out that the descriptor is gone.147*/148return (POLLHUP | ((POLLIN | POLLRDNORM) & ap->a_events));149150}151152static int153dead_rename(struct vop_rename_args *ap)154{155156vop_rename_fail(ap);157return (EXDEV);158}159160static int161dead_unset_text(struct vop_unset_text_args *ap)162{163164return (0);165}166167168