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