xref: /netbsd-src/sys/miscfs/specfs/specdev.h (revision 0b9f50897e9a9c6709320fafb4c3787fddcc0a45)
1 /*
2  * Copyright (c) 1990 The Regents of the University of California.
3  * 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  *	from: @(#)specdev.h	7.4 (Berkeley) 4/19/91
34  *	$Id: specdev.h,v 1.5 1993/09/07 15:41:56 ws Exp $
35  */
36 
37 #ifndef _SYS_SPECDEV_H_
38 #define _SYS_SPECDEV_H_
39 
40 /*
41  * This structure defines the information maintained about
42  * special devices. It is allocated in checkalias and freed
43  * in vgone.
44  */
45 struct specinfo {
46 	struct	vnode **si_hashchain;
47 	struct	vnode *si_specnext;
48 	long	si_flags;
49 	dev_t	si_rdev;
50 };
51 /*
52  * Exported shorthand
53  */
54 #define v_rdev v_specinfo->si_rdev
55 #define v_hashchain v_specinfo->si_hashchain
56 #define v_specnext v_specinfo->si_specnext
57 #define v_specflags v_specinfo->si_flags
58 
59 /*
60  * Flags for specinfo
61  */
62 #define	SI_MOUNTEDON	0x0001	/* block special device is mounted on */
63 
64 /*
65  * Special device management
66  */
67 #define	SPECHSZ	64
68 #if	((SPECHSZ&(SPECHSZ-1)) == 0)
69 #define	SPECHASH(rdev)	(((rdev>>5)+(rdev))&(SPECHSZ-1))
70 #else
71 #define	SPECHASH(rdev)	(((unsigned)((rdev>>5)+(rdev)))%SPECHSZ)
72 #endif
73 
74 struct vnode *speclisth[SPECHSZ];
75 
76 /*
77  * Prototypes for special file operations on vnodes.
78  */
79 struct	nameidata;
80 struct	ucred;
81 struct	flock;
82 struct	buf;
83 struct	uio;
84 
85 int	spec_badop(),
86 	spec_ebadf();
87 
88 int	spec_lookup __P((
89 		struct vnode *vp,
90 		struct nameidata *ndp,
91 		struct proc *p));
92 #define spec_create ((int (*) __P(( \
93 		struct nameidata *ndp, \
94 		struct vattr *vap, \
95 		struct proc *p))) spec_badop)
96 #define spec_mknod ((int (*) __P(( \
97 		struct nameidata *ndp, \
98 		struct vattr *vap, \
99 		struct ucred *cred, \
100 		struct proc *p))) spec_badop)
101 int	spec_open __P((
102 		struct vnode *vp,
103 		int mode,
104 		struct ucred *cred,
105 		struct proc *p));
106 int	spec_close __P((
107 		struct vnode *vp,
108 		int fflag,
109 		struct ucred *cred,
110 		struct proc *p));
111 #define spec_access ((int (*) __P(( \
112 		struct vnode *vp, \
113 		int mode, \
114 		struct ucred *cred, \
115 		struct proc *p))) spec_ebadf)
116 #define spec_getattr ((int (*) __P(( \
117 		struct vnode *vp, \
118 		struct vattr *vap, \
119 		struct ucred *cred, \
120 		struct proc *p))) spec_ebadf)
121 #define spec_setattr ((int (*) __P(( \
122 		struct vnode *vp, \
123 		struct vattr *vap, \
124 		struct ucred *cred, \
125 		struct proc *p))) spec_ebadf)
126 int	spec_read __P((
127 		struct vnode *vp,
128 		struct uio *uio,
129 		int ioflag,
130 		struct ucred *cred));
131 int	spec_write __P((
132 		struct vnode *vp,
133 		struct uio *uio,
134 		int ioflag,
135 		struct ucred *cred));
136 int	spec_ioctl __P((
137 		struct vnode *vp,
138 		int command,
139 		caddr_t data,
140 		int fflag,
141 		struct ucred *cred,
142 		struct proc *p));
143 int	spec_select __P((
144 		struct vnode *vp,
145 		int which,
146 		int fflags,
147 		struct ucred *cred,
148 		struct proc *p));
149 #define spec_mmap ((int (*) __P(( \
150 		struct vnode *vp, \
151 		int fflags, \
152 		struct ucred *cred, \
153 		struct proc *p))) spec_badop)
154 #define spec_fsync ((int (*) __P(( \
155 		struct vnode *vp, \
156 		int fflags, \
157 		struct ucred *cred, \
158 		int waitfor, \
159 		struct proc *p))) nullop)
160 #define spec_seek ((int (*) __P(( \
161 		struct vnode *vp, \
162 		off_t oldoff, \
163 		off_t newoff, \
164 		struct ucred *cred))) spec_badop)
165 #define spec_remove ((int (*) __P(( \
166 		struct nameidata *ndp, \
167 		struct proc *p))) spec_badop)
168 #define spec_link ((int (*) __P(( \
169 		struct vnode *vp, \
170 		struct nameidata *ndp, \
171 		struct proc *p))) spec_badop)
172 #define spec_rename ((int (*) __P(( \
173 		struct nameidata *fndp, \
174 		struct nameidata *tdnp, \
175 		struct proc *p))) spec_badop)
176 #define spec_mkdir ((int (*) __P(( \
177 		struct nameidata *ndp, \
178 		struct vattr *vap, \
179 		struct proc *p))) spec_badop)
180 #define spec_rmdir ((int (*) __P(( \
181 		struct nameidata *ndp, \
182 		struct proc *p))) spec_badop)
183 #define spec_symlink ((int (*) __P(( \
184 		struct nameidata *ndp, \
185 		struct vattr *vap, \
186 		char *target, \
187 		struct proc *p))) spec_badop)
188 #define spec_readdir ((int (*) __P(( \
189 		struct vnode *vp, \
190 		struct uio *uio, \
191 		struct ucred *cred, \
192 		int *eofflagp, \
193 		u_int *cookies, \
194 		int ncookies))) spec_badop)
195 #define spec_readlink ((int (*) __P(( \
196 		struct vnode *vp, \
197 		struct uio *uio, \
198 		struct ucred *cred))) spec_badop)
199 #define spec_abortop ((int (*) __P(( \
200 		struct nameidata *ndp))) spec_badop)
201 #define spec_inactive ((int (*) __P(( \
202 		struct vnode *vp, \
203 		struct proc *p))) nullop)
204 #define spec_reclaim ((int (*) __P(( \
205 		struct vnode *vp))) nullop)
206 int	spec_lock __P((
207 		struct vnode *vp));
208 int	spec_unlock __P((
209 		struct vnode *vp));
210 int	spec_bmap __P((
211 		struct vnode *vp,
212 		daddr_t bn,
213 		struct vnode **vpp,
214 		daddr_t *bnp));
215 int	spec_strategy __P((
216 		struct buf *bp));
217 void	spec_print __P((
218 		struct vnode *vp));
219 #define spec_islocked ((int (*) __P(( \
220 		struct vnode *vp))) nullop)
221 int	spec_advlock __P((
222 		struct vnode *vp,
223 		caddr_t id,
224 		int op,
225 		struct flock *fl,
226 		int flags));
227 
228 #endif /* !_SYS_SPECDEV_H_ */
229