kernel - Tear out vfs polling
[dragonfly.git] / sys / vfs / deadfs / dead_vnops.c
CommitLineData
984263bc
MD
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 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)dead_vnops.c 8.1 (Berkeley) 6/10/93
34 * $FreeBSD: src/sys/miscfs/deadfs/dead_vnops.c,v 1.26 1999/08/28 00:46:42 peter Exp $
08daea96 35 * $DragonFly: src/sys/vfs/deadfs/dead_vnops.c,v 1.20 2007/08/13 17:31:56 dillon Exp $
984263bc
MD
36 */
37
38#include <sys/param.h>
39#include <sys/systm.h>
40#include <sys/kernel.h>
41#include <sys/lock.h>
42#include <sys/vnode.h>
8ddc6004 43#include <sys/fcntl.h>
984263bc 44#include <sys/buf.h>
984263bc 45
984263bc
MD
46/*
47 * Prototypes for dead operations on vnodes.
48 */
a6ee311a
RG
49static int dead_badop (void);
50static int dead_bmap (struct vop_bmap_args *);
51static int dead_ioctl (struct vop_ioctl_args *);
e62afb5f 52static int dead_lookup (struct vop_old_lookup_args *);
a6ee311a 53static int dead_open (struct vop_open_args *);
8ddc6004 54static int dead_close (struct vop_close_args *);
a6ee311a
RG
55static int dead_print (struct vop_print_args *);
56static int dead_read (struct vop_read_args *);
57static int dead_write (struct vop_write_args *);
984263bc 58
66a1ddf5
MD
59struct vop_ops dead_vnode_vops = {
60 .vop_default = vop_defaultop,
61 .vop_access = (void *)vop_ebadf,
62 .vop_advlock = (void *)vop_ebadf,
63 .vop_bmap = dead_bmap,
64 .vop_old_create = (void *)dead_badop,
65 .vop_getattr = (void *)vop_ebadf,
66 .vop_inactive = (void *)vop_null,
67 .vop_ioctl = dead_ioctl,
68 .vop_old_link = (void *)dead_badop,
69 .vop_old_lookup = dead_lookup,
70 .vop_old_mkdir = (void *)dead_badop,
71 .vop_old_mknod = (void *)dead_badop,
72 .vop_mmap = (void *)dead_badop,
73 .vop_open = dead_open,
74 .vop_close = dead_close,
75 .vop_pathconf = (void *)vop_ebadf, /* per pathconf(2) */
66a1ddf5
MD
76 .vop_print = dead_print,
77 .vop_read = dead_read,
78 .vop_readdir = (void *)vop_ebadf,
79 .vop_readlink = (void *)vop_ebadf,
80 .vop_reclaim = (void *)vop_null,
81 .vop_old_remove = (void *)dead_badop,
82 .vop_old_rename = (void *)dead_badop,
83 .vop_old_rmdir = (void *)dead_badop,
84 .vop_setattr = (void *)vop_ebadf,
85 .vop_old_symlink = (void *)dead_badop,
86 .vop_write = dead_write
984263bc 87};
984263bc 88
66a1ddf5
MD
89struct vop_ops *dead_vnode_vops_p = &dead_vnode_vops;
90
91VNODEOP_SET(dead_vnode_vops);
984263bc
MD
92
93/*
94 * Trivial lookup routine that always fails.
a7918111
CP
95 *
96 * dead_lookup(struct vnode *a_dvp, struct vnode **a_vpp,
97 * struct componentname *a_cnp)
984263bc
MD
98 */
99/* ARGSUSED */
100static int
e62afb5f 101dead_lookup(struct vop_old_lookup_args *ap)
984263bc 102{
984263bc
MD
103 *ap->a_vpp = NULL;
104 return (ENOTDIR);
105}
106
107/*
108 * Open always fails as if device did not exist.
a7918111
CP
109 *
110 * dead_open(struct vnode *a_vp, int a_mode, struct ucred *a_cred,
111 * struct proc *a_p)
984263bc
MD
112 */
113/* ARGSUSED */
114static int
a7918111 115dead_open(struct vop_open_args *ap)
984263bc 116{
984263bc
MD
117 return (ENXIO);
118}
119
8ddc6004
MD
120/*
121 * Close always succeeds, and does not warn or panic if v_opencount or
122 * v_writecount is incorrect, because a forced unmount or revocation
123 * might have closed the file out from under the descriptor.
124 */
125static int
126dead_close(struct vop_close_args *ap)
127{
128 struct vnode *vp = ap->a_vp;
129
130 if (vp->v_opencount > 0) {
131 if ((ap->a_fflag & FWRITE) && vp->v_writecount > 0)
132 --vp->v_writecount;
133 --vp->v_opencount;
134 }
135 return (0);
136}
137
984263bc
MD
138/*
139 * Vnode op for read
a7918111
CP
140 *
141 * dead_read(struct vnode *a_vp, struct uio *a_uio, int a_ioflag,
142 * struct ucred *a_cred)
984263bc
MD
143 */
144/* ARGSUSED */
145static int
a7918111 146dead_read(struct vop_read_args *ap)
984263bc 147{
984263bc
MD
148 /*
149 * Return EOF for tty devices, EIO for others
150 */
151 if ((ap->a_vp->v_flag & VISTTY) == 0)
152 return (EIO);
153 return (0);
154}
155
156/*
157 * Vnode op for write
a7918111
CP
158 *
159 * dead_write(struct vnode *a_vp, struct uio *a_uio, int a_ioflag,
160 * struct ucred *a_cred)
984263bc
MD
161 */
162/* ARGSUSED */
163static int
a7918111 164dead_write(struct vop_write_args *ap)
984263bc 165{
984263bc
MD
166 return (EIO);
167}
168
169/*
170 * Device ioctl operation.
a7918111
CP
171 *
172 * dead_ioctl(struct vnode *a_vp, int a_command, caddr_t a_data, int a_fflag,
173 * struct ucred *a_cred, struct proc *a_p)
984263bc
MD
174 */
175/* ARGSUSED */
176static int
a7918111 177dead_ioctl(struct vop_ioctl_args *ap)
984263bc 178{
5fd012e0 179 return (ENOTTY);
984263bc
MD
180}
181
984263bc
MD
182/*
183 * Wait until the vnode has finished changing state.
a7918111 184 *
08daea96 185 * dead_bmap(struct vnode *a_vp, off_t a_loffset,
54078292 186 * off_t *a_doffsetp, int *a_runp, int *a_runb)
984263bc
MD
187 */
188static int
a7918111 189dead_bmap(struct vop_bmap_args *ap)
984263bc 190{
5fd012e0 191 return (EIO);
984263bc
MD
192}
193
194/*
195 * Print out the contents of a dead vnode.
a7918111
CP
196 *
197 * dead_print(struct vnode *a_vp)
984263bc
MD
198 */
199/* ARGSUSED */
200static int
a7918111 201dead_print(struct vop_print_args *ap)
984263bc 202{
086c1d7e 203 kprintf("tag VT_NON, dead vnode\n");
984263bc
MD
204 return (0);
205}
206
207/*
208 * Empty vnode bad operation
209 */
210static int
a7918111 211dead_badop(void)
984263bc 212{
984263bc
MD
213 panic("dead_badop called");
214 /* NOTREACHED */
215}