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 * $Id: dead_vnops.c,v 1.15 1997/09/14 02:57:46 peter Exp $
35 */
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/kernel.h>
40#include <sys/vnode.h>
41#include <sys/buf.h>
42
43static int chkvnlock __P((struct vnode *));
44/*
45 * Prototypes for dead operations on vnodes.
46 */
47static int dead_badop __P((void));
48static int dead_ebadf __P((void));
49static int dead_lookup __P((struct vop_lookup_args *));
50#define dead_create ((int (*) __P((struct vop_create_args *)))dead_badop)
51#define dead_mknod ((int (*) __P((struct vop_mknod_args *)))dead_badop)
52static int dead_open __P((struct vop_open_args *));
53#define dead_close ((int (*) __P((struct vop_close_args *)))nullop)
54#define dead_access ((int (*) __P((struct vop_access_args *)))dead_ebadf)
55#define dead_getattr ((int (*) __P((struct vop_getattr_args *)))dead_ebadf)
56#define dead_setattr ((int (*) __P((struct vop_setattr_args *)))dead_ebadf)
57static int dead_read __P((struct vop_read_args *));
58static int dead_write __P((struct vop_write_args *));
59static int dead_ioctl __P((struct vop_ioctl_args *));
60#define dead_poll vop_nopoll
61#define dead_mmap ((int (*) __P((struct vop_mmap_args *)))dead_badop)
62#define dead_fsync ((int (*) __P((struct vop_fsync_args *)))nullop)
63#define dead_seek ((int (*) __P((struct vop_seek_args *)))nullop)
64#define dead_remove ((int (*) __P((struct vop_remove_args *)))dead_badop)
65#define dead_link ((int (*) __P((struct vop_link_args *)))dead_badop)
66#define dead_rename ((int (*) __P((struct vop_rename_args *)))dead_badop)
67#define dead_mkdir ((int (*) __P((struct vop_mkdir_args *)))dead_badop)
68#define dead_rmdir ((int (*) __P((struct vop_rmdir_args *)))dead_badop)
69#define dead_symlink ((int (*) __P((struct vop_symlink_args *)))dead_badop)
70#define dead_readdir ((int (*) __P((struct vop_readdir_args *)))dead_ebadf)
71#define dead_readlink ((int (*) __P((struct vop_readlink_args *)))dead_ebadf)
72#define dead_abortop ((int (*) __P((struct vop_abortop_args *)))dead_badop)
73#define dead_inactive ((int (*) __P((struct vop_inactive_args *)))nullop)
74#define dead_reclaim ((int (*) __P((struct vop_reclaim_args *)))nullop)
75static int dead_lock __P((struct vop_lock_args *));
76#define dead_unlock ((int (*) __P((struct vop_unlock_args *)))vop_nounlock)
77static int dead_bmap __P((struct vop_bmap_args *));
78static int dead_strategy __P((struct vop_strategy_args *));
79static int dead_print __P((struct vop_print_args *));
80#define dead_islocked ((int(*) __P((struct vop_islocked_args *)))vop_noislocked)
81#define dead_pathconf ((int (*) __P((struct vop_pathconf_args *)))dead_ebadf)
82#define dead_advlock ((int (*) __P((struct vop_advlock_args *)))dead_ebadf)
83#define dead_blkatoff ((int (*) __P((struct vop_blkatoff_args *)))dead_badop)
84#define dead_valloc ((int (*) __P((struct vop_valloc_args *)))dead_badop)
85#define dead_vfree ((int (*) __P((struct vop_vfree_args *)))dead_badop)
86#define dead_truncate ((int (*) __P((struct vop_truncate_args *)))nullop)
87#define dead_update ((int (*) __P((struct vop_update_args *)))nullop)
88#define dead_bwrite ((int (*) __P((struct vop_bwrite_args *)))nullop)
89
90vop_t **dead_vnodeop_p;
91static struct vnodeopv_entry_desc dead_vnodeop_entries[] = {
92 { &vop_default_desc, (vop_t *) vn_default_error },
93 { &vop_abortop_desc, (vop_t *) dead_abortop },
94 { &vop_access_desc, (vop_t *) dead_access },
95 { &vop_advlock_desc, (vop_t *) dead_advlock },
96 { &vop_blkatoff_desc, (vop_t *) dead_blkatoff },
97 { &vop_bmap_desc, (vop_t *) dead_bmap },
98 { &vop_bwrite_desc, (vop_t *) dead_bwrite },
99 { &vop_close_desc, (vop_t *) dead_close },
100 { &vop_create_desc, (vop_t *) dead_create },
101 { &vop_fsync_desc, (vop_t *) dead_fsync },
102 { &vop_getattr_desc, (vop_t *) dead_getattr },
103 { &vop_inactive_desc, (vop_t *) dead_inactive },
104 { &vop_ioctl_desc, (vop_t *) dead_ioctl },
105 { &vop_islocked_desc, (vop_t *) dead_islocked },
106 { &vop_link_desc, (vop_t *) dead_link },
107 { &vop_lock_desc, (vop_t *) dead_lock },
108 { &vop_lookup_desc, (vop_t *) dead_lookup },
109 { &vop_mkdir_desc, (vop_t *) dead_mkdir },
110 { &vop_mknod_desc, (vop_t *) dead_mknod },
111 { &vop_mmap_desc, (vop_t *) dead_mmap },
112 { &vop_open_desc, (vop_t *) dead_open },
113 { &vop_pathconf_desc, (vop_t *) dead_pathconf },
114 { &vop_poll_desc, (vop_t *) dead_poll },
115 { &vop_print_desc, (vop_t *) dead_print },
116 { &vop_read_desc, (vop_t *) dead_read },
117 { &vop_readdir_desc, (vop_t *) dead_readdir },
118 { &vop_readlink_desc, (vop_t *) dead_readlink },
119 { &vop_reclaim_desc, (vop_t *) dead_reclaim },
120 { &vop_remove_desc, (vop_t *) dead_remove },
121 { &vop_rename_desc, (vop_t *) dead_rename },
122 { &vop_rmdir_desc, (vop_t *) dead_rmdir },
123 { &vop_seek_desc, (vop_t *) dead_seek },
124 { &vop_setattr_desc, (vop_t *) dead_setattr },
125 { &vop_strategy_desc, (vop_t *) dead_strategy },
126 { &vop_symlink_desc, (vop_t *) dead_symlink },
127 { &vop_truncate_desc, (vop_t *) dead_truncate },
128 { &vop_unlock_desc, (vop_t *) dead_unlock },
129 { &vop_update_desc, (vop_t *) dead_update },
130 { &vop_valloc_desc, (vop_t *) dead_valloc },
131 { &vop_vfree_desc, (vop_t *) dead_vfree },
132 { &vop_write_desc, (vop_t *) dead_write },
133 { NULL, NULL }
134};
135static struct vnodeopv_desc dead_vnodeop_opv_desc =
136 { &dead_vnodeop_p, dead_vnodeop_entries };
137
138VNODEOP_SET(dead_vnodeop_opv_desc);
139
140/*
141 * Trivial lookup routine that always fails.
142 */
143/* ARGSUSED */
144static int
145dead_lookup(ap)
146 struct vop_lookup_args /* {
147 struct vnode * a_dvp;
148 struct vnode ** a_vpp;
149 struct componentname * a_cnp;
150 } */ *ap;
151{
152
153 *ap->a_vpp = NULL;
154 return (ENOTDIR);
155}
156
157/*
158 * Open always fails as if device did not exist.
159 */
160/* ARGSUSED */
161static int
162dead_open(ap)
163 struct vop_open_args /* {
164 struct vnode *a_vp;
165 int a_mode;
166 struct ucred *a_cred;
167 struct proc *a_p;
168 } */ *ap;
169{
170
171 return (ENXIO);
172}
173
174/*
175 * Vnode op for read
176 */
177/* ARGSUSED */
178static int
179dead_read(ap)
180 struct vop_read_args /* {
181 struct vnode *a_vp;
182 struct uio *a_uio;
183 int a_ioflag;
184 struct ucred *a_cred;
185 } */ *ap;
186{
187
188 if (chkvnlock(ap->a_vp))
189 panic("dead_read: lock");
190#if 0
191 /* Lite2 behaviour */
192 /*
193 * Return EOF for tty devices, EIO for others
194 */
195 if ((ap->a_vp->v_flag & VISTTY) == 0)
196 return (EIO);
197#else
198 /*
199 * Return EOF for character devices, EIO for others
200 */
201 if (ap->a_vp->v_type != VCHR)
202 return (EIO);
203#endif
204 return (0);
205}
206
207/*
208 * Vnode op for write
209 */
210/* ARGSUSED */
211static int
212dead_write(ap)
213 struct vop_write_args /* {
214 struct vnode *a_vp;
215 struct uio *a_uio;
216 int a_ioflag;
217 struct ucred *a_cred;
218 } */ *ap;
219{
220
221 if (chkvnlock(ap->a_vp))
222 panic("dead_write: lock");
223 return (EIO);
224}
225
226/*
227 * Device ioctl operation.
228 */
229/* ARGSUSED */
230static int
231dead_ioctl(ap)
232 struct vop_ioctl_args /* {
233 struct vnode *a_vp;
234 int a_command;
235 caddr_t a_data;
236 int a_fflag;
237 struct ucred *a_cred;
238 struct proc *a_p;
239 } */ *ap;
240{
241
242 if (!chkvnlock(ap->a_vp))
243 return (EBADF);
244 return (VCALL(ap->a_vp, VOFFSET(vop_ioctl), ap));
245}
246
247/*
248 * Just call the device strategy routine
249 */
250static int
251dead_strategy(ap)
252 struct vop_strategy_args /* {
253 struct buf *a_bp;
254 } */ *ap;
255{
256
257 if (ap->a_bp->b_vp == NULL || !chkvnlock(ap->a_bp->b_vp)) {
258 ap->a_bp->b_flags |= B_ERROR;
259 biodone(ap->a_bp);
260 return (EIO);
261 }
262 return (VOP_STRATEGY(ap->a_bp));
263}
264
265/*
266 * Wait until the vnode has finished changing state.
267 */
268static int
269dead_lock(ap)
270 struct vop_lock_args /* {
271 struct vnode *a_vp;
272 int a_flags;
273 struct proc *a_p;
274 } */ *ap;
275{
276 struct vnode *vp = ap->a_vp;
277
278 /*
279 * Since we are not using the lock manager, we must clear
280 * the interlock here.
281 */
282 if (ap->a_flags & LK_INTERLOCK) {
283 simple_unlock(&vp->v_interlock);
284 ap->a_flags &= ~LK_INTERLOCK;
285 }
286 if (!chkvnlock(vp))
287 return (0);
288 return (VCALL(vp, VOFFSET(vop_lock), ap));
289}
290
291/*
292 * Wait until the vnode has finished changing state.
293 */
294static int
295dead_bmap(ap)
296 struct vop_bmap_args /* {
297 struct vnode *a_vp;
298 daddr_t a_bn;
299 struct vnode **a_vpp;
300 daddr_t *a_bnp;
301 int *a_runp;
302 int *a_runb;
303 } */ *ap;
304{
305
306 if (!chkvnlock(ap->a_vp))
307 return (EIO);
308 return (VOP_BMAP(ap->a_vp, ap->a_bn, ap->a_vpp, ap->a_bnp, ap->a_runp, ap->a_runb));
309}
310
311/*
312 * Print out the contents of a dead vnode.
313 */
314/* ARGSUSED */
315static int
316dead_print(ap)
317 struct vop_print_args /* {
318 struct vnode *a_vp;
319 } */ *ap;
320{
321
322 printf("tag VT_NON, dead vnode\n");
323 return (0);
324}
325
326/*
327 * Empty vnode failed operation
328 */
329static int
330dead_ebadf()
331{
332
333 return (EBADF);
334}
335
336/*
337 * Empty vnode bad operation
338 */
339static int
340dead_badop()
341{
342
343 panic("dead_badop called");
344 /* NOTREACHED */
345}
346
347/*
348 * We have to wait during times when the vnode is
349 * in a state of change.
350 */
351int
352chkvnlock(vp)
353 register struct vnode *vp;
354{
355 int locked = 0;
356
357 while (vp->v_flag & VXLOCK) {
358 vp->v_flag |= VXWANT;
359 (void) tsleep((caddr_t)vp, PINOD, "ckvnlk", 0);
360 locked = 1;
361 }
362 return (locked);
363}
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 * $Id: dead_vnops.c,v 1.15 1997/09/14 02:57:46 peter Exp $
35 */
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/kernel.h>
40#include <sys/vnode.h>
41#include <sys/buf.h>
42
43static int chkvnlock __P((struct vnode *));
44/*
45 * Prototypes for dead operations on vnodes.
46 */
47static int dead_badop __P((void));
48static int dead_ebadf __P((void));
49static int dead_lookup __P((struct vop_lookup_args *));
50#define dead_create ((int (*) __P((struct vop_create_args *)))dead_badop)
51#define dead_mknod ((int (*) __P((struct vop_mknod_args *)))dead_badop)
52static int dead_open __P((struct vop_open_args *));
53#define dead_close ((int (*) __P((struct vop_close_args *)))nullop)
54#define dead_access ((int (*) __P((struct vop_access_args *)))dead_ebadf)
55#define dead_getattr ((int (*) __P((struct vop_getattr_args *)))dead_ebadf)
56#define dead_setattr ((int (*) __P((struct vop_setattr_args *)))dead_ebadf)
57static int dead_read __P((struct vop_read_args *));
58static int dead_write __P((struct vop_write_args *));
59static int dead_ioctl __P((struct vop_ioctl_args *));
60#define dead_poll vop_nopoll
61#define dead_mmap ((int (*) __P((struct vop_mmap_args *)))dead_badop)
62#define dead_fsync ((int (*) __P((struct vop_fsync_args *)))nullop)
63#define dead_seek ((int (*) __P((struct vop_seek_args *)))nullop)
64#define dead_remove ((int (*) __P((struct vop_remove_args *)))dead_badop)
65#define dead_link ((int (*) __P((struct vop_link_args *)))dead_badop)
66#define dead_rename ((int (*) __P((struct vop_rename_args *)))dead_badop)
67#define dead_mkdir ((int (*) __P((struct vop_mkdir_args *)))dead_badop)
68#define dead_rmdir ((int (*) __P((struct vop_rmdir_args *)))dead_badop)
69#define dead_symlink ((int (*) __P((struct vop_symlink_args *)))dead_badop)
70#define dead_readdir ((int (*) __P((struct vop_readdir_args *)))dead_ebadf)
71#define dead_readlink ((int (*) __P((struct vop_readlink_args *)))dead_ebadf)
72#define dead_abortop ((int (*) __P((struct vop_abortop_args *)))dead_badop)
73#define dead_inactive ((int (*) __P((struct vop_inactive_args *)))nullop)
74#define dead_reclaim ((int (*) __P((struct vop_reclaim_args *)))nullop)
75static int dead_lock __P((struct vop_lock_args *));
76#define dead_unlock ((int (*) __P((struct vop_unlock_args *)))vop_nounlock)
77static int dead_bmap __P((struct vop_bmap_args *));
78static int dead_strategy __P((struct vop_strategy_args *));
79static int dead_print __P((struct vop_print_args *));
80#define dead_islocked ((int(*) __P((struct vop_islocked_args *)))vop_noislocked)
81#define dead_pathconf ((int (*) __P((struct vop_pathconf_args *)))dead_ebadf)
82#define dead_advlock ((int (*) __P((struct vop_advlock_args *)))dead_ebadf)
83#define dead_blkatoff ((int (*) __P((struct vop_blkatoff_args *)))dead_badop)
84#define dead_valloc ((int (*) __P((struct vop_valloc_args *)))dead_badop)
85#define dead_vfree ((int (*) __P((struct vop_vfree_args *)))dead_badop)
86#define dead_truncate ((int (*) __P((struct vop_truncate_args *)))nullop)
87#define dead_update ((int (*) __P((struct vop_update_args *)))nullop)
88#define dead_bwrite ((int (*) __P((struct vop_bwrite_args *)))nullop)
89
90vop_t **dead_vnodeop_p;
91static struct vnodeopv_entry_desc dead_vnodeop_entries[] = {
92 { &vop_default_desc, (vop_t *) vn_default_error },
93 { &vop_abortop_desc, (vop_t *) dead_abortop },
94 { &vop_access_desc, (vop_t *) dead_access },
95 { &vop_advlock_desc, (vop_t *) dead_advlock },
96 { &vop_blkatoff_desc, (vop_t *) dead_blkatoff },
97 { &vop_bmap_desc, (vop_t *) dead_bmap },
98 { &vop_bwrite_desc, (vop_t *) dead_bwrite },
99 { &vop_close_desc, (vop_t *) dead_close },
100 { &vop_create_desc, (vop_t *) dead_create },
101 { &vop_fsync_desc, (vop_t *) dead_fsync },
102 { &vop_getattr_desc, (vop_t *) dead_getattr },
103 { &vop_inactive_desc, (vop_t *) dead_inactive },
104 { &vop_ioctl_desc, (vop_t *) dead_ioctl },
105 { &vop_islocked_desc, (vop_t *) dead_islocked },
106 { &vop_link_desc, (vop_t *) dead_link },
107 { &vop_lock_desc, (vop_t *) dead_lock },
108 { &vop_lookup_desc, (vop_t *) dead_lookup },
109 { &vop_mkdir_desc, (vop_t *) dead_mkdir },
110 { &vop_mknod_desc, (vop_t *) dead_mknod },
111 { &vop_mmap_desc, (vop_t *) dead_mmap },
112 { &vop_open_desc, (vop_t *) dead_open },
113 { &vop_pathconf_desc, (vop_t *) dead_pathconf },
114 { &vop_poll_desc, (vop_t *) dead_poll },
115 { &vop_print_desc, (vop_t *) dead_print },
116 { &vop_read_desc, (vop_t *) dead_read },
117 { &vop_readdir_desc, (vop_t *) dead_readdir },
118 { &vop_readlink_desc, (vop_t *) dead_readlink },
119 { &vop_reclaim_desc, (vop_t *) dead_reclaim },
120 { &vop_remove_desc, (vop_t *) dead_remove },
121 { &vop_rename_desc, (vop_t *) dead_rename },
122 { &vop_rmdir_desc, (vop_t *) dead_rmdir },
123 { &vop_seek_desc, (vop_t *) dead_seek },
124 { &vop_setattr_desc, (vop_t *) dead_setattr },
125 { &vop_strategy_desc, (vop_t *) dead_strategy },
126 { &vop_symlink_desc, (vop_t *) dead_symlink },
127 { &vop_truncate_desc, (vop_t *) dead_truncate },
128 { &vop_unlock_desc, (vop_t *) dead_unlock },
129 { &vop_update_desc, (vop_t *) dead_update },
130 { &vop_valloc_desc, (vop_t *) dead_valloc },
131 { &vop_vfree_desc, (vop_t *) dead_vfree },
132 { &vop_write_desc, (vop_t *) dead_write },
133 { NULL, NULL }
134};
135static struct vnodeopv_desc dead_vnodeop_opv_desc =
136 { &dead_vnodeop_p, dead_vnodeop_entries };
137
138VNODEOP_SET(dead_vnodeop_opv_desc);
139
140/*
141 * Trivial lookup routine that always fails.
142 */
143/* ARGSUSED */
144static int
145dead_lookup(ap)
146 struct vop_lookup_args /* {
147 struct vnode * a_dvp;
148 struct vnode ** a_vpp;
149 struct componentname * a_cnp;
150 } */ *ap;
151{
152
153 *ap->a_vpp = NULL;
154 return (ENOTDIR);
155}
156
157/*
158 * Open always fails as if device did not exist.
159 */
160/* ARGSUSED */
161static int
162dead_open(ap)
163 struct vop_open_args /* {
164 struct vnode *a_vp;
165 int a_mode;
166 struct ucred *a_cred;
167 struct proc *a_p;
168 } */ *ap;
169{
170
171 return (ENXIO);
172}
173
174/*
175 * Vnode op for read
176 */
177/* ARGSUSED */
178static int
179dead_read(ap)
180 struct vop_read_args /* {
181 struct vnode *a_vp;
182 struct uio *a_uio;
183 int a_ioflag;
184 struct ucred *a_cred;
185 } */ *ap;
186{
187
188 if (chkvnlock(ap->a_vp))
189 panic("dead_read: lock");
190#if 0
191 /* Lite2 behaviour */
192 /*
193 * Return EOF for tty devices, EIO for others
194 */
195 if ((ap->a_vp->v_flag & VISTTY) == 0)
196 return (EIO);
197#else
198 /*
199 * Return EOF for character devices, EIO for others
200 */
201 if (ap->a_vp->v_type != VCHR)
202 return (EIO);
203#endif
204 return (0);
205}
206
207/*
208 * Vnode op for write
209 */
210/* ARGSUSED */
211static int
212dead_write(ap)
213 struct vop_write_args /* {
214 struct vnode *a_vp;
215 struct uio *a_uio;
216 int a_ioflag;
217 struct ucred *a_cred;
218 } */ *ap;
219{
220
221 if (chkvnlock(ap->a_vp))
222 panic("dead_write: lock");
223 return (EIO);
224}
225
226/*
227 * Device ioctl operation.
228 */
229/* ARGSUSED */
230static int
231dead_ioctl(ap)
232 struct vop_ioctl_args /* {
233 struct vnode *a_vp;
234 int a_command;
235 caddr_t a_data;
236 int a_fflag;
237 struct ucred *a_cred;
238 struct proc *a_p;
239 } */ *ap;
240{
241
242 if (!chkvnlock(ap->a_vp))
243 return (EBADF);
244 return (VCALL(ap->a_vp, VOFFSET(vop_ioctl), ap));
245}
246
247/*
248 * Just call the device strategy routine
249 */
250static int
251dead_strategy(ap)
252 struct vop_strategy_args /* {
253 struct buf *a_bp;
254 } */ *ap;
255{
256
257 if (ap->a_bp->b_vp == NULL || !chkvnlock(ap->a_bp->b_vp)) {
258 ap->a_bp->b_flags |= B_ERROR;
259 biodone(ap->a_bp);
260 return (EIO);
261 }
262 return (VOP_STRATEGY(ap->a_bp));
263}
264
265/*
266 * Wait until the vnode has finished changing state.
267 */
268static int
269dead_lock(ap)
270 struct vop_lock_args /* {
271 struct vnode *a_vp;
272 int a_flags;
273 struct proc *a_p;
274 } */ *ap;
275{
276 struct vnode *vp = ap->a_vp;
277
278 /*
279 * Since we are not using the lock manager, we must clear
280 * the interlock here.
281 */
282 if (ap->a_flags & LK_INTERLOCK) {
283 simple_unlock(&vp->v_interlock);
284 ap->a_flags &= ~LK_INTERLOCK;
285 }
286 if (!chkvnlock(vp))
287 return (0);
288 return (VCALL(vp, VOFFSET(vop_lock), ap));
289}
290
291/*
292 * Wait until the vnode has finished changing state.
293 */
294static int
295dead_bmap(ap)
296 struct vop_bmap_args /* {
297 struct vnode *a_vp;
298 daddr_t a_bn;
299 struct vnode **a_vpp;
300 daddr_t *a_bnp;
301 int *a_runp;
302 int *a_runb;
303 } */ *ap;
304{
305
306 if (!chkvnlock(ap->a_vp))
307 return (EIO);
308 return (VOP_BMAP(ap->a_vp, ap->a_bn, ap->a_vpp, ap->a_bnp, ap->a_runp, ap->a_runb));
309}
310
311/*
312 * Print out the contents of a dead vnode.
313 */
314/* ARGSUSED */
315static int
316dead_print(ap)
317 struct vop_print_args /* {
318 struct vnode *a_vp;
319 } */ *ap;
320{
321
322 printf("tag VT_NON, dead vnode\n");
323 return (0);
324}
325
326/*
327 * Empty vnode failed operation
328 */
329static int
330dead_ebadf()
331{
332
333 return (EBADF);
334}
335
336/*
337 * Empty vnode bad operation
338 */
339static int
340dead_badop()
341{
342
343 panic("dead_badop called");
344 /* NOTREACHED */
345}
346
347/*
348 * We have to wait during times when the vnode is
349 * in a state of change.
350 */
351int
352chkvnlock(vp)
353 register struct vnode *vp;
354{
355 int locked = 0;
356
357 while (vp->v_flag & VXLOCK) {
358 vp->v_flag |= VXWANT;
359 (void) tsleep((caddr_t)vp, PINOD, "ckvnlk", 0);
360 locked = 1;
361 }
362 return (locked);
363}