Deleted Added
full compact
dead_vnops.c (12203) dead_vnops.c (12570)
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

--- 17 unchanged lines hidden (view full) ---

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

--- 17 unchanged lines hidden (view full) ---

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.8 1995/11/09 08:14:59 bde Exp $
34 * $Id: dead_vnops.c,v 1.9 1995/11/11 03:36:07 bde Exp $
35 */
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/proc.h>
40#include <sys/time.h>
41#include <sys/kernel.h>
42#include <sys/vnode.h>
43#include <sys/errno.h>
44#include <sys/namei.h>
45#include <sys/buf.h>
46
47static int chkvnlock __P((struct vnode *));
48/*
49 * Prototypes for dead operations on vnodes.
50 */
35 */
36
37#include <sys/param.h>
38#include <sys/systm.h>
39#include <sys/proc.h>
40#include <sys/time.h>
41#include <sys/kernel.h>
42#include <sys/vnode.h>
43#include <sys/errno.h>
44#include <sys/namei.h>
45#include <sys/buf.h>
46
47static int chkvnlock __P((struct vnode *));
48/*
49 * Prototypes for dead operations on vnodes.
50 */
51int dead_badop __P((void));
52int dead_ebadf __P((void));
53int dead_lookup __P((struct vop_lookup_args *));
51static int dead_badop __P((void));
52static int dead_ebadf __P((void));
53static int dead_lookup __P((struct vop_lookup_args *));
54#define dead_create ((int (*) __P((struct vop_create_args *)))dead_badop)
55#define dead_mknod ((int (*) __P((struct vop_mknod_args *)))dead_badop)
54#define dead_create ((int (*) __P((struct vop_create_args *)))dead_badop)
55#define dead_mknod ((int (*) __P((struct vop_mknod_args *)))dead_badop)
56int dead_open __P((struct vop_open_args *));
56static int dead_open __P((struct vop_open_args *));
57#define dead_close ((int (*) __P((struct vop_close_args *)))nullop)
58#define dead_access ((int (*) __P((struct vop_access_args *)))dead_ebadf)
59#define dead_getattr ((int (*) __P((struct vop_getattr_args *)))dead_ebadf)
60#define dead_setattr ((int (*) __P((struct vop_setattr_args *)))dead_ebadf)
57#define dead_close ((int (*) __P((struct vop_close_args *)))nullop)
58#define dead_access ((int (*) __P((struct vop_access_args *)))dead_ebadf)
59#define dead_getattr ((int (*) __P((struct vop_getattr_args *)))dead_ebadf)
60#define dead_setattr ((int (*) __P((struct vop_setattr_args *)))dead_ebadf)
61int dead_read __P((struct vop_read_args *));
62int dead_write __P((struct vop_write_args *));
63int dead_ioctl __P((struct vop_ioctl_args *));
64int dead_select __P((struct vop_select_args *));
61static int dead_read __P((struct vop_read_args *));
62static int dead_write __P((struct vop_write_args *));
63static int dead_ioctl __P((struct vop_ioctl_args *));
64static int dead_select __P((struct vop_select_args *));
65#define dead_mmap ((int (*) __P((struct vop_mmap_args *)))dead_badop)
66#define dead_fsync ((int (*) __P((struct vop_fsync_args *)))nullop)
67#define dead_seek ((int (*) __P((struct vop_seek_args *)))nullop)
68#define dead_remove ((int (*) __P((struct vop_remove_args *)))dead_badop)
69#define dead_link ((int (*) __P((struct vop_link_args *)))dead_badop)
70#define dead_rename ((int (*) __P((struct vop_rename_args *)))dead_badop)
71#define dead_mkdir ((int (*) __P((struct vop_mkdir_args *)))dead_badop)
72#define dead_rmdir ((int (*) __P((struct vop_rmdir_args *)))dead_badop)
73#define dead_symlink ((int (*) __P((struct vop_symlink_args *)))dead_badop)
74#define dead_readdir ((int (*) __P((struct vop_readdir_args *)))dead_ebadf)
75#define dead_readlink ((int (*) __P((struct vop_readlink_args *)))dead_ebadf)
76#define dead_abortop ((int (*) __P((struct vop_abortop_args *)))dead_badop)
77#define dead_inactive ((int (*) __P((struct vop_inactive_args *)))nullop)
78#define dead_reclaim ((int (*) __P((struct vop_reclaim_args *)))nullop)
65#define dead_mmap ((int (*) __P((struct vop_mmap_args *)))dead_badop)
66#define dead_fsync ((int (*) __P((struct vop_fsync_args *)))nullop)
67#define dead_seek ((int (*) __P((struct vop_seek_args *)))nullop)
68#define dead_remove ((int (*) __P((struct vop_remove_args *)))dead_badop)
69#define dead_link ((int (*) __P((struct vop_link_args *)))dead_badop)
70#define dead_rename ((int (*) __P((struct vop_rename_args *)))dead_badop)
71#define dead_mkdir ((int (*) __P((struct vop_mkdir_args *)))dead_badop)
72#define dead_rmdir ((int (*) __P((struct vop_rmdir_args *)))dead_badop)
73#define dead_symlink ((int (*) __P((struct vop_symlink_args *)))dead_badop)
74#define dead_readdir ((int (*) __P((struct vop_readdir_args *)))dead_ebadf)
75#define dead_readlink ((int (*) __P((struct vop_readlink_args *)))dead_ebadf)
76#define dead_abortop ((int (*) __P((struct vop_abortop_args *)))dead_badop)
77#define dead_inactive ((int (*) __P((struct vop_inactive_args *)))nullop)
78#define dead_reclaim ((int (*) __P((struct vop_reclaim_args *)))nullop)
79int dead_lock __P((struct vop_lock_args *));
79static int dead_lock __P((struct vop_lock_args *));
80#define dead_unlock ((int (*) __P((struct vop_unlock_args *)))nullop)
80#define dead_unlock ((int (*) __P((struct vop_unlock_args *)))nullop)
81int dead_bmap __P((struct vop_bmap_args *));
82int dead_strategy __P((struct vop_strategy_args *));
83int dead_print __P((struct vop_print_args *));
81static int dead_bmap __P((struct vop_bmap_args *));
82static int dead_strategy __P((struct vop_strategy_args *));
83static int dead_print __P((struct vop_print_args *));
84#define dead_islocked ((int (*) __P((struct vop_islocked_args *)))nullop)
85#define dead_pathconf ((int (*) __P((struct vop_pathconf_args *)))dead_ebadf)
86#define dead_advlock ((int (*) __P((struct vop_advlock_args *)))dead_ebadf)
87#define dead_blkatoff ((int (*) __P((struct vop_blkatoff_args *)))dead_badop)
88#define dead_valloc ((int (*) __P((struct vop_valloc_args *)))dead_badop)
89#define dead_vfree ((int (*) __P((struct vop_vfree_args *)))dead_badop)
90#define dead_truncate ((int (*) __P((struct vop_truncate_args *)))nullop)
91#define dead_update ((int (*) __P((struct vop_update_args *)))nullop)
92#define dead_bwrite ((int (*) __P((struct vop_bwrite_args *)))nullop)
93
94vop_t **dead_vnodeop_p;
84#define dead_islocked ((int (*) __P((struct vop_islocked_args *)))nullop)
85#define dead_pathconf ((int (*) __P((struct vop_pathconf_args *)))dead_ebadf)
86#define dead_advlock ((int (*) __P((struct vop_advlock_args *)))dead_ebadf)
87#define dead_blkatoff ((int (*) __P((struct vop_blkatoff_args *)))dead_badop)
88#define dead_valloc ((int (*) __P((struct vop_valloc_args *)))dead_badop)
89#define dead_vfree ((int (*) __P((struct vop_vfree_args *)))dead_badop)
90#define dead_truncate ((int (*) __P((struct vop_truncate_args *)))nullop)
91#define dead_update ((int (*) __P((struct vop_update_args *)))nullop)
92#define dead_bwrite ((int (*) __P((struct vop_bwrite_args *)))nullop)
93
94vop_t **dead_vnodeop_p;
95struct vnodeopv_entry_desc dead_vnodeop_entries[] = {
95static struct vnodeopv_entry_desc dead_vnodeop_entries[] = {
96 { &vop_default_desc, (vop_t *)vn_default_error },
97 { &vop_lookup_desc, (vop_t *)dead_lookup }, /* lookup */
98 { &vop_create_desc, (vop_t *)dead_create }, /* create */
99 { &vop_mknod_desc, (vop_t *)dead_mknod }, /* mknod */
100 { &vop_open_desc, (vop_t *)dead_open }, /* open */
101 { &vop_close_desc, (vop_t *)dead_close }, /* close */
102 { &vop_access_desc, (vop_t *)dead_access }, /* access */
103 { &vop_getattr_desc, (vop_t *)dead_getattr }, /* getattr */

--- 27 unchanged lines hidden (view full) ---

131 { &vop_blkatoff_desc, (vop_t *)dead_blkatoff }, /* blkatoff */
132 { &vop_valloc_desc, (vop_t *)dead_valloc }, /* valloc */
133 { &vop_vfree_desc, (vop_t *)dead_vfree }, /* vfree */
134 { &vop_truncate_desc, (vop_t *)dead_truncate }, /* truncate */
135 { &vop_update_desc, (vop_t *)dead_update }, /* update */
136 { &vop_bwrite_desc, (vop_t *)dead_bwrite }, /* bwrite */
137 { NULL, NULL }
138};
96 { &vop_default_desc, (vop_t *)vn_default_error },
97 { &vop_lookup_desc, (vop_t *)dead_lookup }, /* lookup */
98 { &vop_create_desc, (vop_t *)dead_create }, /* create */
99 { &vop_mknod_desc, (vop_t *)dead_mknod }, /* mknod */
100 { &vop_open_desc, (vop_t *)dead_open }, /* open */
101 { &vop_close_desc, (vop_t *)dead_close }, /* close */
102 { &vop_access_desc, (vop_t *)dead_access }, /* access */
103 { &vop_getattr_desc, (vop_t *)dead_getattr }, /* getattr */

--- 27 unchanged lines hidden (view full) ---

131 { &vop_blkatoff_desc, (vop_t *)dead_blkatoff }, /* blkatoff */
132 { &vop_valloc_desc, (vop_t *)dead_valloc }, /* valloc */
133 { &vop_vfree_desc, (vop_t *)dead_vfree }, /* vfree */
134 { &vop_truncate_desc, (vop_t *)dead_truncate }, /* truncate */
135 { &vop_update_desc, (vop_t *)dead_update }, /* update */
136 { &vop_bwrite_desc, (vop_t *)dead_bwrite }, /* bwrite */
137 { NULL, NULL }
138};
139struct vnodeopv_desc dead_vnodeop_opv_desc =
139static struct vnodeopv_desc dead_vnodeop_opv_desc =
140 { &dead_vnodeop_p, dead_vnodeop_entries };
141
142VNODEOP_SET(dead_vnodeop_opv_desc);
143
144/*
145 * Trivial lookup routine that always fails.
146 */
147/* ARGSUSED */
140 { &dead_vnodeop_p, dead_vnodeop_entries };
141
142VNODEOP_SET(dead_vnodeop_opv_desc);
143
144/*
145 * Trivial lookup routine that always fails.
146 */
147/* ARGSUSED */
148int
148static int
149dead_lookup(ap)
150 struct vop_lookup_args /* {
151 struct vnode * a_dvp;
152 struct vnode ** a_vpp;
153 struct componentname * a_cnp;
154 } */ *ap;
155{
156
157 *ap->a_vpp = NULL;
158 return (ENOTDIR);
159}
160
161/*
162 * Open always fails as if device did not exist.
163 */
164/* ARGSUSED */
149dead_lookup(ap)
150 struct vop_lookup_args /* {
151 struct vnode * a_dvp;
152 struct vnode ** a_vpp;
153 struct componentname * a_cnp;
154 } */ *ap;
155{
156
157 *ap->a_vpp = NULL;
158 return (ENOTDIR);
159}
160
161/*
162 * Open always fails as if device did not exist.
163 */
164/* ARGSUSED */
165int
165static int
166dead_open(ap)
167 struct vop_open_args /* {
168 struct vnode *a_vp;
169 int a_mode;
170 struct ucred *a_cred;
171 struct proc *a_p;
172 } */ *ap;
173{
174
175 return (ENXIO);
176}
177
178/*
179 * Vnode op for read
180 */
181/* ARGSUSED */
166dead_open(ap)
167 struct vop_open_args /* {
168 struct vnode *a_vp;
169 int a_mode;
170 struct ucred *a_cred;
171 struct proc *a_p;
172 } */ *ap;
173{
174
175 return (ENXIO);
176}
177
178/*
179 * Vnode op for read
180 */
181/* ARGSUSED */
182int
182static int
183dead_read(ap)
184 struct vop_read_args /* {
185 struct vnode *a_vp;
186 struct uio *a_uio;
187 int a_ioflag;
188 struct ucred *a_cred;
189 } */ *ap;
190{

--- 7 unchanged lines hidden (view full) ---

198 return (EIO);
199 return (0);
200}
201
202/*
203 * Vnode op for write
204 */
205/* ARGSUSED */
183dead_read(ap)
184 struct vop_read_args /* {
185 struct vnode *a_vp;
186 struct uio *a_uio;
187 int a_ioflag;
188 struct ucred *a_cred;
189 } */ *ap;
190{

--- 7 unchanged lines hidden (view full) ---

198 return (EIO);
199 return (0);
200}
201
202/*
203 * Vnode op for write
204 */
205/* ARGSUSED */
206int
206static int
207dead_write(ap)
208 struct vop_write_args /* {
209 struct vnode *a_vp;
210 struct uio *a_uio;
211 int a_ioflag;
212 struct ucred *a_cred;
213 } */ *ap;
214{
215
216 if (chkvnlock(ap->a_vp))
217 panic("dead_write: lock");
218 return (EIO);
219}
220
221/*
222 * Device ioctl operation.
223 */
224/* ARGSUSED */
207dead_write(ap)
208 struct vop_write_args /* {
209 struct vnode *a_vp;
210 struct uio *a_uio;
211 int a_ioflag;
212 struct ucred *a_cred;
213 } */ *ap;
214{
215
216 if (chkvnlock(ap->a_vp))
217 panic("dead_write: lock");
218 return (EIO);
219}
220
221/*
222 * Device ioctl operation.
223 */
224/* ARGSUSED */
225int
225static int
226dead_ioctl(ap)
227 struct vop_ioctl_args /* {
228 struct vnode *a_vp;
229 int a_command;
230 caddr_t a_data;
231 int a_fflag;
232 struct ucred *a_cred;
233 struct proc *a_p;
234 } */ *ap;
235{
236
237 if (!chkvnlock(ap->a_vp))
238 return (EBADF);
239 return (VCALL(ap->a_vp, VOFFSET(vop_ioctl), ap));
240}
241
242/* ARGSUSED */
226dead_ioctl(ap)
227 struct vop_ioctl_args /* {
228 struct vnode *a_vp;
229 int a_command;
230 caddr_t a_data;
231 int a_fflag;
232 struct ucred *a_cred;
233 struct proc *a_p;
234 } */ *ap;
235{
236
237 if (!chkvnlock(ap->a_vp))
238 return (EBADF);
239 return (VCALL(ap->a_vp, VOFFSET(vop_ioctl), ap));
240}
241
242/* ARGSUSED */
243int
243static int
244dead_select(ap)
245 struct vop_select_args /* {
246 struct vnode *a_vp;
247 int a_which;
248 int a_fflags;
249 struct ucred *a_cred;
250 struct proc *a_p;
251 } */ *ap;
252{
253
254 /*
255 * Let the user find out that the descriptor is gone.
256 */
257 return (1);
258}
259
260/*
261 * Just call the device strategy routine
262 */
244dead_select(ap)
245 struct vop_select_args /* {
246 struct vnode *a_vp;
247 int a_which;
248 int a_fflags;
249 struct ucred *a_cred;
250 struct proc *a_p;
251 } */ *ap;
252{
253
254 /*
255 * Let the user find out that the descriptor is gone.
256 */
257 return (1);
258}
259
260/*
261 * Just call the device strategy routine
262 */
263int
263static int
264dead_strategy(ap)
265 struct vop_strategy_args /* {
266 struct buf *a_bp;
267 } */ *ap;
268{
269
270 if (ap->a_bp->b_vp == NULL || !chkvnlock(ap->a_bp->b_vp)) {
271 ap->a_bp->b_flags |= B_ERROR;
272 biodone(ap->a_bp);
273 return (EIO);
274 }
275 return (VOP_STRATEGY(ap->a_bp));
276}
277
278/*
279 * Wait until the vnode has finished changing state.
280 */
264dead_strategy(ap)
265 struct vop_strategy_args /* {
266 struct buf *a_bp;
267 } */ *ap;
268{
269
270 if (ap->a_bp->b_vp == NULL || !chkvnlock(ap->a_bp->b_vp)) {
271 ap->a_bp->b_flags |= B_ERROR;
272 biodone(ap->a_bp);
273 return (EIO);
274 }
275 return (VOP_STRATEGY(ap->a_bp));
276}
277
278/*
279 * Wait until the vnode has finished changing state.
280 */
281int
281static int
282dead_lock(ap)
283 struct vop_lock_args /* {
284 struct vnode *a_vp;
285 } */ *ap;
286{
287
288 if (!chkvnlock(ap->a_vp))
289 return (0);
290 return (VCALL(ap->a_vp, VOFFSET(vop_lock), ap));
291}
292
293/*
294 * Wait until the vnode has finished changing state.
295 */
282dead_lock(ap)
283 struct vop_lock_args /* {
284 struct vnode *a_vp;
285 } */ *ap;
286{
287
288 if (!chkvnlock(ap->a_vp))
289 return (0);
290 return (VCALL(ap->a_vp, VOFFSET(vop_lock), ap));
291}
292
293/*
294 * Wait until the vnode has finished changing state.
295 */
296int
296static int
297dead_bmap(ap)
298 struct vop_bmap_args /* {
299 struct vnode *a_vp;
300 daddr_t a_bn;
301 struct vnode **a_vpp;
302 daddr_t *a_bnp;
303 int *a_runp;
304 int *a_runb;

--- 4 unchanged lines hidden (view full) ---

309 return (EIO);
310 return (VOP_BMAP(ap->a_vp, ap->a_bn, ap->a_vpp, ap->a_bnp, ap->a_runp, ap->a_runb));
311}
312
313/*
314 * Print out the contents of a dead vnode.
315 */
316/* ARGSUSED */
297dead_bmap(ap)
298 struct vop_bmap_args /* {
299 struct vnode *a_vp;
300 daddr_t a_bn;
301 struct vnode **a_vpp;
302 daddr_t *a_bnp;
303 int *a_runp;
304 int *a_runb;

--- 4 unchanged lines hidden (view full) ---

309 return (EIO);
310 return (VOP_BMAP(ap->a_vp, ap->a_bn, ap->a_vpp, ap->a_bnp, ap->a_runp, ap->a_runb));
311}
312
313/*
314 * Print out the contents of a dead vnode.
315 */
316/* ARGSUSED */
317int
317static int
318dead_print(ap)
319 struct vop_print_args /* {
320 struct vnode *a_vp;
321 } */ *ap;
322{
323
324 printf("tag VT_NON, dead vnode\n");
325 return (0);
326}
327
328/*
329 * Empty vnode failed operation
330 */
318dead_print(ap)
319 struct vop_print_args /* {
320 struct vnode *a_vp;
321 } */ *ap;
322{
323
324 printf("tag VT_NON, dead vnode\n");
325 return (0);
326}
327
328/*
329 * Empty vnode failed operation
330 */
331int
331static int
332dead_ebadf()
333{
334
335 return (EBADF);
336}
337
338/*
339 * Empty vnode bad operation
340 */
332dead_ebadf()
333{
334
335 return (EBADF);
336}
337
338/*
339 * Empty vnode bad operation
340 */
341int
341static int
342dead_badop()
343{
344
345 panic("dead_badop called");
346 /* NOTREACHED */
347}
348
349/*

--- 16 unchanged lines hidden ---
342dead_badop()
343{
344
345 panic("dead_badop called");
346 /* NOTREACHED */
347}
348
349/*

--- 16 unchanged lines hidden ---