Home | History | Annotate | Line # | Download | only in deadfs
dead_vnops.c revision 1.61.18.1
      1  1.61.18.1        ad /*	$NetBSD: dead_vnops.c,v 1.61.18.1 2020/02/29 20:21:03 ad Exp $	*/
      2        1.9       cgd 
      3        1.1       cgd /*
      4        1.8   mycroft  * Copyright (c) 1989, 1993
      5        1.8   mycroft  *	The Regents of the University of California.  All rights reserved.
      6        1.1       cgd  *
      7        1.1       cgd  * Redistribution and use in source and binary forms, with or without
      8        1.1       cgd  * modification, are permitted provided that the following conditions
      9        1.1       cgd  * are met:
     10        1.1       cgd  * 1. Redistributions of source code must retain the above copyright
     11        1.1       cgd  *    notice, this list of conditions and the following disclaimer.
     12        1.1       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     13        1.1       cgd  *    notice, this list of conditions and the following disclaimer in the
     14        1.1       cgd  *    documentation and/or other materials provided with the distribution.
     15       1.33       agc  * 3. Neither the name of the University nor the names of its contributors
     16        1.1       cgd  *    may be used to endorse or promote products derived from this software
     17        1.1       cgd  *    without specific prior written permission.
     18        1.1       cgd  *
     19        1.1       cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     20        1.1       cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     21        1.1       cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     22        1.1       cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     23        1.1       cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     24        1.1       cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     25        1.1       cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     26        1.1       cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     27        1.1       cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     28        1.1       cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     29        1.1       cgd  * SUCH DAMAGE.
     30        1.1       cgd  *
     31       1.13   mycroft  *	@(#)dead_vnops.c	8.2 (Berkeley) 11/21/94
     32        1.1       cgd  */
     33       1.31     lukem 
     34       1.31     lukem #include <sys/cdefs.h>
     35  1.61.18.1        ad __KERNEL_RCSID(0, "$NetBSD: dead_vnops.c,v 1.61.18.1 2020/02/29 20:21:03 ad Exp $");
     36        1.1       cgd 
     37        1.6   mycroft #include <sys/param.h>
     38        1.6   mycroft #include <sys/systm.h>
     39        1.6   mycroft #include <sys/time.h>
     40        1.6   mycroft #include <sys/vnode.h>
     41        1.6   mycroft #include <sys/errno.h>
     42        1.6   mycroft #include <sys/namei.h>
     43        1.6   mycroft #include <sys/buf.h>
     44       1.14  christos #include <sys/proc.h>
     45        1.1       cgd 
     46       1.17   mycroft #include <miscfs/genfs/genfs.h>
     47       1.17   mycroft 
     48        1.1       cgd /*
     49        1.1       cgd  * Prototypes for dead operations on vnodes.
     50        1.1       cgd  */
     51  1.61.18.1        ad #define	dead_bwrite	vn_bwrite
     52       1.52   hannken int	dead_lookup(void *);
     53       1.36   xtraeme int	dead_open(void *);
     54       1.17   mycroft #define dead_close	genfs_nullop
     55       1.36   xtraeme int	dead_read(void *);
     56       1.36   xtraeme int	dead_write(void *);
     57       1.27  sommerfe #define dead_fcntl	genfs_nullop
     58       1.36   xtraeme int	dead_ioctl(void *);
     59       1.36   xtraeme int	dead_poll(void *);
     60       1.52   hannken int	dead_remove(void *);
     61       1.52   hannken int	dead_link(void *);
     62       1.52   hannken int	dead_rename(void *);
     63       1.52   hannken int	dead_rmdir(void *);
     64       1.17   mycroft #define dead_fsync	genfs_nullop
     65       1.17   mycroft #define dead_seek	genfs_nullop
     66       1.52   hannken int	dead_inactive(void *);
     67       1.17   mycroft #define dead_reclaim	genfs_nullop
     68       1.56   hannken #define dead_lock	genfs_deadlock
     69       1.56   hannken #define dead_unlock	genfs_deadunlock
     70       1.36   xtraeme int	dead_bmap(void *);
     71       1.36   xtraeme int	dead_strategy(void *);
     72       1.36   xtraeme int	dead_print(void *);
     73       1.56   hannken #define dead_islocked	genfs_deadislocked
     74       1.22      fvdl #define dead_revoke	genfs_nullop
     75       1.43     pooka int	dead_getpages(void *);
     76       1.52   hannken int	dead_putpages(void *);
     77       1.14  christos 
     78       1.42       chs int	dead_default_error(void *);
     79       1.14  christos 
     80       1.36   xtraeme int (**dead_vnodeop_p)(void *);
     81        1.8   mycroft 
     82       1.30  jdolecek const struct vnodeopv_entry_desc dead_vnodeop_entries[] = {
     83       1.42       chs 	{ &vop_default_desc, dead_default_error },
     84       1.52   hannken 	{ &vop_bwrite_desc, dead_bwrite },		/* bwrite */
     85       1.52   hannken 	{ &vop_lookup_desc, dead_lookup },		/* lookup */
     86       1.17   mycroft 	{ &vop_open_desc, dead_open },			/* open */
     87       1.17   mycroft 	{ &vop_close_desc, dead_close },		/* close */
     88       1.17   mycroft 	{ &vop_read_desc, dead_read },			/* read */
     89       1.17   mycroft 	{ &vop_write_desc, dead_write },		/* write */
     90       1.57  dholland 	{ &vop_fallocate_desc, genfs_eopnotsupp },	/* fallocate */
     91       1.57  dholland 	{ &vop_fdiscard_desc, genfs_eopnotsupp },	/* fdiscard */
     92       1.25  sommerfe 	{ &vop_fcntl_desc, dead_fcntl },		/* fcntl */
     93       1.17   mycroft 	{ &vop_ioctl_desc, dead_ioctl },		/* ioctl */
     94       1.19   mycroft 	{ &vop_poll_desc, dead_poll },			/* poll */
     95       1.52   hannken 	{ &vop_remove_desc, dead_remove },		/* remove */
     96       1.52   hannken 	{ &vop_link_desc, dead_link },			/* link */
     97       1.52   hannken 	{ &vop_rename_desc, dead_rename },		/* rename */
     98       1.52   hannken 	{ &vop_rmdir_desc, dead_rmdir },		/* rmdir */
     99       1.17   mycroft 	{ &vop_fsync_desc, dead_fsync },		/* fsync */
    100       1.17   mycroft 	{ &vop_seek_desc, dead_seek },			/* seek */
    101       1.17   mycroft 	{ &vop_inactive_desc, dead_inactive },		/* inactive */
    102       1.17   mycroft 	{ &vop_reclaim_desc, dead_reclaim },		/* reclaim */
    103       1.17   mycroft 	{ &vop_lock_desc, dead_lock },			/* lock */
    104       1.17   mycroft 	{ &vop_unlock_desc, dead_unlock },		/* unlock */
    105       1.17   mycroft 	{ &vop_bmap_desc, dead_bmap },			/* bmap */
    106       1.17   mycroft 	{ &vop_strategy_desc, dead_strategy },		/* strategy */
    107       1.17   mycroft 	{ &vop_print_desc, dead_print },		/* print */
    108       1.17   mycroft 	{ &vop_islocked_desc, dead_islocked },		/* islocked */
    109       1.52   hannken 	{ &vop_revoke_desc, dead_revoke },		/* revoke */
    110       1.43     pooka 	{ &vop_getpages_desc, dead_getpages },		/* getpages */
    111       1.32       chs 	{ &vop_putpages_desc, dead_putpages },		/* putpages */
    112       1.32       chs 	{ NULL, NULL }
    113        1.1       cgd };
    114       1.30  jdolecek const struct vnodeopv_desc dead_vnodeop_opv_desc =
    115        1.8   mycroft 	{ &dead_vnodeop_p, dead_vnodeop_entries };
    116        1.1       cgd 
    117       1.52   hannken /* ARGSUSED */
    118        1.3    andrew int
    119       1.42       chs dead_default_error(void *v)
    120       1.14  christos {
    121        1.1       cgd 
    122       1.42       chs 	return EBADF;
    123        1.1       cgd }
    124        1.1       cgd 
    125       1.52   hannken int
    126       1.52   hannken dead_bmap(void *v)
    127       1.52   hannken {
    128       1.59  riastrad 	struct vop_bmap_args /* {
    129       1.52   hannken 		struct vnode *a_vp;
    130       1.52   hannken 		daddr_t  a_bn;
    131       1.52   hannken 		struct vnode **a_vpp;
    132       1.52   hannken 		daddr_t *a_bnp;
    133       1.52   hannken 		int *a_runp;
    134       1.59  riastrad 	} */ *ap = v;
    135       1.59  riastrad 
    136       1.59  riastrad 	(void)ap;
    137       1.52   hannken 
    138       1.52   hannken 	return (EIO);
    139       1.52   hannken }
    140       1.52   hannken 
    141       1.52   hannken int
    142       1.52   hannken dead_lookup(void *v)
    143       1.52   hannken {
    144       1.54   hannken 	struct vop_lookup_v2_args /* {
    145       1.52   hannken 		struct vnode *a_dvp;
    146       1.52   hannken 		struct vnode **a_vpp;
    147       1.52   hannken 		struct componentname *a_cnp;
    148       1.52   hannken 	} */ *ap = v;
    149       1.52   hannken 
    150       1.52   hannken 	*(ap->a_vpp) = NULL;
    151       1.52   hannken 
    152       1.55   hannken 	return ENOENT;
    153       1.52   hannken }
    154       1.52   hannken 
    155       1.14  christos int
    156       1.41  christos dead_open(void *v)
    157        1.1       cgd {
    158       1.59  riastrad 	struct vop_open_args /* {
    159       1.52   hannken 		struct vnode *a_vp;
    160       1.52   hannken 		int a_mode;
    161       1.52   hannken 		kauth_cred_t a_cred;
    162       1.59  riastrad 	} */ *ap = v;
    163       1.59  riastrad 
    164       1.59  riastrad 	(void)ap;
    165        1.1       cgd 
    166        1.1       cgd 	return (ENXIO);
    167        1.1       cgd }
    168        1.1       cgd 
    169       1.14  christos int
    170       1.48       dsl dead_read(void *v)
    171       1.14  christos {
    172        1.8   mycroft 	struct vop_read_args /* {
    173        1.8   mycroft 		struct vnode *a_vp;
    174        1.8   mycroft 		struct uio *a_uio;
    175        1.8   mycroft 		int  a_ioflag;
    176       1.39      elad 		kauth_cred_t a_cred;
    177       1.14  christos 	} */ *ap = v;
    178        1.1       cgd 
    179        1.1       cgd 	/*
    180       1.13   mycroft 	 * Return EOF for tty devices, EIO for others
    181        1.1       cgd 	 */
    182       1.45        ad 	if ((ap->a_vp->v_vflag & VV_ISTTY) == 0)
    183        1.1       cgd 		return (EIO);
    184        1.1       cgd 	return (0);
    185        1.1       cgd }
    186        1.1       cgd 
    187       1.14  christos int
    188       1.48       dsl dead_write(void *v)
    189       1.14  christos {
    190       1.59  riastrad 	struct vop_write_args /* {
    191        1.8   mycroft 		struct vnode *a_vp;
    192        1.8   mycroft 		struct uio *a_uio;
    193        1.8   mycroft 		int  a_ioflag;
    194       1.39      elad 		kauth_cred_t a_cred;
    195       1.59  riastrad 	} */ *ap = v;
    196       1.59  riastrad 
    197       1.59  riastrad 	(void)ap;
    198        1.1       cgd 
    199        1.1       cgd 	return (EIO);
    200        1.1       cgd }
    201        1.1       cgd 
    202       1.14  christos int
    203       1.48       dsl dead_ioctl(void *v)
    204       1.14  christos {
    205       1.59  riastrad 	struct vop_ioctl_args /* {
    206        1.8   mycroft 		struct vnode *a_vp;
    207       1.10       cgd 		u_long a_command;
    208       1.35       jrf 		void *a_data;
    209        1.8   mycroft 		int  a_fflag;
    210       1.39      elad 		kauth_cred_t a_cred;
    211       1.38  christos 		struct lwp *a_l;
    212       1.59  riastrad 	} */ *ap = v;
    213       1.59  riastrad 
    214       1.59  riastrad 	(void)ap;
    215        1.1       cgd 
    216       1.52   hannken 	return (EBADF);
    217        1.1       cgd }
    218        1.1       cgd 
    219       1.14  christos int
    220       1.48       dsl dead_poll(void *v)
    221        1.1       cgd {
    222       1.19   mycroft 	struct vop_poll_args /* {
    223       1.17   mycroft 		struct vnode *a_vp;
    224       1.19   mycroft 		int a_events;
    225       1.38  christos 		struct lwp *a_l;
    226       1.17   mycroft 	} */ *ap = v;
    227       1.17   mycroft 
    228        1.1       cgd 	/*
    229        1.1       cgd 	 * Let the user find out that the descriptor is gone.
    230        1.1       cgd 	 */
    231       1.19   mycroft 	return (ap->a_events);
    232        1.1       cgd }
    233        1.1       cgd 
    234       1.14  christos int
    235       1.52   hannken dead_remove(void *v)
    236       1.52   hannken {
    237       1.61  riastrad 	struct vop_remove_v2_args /* {
    238       1.52   hannken 		struct vnode *a_dvp;
    239       1.52   hannken 		struct vnode *a_vp;
    240       1.52   hannken 		struct componentname *a_cnp;
    241       1.52   hannken 	} */ *ap = v;
    242       1.52   hannken 
    243       1.52   hannken 	vput(ap->a_vp);
    244       1.52   hannken 
    245       1.52   hannken 	return EIO;
    246       1.52   hannken }
    247       1.52   hannken 
    248       1.52   hannken int
    249       1.52   hannken dead_link(void *v)
    250       1.52   hannken {
    251       1.58  riastrad 	struct vop_link_v2_args /* {
    252       1.52   hannken 		struct vnode *a_dvp;
    253       1.52   hannken 		struct vnode *a_vp;
    254       1.52   hannken 		struct componentname *a_cnp;
    255       1.52   hannken 	} */ *ap = v;
    256       1.52   hannken 
    257       1.58  riastrad 	(void)ap;
    258       1.52   hannken 
    259       1.52   hannken 	return EIO;
    260       1.52   hannken }
    261       1.52   hannken 
    262       1.52   hannken int
    263       1.52   hannken dead_rename(void *v)
    264       1.52   hannken {
    265       1.52   hannken 	struct vop_rename_args /* {
    266       1.52   hannken 		struct vnode *a_fdvp;
    267       1.52   hannken 		struct vnode *a_fvp;
    268       1.52   hannken 		struct componentname *a_fcnp;
    269       1.52   hannken 		struct vnode *a_tdvp;
    270       1.52   hannken 		struct vnode *a_tvp;
    271       1.52   hannken 		struct componentname *a_tcnp;
    272       1.52   hannken 	} */ *ap = v;
    273       1.52   hannken 
    274       1.52   hannken 	vrele(ap->a_fdvp);
    275       1.52   hannken 	vrele(ap->a_fvp);
    276       1.52   hannken 	if (ap->a_tvp != NULL && ap->a_tvp != ap->a_tdvp)
    277       1.52   hannken 		VOP_UNLOCK(ap->a_tvp);
    278       1.52   hannken 	vput(ap->a_tdvp);
    279       1.52   hannken 	if (ap->a_tvp != NULL)
    280       1.52   hannken 		vrele(ap->a_tvp);
    281       1.52   hannken 
    282       1.52   hannken 	return EIO;
    283       1.52   hannken }
    284       1.52   hannken 
    285       1.52   hannken int
    286       1.52   hannken dead_rmdir(void *v)
    287       1.52   hannken {
    288       1.61  riastrad 	struct vop_rmdir_v2_args /* {
    289       1.52   hannken 		struct vnode *a_dvp;
    290       1.34   hannken 		struct vnode *a_vp;
    291       1.52   hannken 		struct componentname *a_cnp;
    292       1.52   hannken 	} */ *ap = v;
    293       1.52   hannken 
    294       1.52   hannken 	vput(ap->a_vp);
    295       1.52   hannken 
    296       1.52   hannken 	return EIO;
    297       1.52   hannken }
    298       1.52   hannken 
    299       1.52   hannken int
    300       1.52   hannken dead_inactive(void *v)
    301       1.14  christos {
    302       1.60  riastrad 	struct vop_inactive_v2_args /* {
    303        1.8   mycroft 		struct vnode *a_vp;
    304       1.52   hannken 		bool *a_recycle;
    305       1.14  christos 	} */ *ap = v;
    306        1.1       cgd 
    307       1.52   hannken 	*ap->a_recycle = false;
    308       1.52   hannken 
    309       1.52   hannken 	return 0;
    310        1.1       cgd }
    311        1.1       cgd 
    312       1.14  christos int
    313       1.52   hannken dead_strategy(void *v)
    314       1.14  christos {
    315       1.52   hannken 	struct vop_strategy_args /* {
    316        1.8   mycroft 		struct vnode *a_vp;
    317       1.52   hannken 		struct buf *a_bp;
    318       1.14  christos 	} */ *ap = v;
    319       1.52   hannken 	struct buf *bp;
    320        1.1       cgd 
    321       1.52   hannken 	bp = ap->a_bp;
    322       1.52   hannken 	bp->b_error = EIO;
    323       1.52   hannken 	bp->b_resid = bp->b_bcount;
    324       1.52   hannken 	biodone(ap->a_bp);
    325       1.52   hannken 	return (EIO);
    326        1.1       cgd }
    327        1.1       cgd 
    328        1.1       cgd /* ARGSUSED */
    329       1.14  christos int
    330       1.41  christos dead_print(void *v)
    331        1.1       cgd {
    332       1.21  christos 	printf("tag VT_NON, dead vnode\n");
    333       1.14  christos 	return 0;
    334        1.1       cgd }
    335        1.1       cgd 
    336       1.43     pooka int
    337       1.43     pooka dead_getpages(void *v)
    338       1.43     pooka {
    339       1.43     pooka 	struct vop_getpages_args /* {
    340       1.43     pooka 		struct vnode *a_vp;
    341       1.43     pooka 		voff_t a_offset;
    342       1.43     pooka 		struct vm_page **a_m;
    343       1.43     pooka 		int *a_count;
    344       1.43     pooka 		int a_centeridx;
    345       1.43     pooka 		vm_prot_t a_access_type;
    346       1.43     pooka 		int a_advice;
    347       1.43     pooka 		int a_flags;
    348       1.43     pooka 	} */ *ap = v;
    349       1.43     pooka 
    350       1.43     pooka 	if ((ap->a_flags & PGO_LOCKED) == 0)
    351  1.61.18.1        ad 		rw_exit(ap->a_vp->v_uobj.vmobjlock);
    352       1.43     pooka 
    353       1.43     pooka 	return (EFAULT);
    354       1.43     pooka }
    355       1.43     pooka 
    356       1.14  christos int
    357       1.52   hannken dead_putpages(void *v)
    358        1.1       cgd {
    359       1.52   hannken         struct vop_putpages_args /* {
    360       1.59  riastrad 		struct vnode *a_vp;
    361       1.52   hannken 		voff_t a_offlo;
    362       1.52   hannken 		voff_t a_offhi;
    363       1.52   hannken 		int a_flags;
    364       1.52   hannken 	} */ *ap = v;
    365        1.1       cgd 
    366  1.61.18.1        ad 	rw_exit(ap->a_vp->v_uobj.vmobjlock);
    367       1.52   hannken 	return (EFAULT);
    368        1.1       cgd }
    369