Home | History | Annotate | Line # | Download | only in deadfs
dead_vnops.c revision 1.51.12.1
      1       1.51     rmind /*	$NetBSD: dead_vnops.c,v 1.51.12.1 2014/08/20 00:04:30 tls 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.51     rmind __KERNEL_RCSID(0, "$NetBSD: dead_vnops.c,v 1.51.12.1 2014/08/20 00:04:30 tls 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.51.12.1       tls #define dead_bwrite	genfs_nullop
     52  1.51.12.1       tls 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.51.12.1       tls int	dead_remove(void *);
     61  1.51.12.1       tls int	dead_link(void *);
     62  1.51.12.1       tls int	dead_rename(void *);
     63  1.51.12.1       tls int	dead_rmdir(void *);
     64       1.17   mycroft #define dead_fsync	genfs_nullop
     65       1.17   mycroft #define dead_seek	genfs_nullop
     66  1.51.12.1       tls int	dead_inactive(void *);
     67       1.17   mycroft #define dead_reclaim	genfs_nullop
     68  1.51.12.1       tls #define dead_lock	genfs_deadlock
     69  1.51.12.1       tls #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.51.12.1       tls #define dead_islocked	genfs_deadislocked
     74       1.22      fvdl #define dead_revoke	genfs_nullop
     75       1.43     pooka int	dead_getpages(void *);
     76  1.51.12.1       tls 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.51.12.1       tls 	{ &vop_bwrite_desc, dead_bwrite },		/* bwrite */
     85  1.51.12.1       tls 	{ &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.51.12.1       tls 	{ &vop_fallocate_desc, genfs_eopnotsupp },	/* fallocate */
     91  1.51.12.1       tls 	{ &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.51.12.1       tls 	{ &vop_remove_desc, dead_remove },		/* remove */
     96  1.51.12.1       tls 	{ &vop_link_desc, dead_link },			/* link */
     97  1.51.12.1       tls 	{ &vop_rename_desc, dead_rename },		/* rename */
     98  1.51.12.1       tls 	{ &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.51.12.1       tls 	{ &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.51.12.1       tls /* 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.51.12.1       tls /* ARGSUSED */
    126  1.51.12.1       tls int
    127  1.51.12.1       tls dead_bmap(void *v)
    128  1.51.12.1       tls {
    129  1.51.12.1       tls 	/* struct vop_bmap_args {
    130  1.51.12.1       tls 		struct vnode *a_vp;
    131  1.51.12.1       tls 		daddr_t  a_bn;
    132  1.51.12.1       tls 		struct vnode **a_vpp;
    133  1.51.12.1       tls 		daddr_t *a_bnp;
    134  1.51.12.1       tls 		int *a_runp;
    135  1.51.12.1       tls 	} *ap = v; */
    136  1.51.12.1       tls 
    137  1.51.12.1       tls 	return (EIO);
    138  1.51.12.1       tls }
    139  1.51.12.1       tls 
    140  1.51.12.1       tls int
    141  1.51.12.1       tls dead_lookup(void *v)
    142  1.51.12.1       tls {
    143  1.51.12.1       tls 	struct vop_lookup_v2_args /* {
    144  1.51.12.1       tls 		struct vnode *a_dvp;
    145  1.51.12.1       tls 		struct vnode **a_vpp;
    146  1.51.12.1       tls 		struct componentname *a_cnp;
    147  1.51.12.1       tls 	} */ *ap = v;
    148  1.51.12.1       tls 
    149  1.51.12.1       tls 	*(ap->a_vpp) = NULL;
    150  1.51.12.1       tls 
    151  1.51.12.1       tls 	return ENOENT;
    152  1.51.12.1       tls }
    153  1.51.12.1       tls 
    154        1.1       cgd /* ARGSUSED */
    155       1.14  christos int
    156       1.41  christos dead_open(void *v)
    157        1.1       cgd {
    158  1.51.12.1       tls 	/* struct vop_open_args {
    159  1.51.12.1       tls 		struct vnode *a_vp;
    160  1.51.12.1       tls 		int a_mode;
    161  1.51.12.1       tls 		kauth_cred_t a_cred;
    162  1.51.12.1       tls 	} *ap = v; */
    163        1.1       cgd 
    164        1.1       cgd 	return (ENXIO);
    165        1.1       cgd }
    166        1.1       cgd 
    167       1.14  christos int
    168       1.48       dsl dead_read(void *v)
    169       1.14  christos {
    170        1.8   mycroft 	struct vop_read_args /* {
    171        1.8   mycroft 		struct vnode *a_vp;
    172        1.8   mycroft 		struct uio *a_uio;
    173        1.8   mycroft 		int  a_ioflag;
    174       1.39      elad 		kauth_cred_t a_cred;
    175       1.14  christos 	} */ *ap = v;
    176        1.1       cgd 
    177        1.1       cgd 	/*
    178       1.13   mycroft 	 * Return EOF for tty devices, EIO for others
    179        1.1       cgd 	 */
    180       1.45        ad 	if ((ap->a_vp->v_vflag & VV_ISTTY) == 0)
    181        1.1       cgd 		return (EIO);
    182        1.1       cgd 	return (0);
    183        1.1       cgd }
    184        1.1       cgd 
    185        1.1       cgd /* ARGSUSED */
    186       1.14  christos int
    187       1.48       dsl dead_write(void *v)
    188       1.14  christos {
    189  1.51.12.1       tls 	/* struct vop_write_args {
    190        1.8   mycroft 		struct vnode *a_vp;
    191        1.8   mycroft 		struct uio *a_uio;
    192        1.8   mycroft 		int  a_ioflag;
    193       1.39      elad 		kauth_cred_t a_cred;
    194  1.51.12.1       tls 	} *ap = v; */
    195        1.1       cgd 
    196        1.1       cgd 	return (EIO);
    197        1.1       cgd }
    198        1.1       cgd 
    199        1.1       cgd /* ARGSUSED */
    200       1.14  christos int
    201       1.48       dsl dead_ioctl(void *v)
    202       1.14  christos {
    203  1.51.12.1       tls 	/* struct vop_ioctl_args {
    204        1.8   mycroft 		struct vnode *a_vp;
    205       1.10       cgd 		u_long a_command;
    206       1.35       jrf 		void *a_data;
    207        1.8   mycroft 		int  a_fflag;
    208       1.39      elad 		kauth_cred_t a_cred;
    209       1.38  christos 		struct lwp *a_l;
    210  1.51.12.1       tls 	} *ap = v; */
    211        1.1       cgd 
    212  1.51.12.1       tls 	return (EBADF);
    213        1.1       cgd }
    214        1.1       cgd 
    215       1.14  christos int
    216       1.48       dsl dead_poll(void *v)
    217        1.1       cgd {
    218       1.19   mycroft 	struct vop_poll_args /* {
    219       1.17   mycroft 		struct vnode *a_vp;
    220       1.19   mycroft 		int a_events;
    221       1.38  christos 		struct lwp *a_l;
    222       1.17   mycroft 	} */ *ap = v;
    223       1.17   mycroft 
    224        1.1       cgd 	/*
    225        1.1       cgd 	 * Let the user find out that the descriptor is gone.
    226        1.1       cgd 	 */
    227       1.19   mycroft 	return (ap->a_events);
    228        1.1       cgd }
    229        1.1       cgd 
    230       1.14  christos int
    231  1.51.12.1       tls dead_remove(void *v)
    232       1.14  christos {
    233  1.51.12.1       tls 	struct vop_remove_args /* {
    234  1.51.12.1       tls 		struct vnode *a_dvp;
    235  1.51.12.1       tls 		struct vnode *a_vp;
    236  1.51.12.1       tls 		struct componentname *a_cnp;
    237  1.51.12.1       tls 	} */ *ap = v;
    238       1.14  christos 
    239  1.51.12.1       tls 	vput(ap->a_dvp);
    240  1.51.12.1       tls 	vput(ap->a_vp);
    241  1.51.12.1       tls 
    242  1.51.12.1       tls 	return EIO;
    243  1.51.12.1       tls }
    244  1.51.12.1       tls 
    245  1.51.12.1       tls int
    246  1.51.12.1       tls dead_link(void *v)
    247  1.51.12.1       tls {
    248  1.51.12.1       tls 	struct vop_link_args /* {
    249  1.51.12.1       tls 		struct vnode *a_dvp;
    250       1.34   hannken 		struct vnode *a_vp;
    251  1.51.12.1       tls 		struct componentname *a_cnp;
    252       1.14  christos 	} */ *ap = v;
    253  1.51.12.1       tls 
    254  1.51.12.1       tls 	vput(ap->a_dvp);
    255  1.51.12.1       tls 
    256  1.51.12.1       tls 	return EIO;
    257        1.1       cgd }
    258        1.1       cgd 
    259       1.14  christos int
    260  1.51.12.1       tls dead_rename(void *v)
    261       1.14  christos {
    262  1.51.12.1       tls 	struct vop_rename_args /* {
    263  1.51.12.1       tls 		struct vnode *a_fdvp;
    264  1.51.12.1       tls 		struct vnode *a_fvp;
    265  1.51.12.1       tls 		struct componentname *a_fcnp;
    266  1.51.12.1       tls 		struct vnode *a_tdvp;
    267  1.51.12.1       tls 		struct vnode *a_tvp;
    268  1.51.12.1       tls 		struct componentname *a_tcnp;
    269  1.51.12.1       tls 	} */ *ap = v;
    270  1.51.12.1       tls 
    271  1.51.12.1       tls 	vrele(ap->a_fdvp);
    272  1.51.12.1       tls 	vrele(ap->a_fvp);
    273  1.51.12.1       tls 	if (ap->a_tvp != NULL && ap->a_tvp != ap->a_tdvp)
    274  1.51.12.1       tls 		VOP_UNLOCK(ap->a_tvp);
    275  1.51.12.1       tls 	vput(ap->a_tdvp);
    276  1.51.12.1       tls 	if (ap->a_tvp != NULL)
    277  1.51.12.1       tls 		vrele(ap->a_tvp);
    278  1.51.12.1       tls 
    279  1.51.12.1       tls 	return EIO;
    280  1.51.12.1       tls }
    281  1.51.12.1       tls 
    282  1.51.12.1       tls int
    283  1.51.12.1       tls dead_rmdir(void *v)
    284  1.51.12.1       tls {
    285  1.51.12.1       tls 	struct vop_rmdir_args /* {
    286  1.51.12.1       tls 		struct vnode *a_dvp;
    287        1.8   mycroft 		struct vnode *a_vp;
    288  1.51.12.1       tls 		struct componentname *a_cnp;
    289       1.14  christos 	} */ *ap = v;
    290        1.1       cgd 
    291  1.51.12.1       tls 	vput(ap->a_dvp);
    292  1.51.12.1       tls 	vput(ap->a_vp);
    293  1.51.12.1       tls 
    294  1.51.12.1       tls 	return EIO;
    295        1.1       cgd }
    296        1.1       cgd 
    297       1.14  christos int
    298  1.51.12.1       tls dead_inactive(void *v)
    299       1.14  christos {
    300  1.51.12.1       tls 	struct vop_inactive_args /* {
    301        1.8   mycroft 		struct vnode *a_vp;
    302  1.51.12.1       tls 		bool *a_recycle;
    303       1.14  christos 	} */ *ap = v;
    304        1.1       cgd 
    305  1.51.12.1       tls 	*ap->a_recycle = false;
    306  1.51.12.1       tls 	VOP_UNLOCK(ap->a_vp);
    307  1.51.12.1       tls 
    308  1.51.12.1       tls 	return 0;
    309  1.51.12.1       tls }
    310  1.51.12.1       tls 
    311  1.51.12.1       tls int
    312  1.51.12.1       tls dead_strategy(void *v)
    313  1.51.12.1       tls {
    314  1.51.12.1       tls 	struct vop_strategy_args /* {
    315  1.51.12.1       tls 		struct vnode *a_vp;
    316  1.51.12.1       tls 		struct buf *a_bp;
    317  1.51.12.1       tls 	} */ *ap = v;
    318  1.51.12.1       tls 	struct buf *bp;
    319  1.51.12.1       tls 
    320  1.51.12.1       tls 	bp = ap->a_bp;
    321  1.51.12.1       tls 	bp->b_error = EIO;
    322  1.51.12.1       tls 	bp->b_resid = bp->b_bcount;
    323  1.51.12.1       tls 	biodone(ap->a_bp);
    324  1.51.12.1       tls 	return (EIO);
    325        1.1       cgd }
    326        1.1       cgd 
    327        1.1       cgd /* ARGSUSED */
    328       1.14  christos int
    329       1.41  christos dead_print(void *v)
    330        1.1       cgd {
    331       1.21  christos 	printf("tag VT_NON, dead vnode\n");
    332       1.14  christos 	return 0;
    333        1.1       cgd }
    334        1.1       cgd 
    335       1.43     pooka int
    336       1.43     pooka dead_getpages(void *v)
    337       1.43     pooka {
    338       1.43     pooka 	struct vop_getpages_args /* {
    339       1.43     pooka 		struct vnode *a_vp;
    340       1.43     pooka 		voff_t a_offset;
    341       1.43     pooka 		struct vm_page **a_m;
    342       1.43     pooka 		int *a_count;
    343       1.43     pooka 		int a_centeridx;
    344       1.43     pooka 		vm_prot_t a_access_type;
    345       1.43     pooka 		int a_advice;
    346       1.43     pooka 		int a_flags;
    347       1.43     pooka 	} */ *ap = v;
    348       1.43     pooka 
    349       1.43     pooka 	if ((ap->a_flags & PGO_LOCKED) == 0)
    350       1.51     rmind 		mutex_exit(ap->a_vp->v_interlock);
    351       1.43     pooka 
    352       1.43     pooka 	return (EFAULT);
    353       1.43     pooka }
    354       1.43     pooka 
    355  1.51.12.1       tls int
    356  1.51.12.1       tls dead_putpages(void *v)
    357  1.51.12.1       tls {
    358  1.51.12.1       tls         struct vop_putpages_args /* {
    359  1.51.12.1       tls 	struct vnode *a_vp;
    360  1.51.12.1       tls 		voff_t a_offlo;
    361  1.51.12.1       tls 		voff_t a_offhi;
    362  1.51.12.1       tls 		int a_flags;
    363  1.51.12.1       tls 	} */ *ap = v;
    364       1.45        ad 
    365  1.51.12.1       tls 	mutex_exit(ap->a_vp->v_interlock);
    366  1.51.12.1       tls 	return (EFAULT);
    367        1.1       cgd }
    368