Rename all the functions and structures for the old VOP namespace API
[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 $
e62afb5f 35 * $DragonFly: src/sys/vfs/deadfs/dead_vnops.c,v 1.13 2005/09/14 01:13:24 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>
43#include <sys/buf.h>
44#include <sys/poll.h>
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 *);
52static int dead_lock (struct vop_lock_args *);
e62afb5f 53static int dead_lookup (struct vop_old_lookup_args *);
a6ee311a
RG
54static int dead_open (struct vop_open_args *);
55static int dead_poll (struct vop_poll_args *);
56static int dead_print (struct vop_print_args *);
57static int dead_read (struct vop_read_args *);
58static int dead_write (struct vop_write_args *);
984263bc 59
2d3e977e 60struct vop_ops *dead_vnode_vops;
984263bc 61static struct vnodeopv_entry_desc dead_vnodeop_entries[] = {
2d3e977e
MD
62 { &vop_default_desc, vop_defaultop },
63 { &vop_access_desc, vop_ebadf },
64 { &vop_advlock_desc, vop_ebadf },
625ddaba 65 { &vop_bmap_desc, (vnodeopv_entry_t) dead_bmap },
e62afb5f 66 { &vop_old_create_desc, (vnodeopv_entry_t) dead_badop },
2d3e977e
MD
67 { &vop_getattr_desc, vop_ebadf },
68 { &vop_inactive_desc, vop_null },
625ddaba 69 { &vop_ioctl_desc, (vnodeopv_entry_t) dead_ioctl },
e62afb5f 70 { &vop_old_link_desc, (vnodeopv_entry_t) dead_badop },
625ddaba 71 { &vop_lock_desc, (vnodeopv_entry_t) dead_lock },
e62afb5f
MD
72 { &vop_old_lookup_desc, (vnodeopv_entry_t) dead_lookup },
73 { &vop_old_mkdir_desc, (vnodeopv_entry_t) dead_badop },
74 { &vop_old_mknod_desc, (vnodeopv_entry_t) dead_badop },
625ddaba
JS
75 { &vop_mmap_desc, (vnodeopv_entry_t) dead_badop },
76 { &vop_open_desc, (vnodeopv_entry_t) dead_open },
2d3e977e 77 { &vop_pathconf_desc, vop_ebadf }, /* per pathconf(2) */
625ddaba
JS
78 { &vop_poll_desc, (vnodeopv_entry_t) dead_poll },
79 { &vop_print_desc, (vnodeopv_entry_t) dead_print },
80 { &vop_read_desc, (vnodeopv_entry_t) dead_read },
2d3e977e
MD
81 { &vop_readdir_desc, vop_ebadf },
82 { &vop_readlink_desc, vop_ebadf },
83 { &vop_reclaim_desc, vop_null },
e62afb5f
MD
84 { &vop_old_remove_desc, (vnodeopv_entry_t) dead_badop },
85 { &vop_old_rename_desc, (vnodeopv_entry_t) dead_badop },
86 { &vop_old_rmdir_desc, (vnodeopv_entry_t) dead_badop },
2d3e977e 87 { &vop_setattr_desc, vop_ebadf },
e62afb5f 88 { &vop_old_symlink_desc, (vnodeopv_entry_t) dead_badop },
625ddaba 89 { &vop_write_desc, (vnodeopv_entry_t) dead_write },
984263bc
MD
90 { NULL, NULL }
91};
92static struct vnodeopv_desc dead_vnodeop_opv_desc =
2d3e977e 93 { &dead_vnode_vops, dead_vnodeop_entries };
984263bc
MD
94
95VNODEOP_SET(dead_vnodeop_opv_desc);
96
97/*
98 * Trivial lookup routine that always fails.
a7918111
CP
99 *
100 * dead_lookup(struct vnode *a_dvp, struct vnode **a_vpp,
101 * struct componentname *a_cnp)
984263bc
MD
102 */
103/* ARGSUSED */
104static int
e62afb5f 105dead_lookup(struct vop_old_lookup_args *ap)
984263bc 106{
984263bc
MD
107 *ap->a_vpp = NULL;
108 return (ENOTDIR);
109}
110
111/*
112 * Open always fails as if device did not exist.
a7918111
CP
113 *
114 * dead_open(struct vnode *a_vp, int a_mode, struct ucred *a_cred,
115 * struct proc *a_p)
984263bc
MD
116 */
117/* ARGSUSED */
118static int
a7918111 119dead_open(struct vop_open_args *ap)
984263bc 120{
984263bc
MD
121 return (ENXIO);
122}
123
124/*
125 * Vnode op for read
a7918111
CP
126 *
127 * dead_read(struct vnode *a_vp, struct uio *a_uio, int a_ioflag,
128 * struct ucred *a_cred)
984263bc
MD
129 */
130/* ARGSUSED */
131static int
a7918111 132dead_read(struct vop_read_args *ap)
984263bc 133{
984263bc
MD
134 /*
135 * Return EOF for tty devices, EIO for others
136 */
137 if ((ap->a_vp->v_flag & VISTTY) == 0)
138 return (EIO);
139 return (0);
140}
141
142/*
143 * Vnode op for write
a7918111
CP
144 *
145 * dead_write(struct vnode *a_vp, struct uio *a_uio, int a_ioflag,
146 * struct ucred *a_cred)
984263bc
MD
147 */
148/* ARGSUSED */
149static int
a7918111 150dead_write(struct vop_write_args *ap)
984263bc 151{
984263bc
MD
152 return (EIO);
153}
154
155/*
156 * Device ioctl operation.
a7918111
CP
157 *
158 * dead_ioctl(struct vnode *a_vp, int a_command, caddr_t a_data, int a_fflag,
159 * struct ucred *a_cred, struct proc *a_p)
984263bc
MD
160 */
161/* ARGSUSED */
162static int
a7918111 163dead_ioctl(struct vop_ioctl_args *ap)
984263bc 164{
5fd012e0 165 return (ENOTTY);
984263bc
MD
166}
167
984263bc
MD
168/*
169 * Wait until the vnode has finished changing state.
a7918111 170 *
5fd012e0 171 * dead_lock(struct vnode *a_vp, int a_flags, struct proc *a_p)
984263bc
MD
172 */
173static int
a7918111 174dead_lock(struct vop_lock_args *ap)
984263bc 175{
5fd012e0 176 return (0);
984263bc
MD
177}
178
179/*
180 * Wait until the vnode has finished changing state.
a7918111
CP
181 *
182 * dead_bmap(struct vnode *a_vp, daddr_t a_bn, struct vnode **a_vpp,
183 * daddr_t *a_bnp, int *a_runp, int *a_runb)
984263bc
MD
184 */
185static int
a7918111 186dead_bmap(struct vop_bmap_args *ap)
984263bc 187{
5fd012e0 188 return (EIO);
984263bc
MD
189}
190
191/*
192 * Print out the contents of a dead vnode.
a7918111
CP
193 *
194 * dead_print(struct vnode *a_vp)
984263bc
MD
195 */
196/* ARGSUSED */
197static int
a7918111 198dead_print(struct vop_print_args *ap)
984263bc 199{
984263bc
MD
200 printf("tag VT_NON, dead vnode\n");
201 return (0);
202}
203
204/*
205 * Empty vnode bad operation
206 */
207static int
a7918111 208dead_badop(void)
984263bc 209{
984263bc
MD
210 panic("dead_badop called");
211 /* NOTREACHED */
212}
213
984263bc
MD
214/*
215 * Trivial poll routine that always returns POLLHUP.
216 * This is necessary so that a process which is polling a file
217 * gets notified when that file is revoke()d.
218 */
219static int
a7918111 220dead_poll(struct vop_poll_args *ap)
984263bc
MD
221{
222 return (POLLHUP);
223}