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