specdev.h revision 1.2 1 1.1 cgd /*
2 1.1 cgd * Copyright (c) 1990 The Regents of the University of California.
3 1.1 cgd * All rights reserved.
4 1.1 cgd *
5 1.1 cgd * Redistribution and use in source and binary forms, with or without
6 1.1 cgd * modification, are permitted provided that the following conditions
7 1.1 cgd * are met:
8 1.1 cgd * 1. Redistributions of source code must retain the above copyright
9 1.1 cgd * notice, this list of conditions and the following disclaimer.
10 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
11 1.1 cgd * notice, this list of conditions and the following disclaimer in the
12 1.1 cgd * documentation and/or other materials provided with the distribution.
13 1.1 cgd * 3. All advertising materials mentioning features or use of this software
14 1.1 cgd * must display the following acknowledgement:
15 1.1 cgd * This product includes software developed by the University of
16 1.1 cgd * California, Berkeley and its contributors.
17 1.1 cgd * 4. Neither the name of the University nor the names of its contributors
18 1.1 cgd * may be used to endorse or promote products derived from this software
19 1.1 cgd * without specific prior written permission.
20 1.1 cgd *
21 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 1.1 cgd * SUCH DAMAGE.
32 1.1 cgd *
33 1.1 cgd * @(#)specdev.h 7.4 (Berkeley) 4/19/91
34 1.1 cgd */
35 1.1 cgd
36 1.2 mycroft #ifndef _SYS_SPECDEV_H_
37 1.2 mycroft #define _SYS_SPECDEV_H_
38 1.2 mycroft
39 1.1 cgd /*
40 1.1 cgd * This structure defines the information maintained about
41 1.1 cgd * special devices. It is allocated in checkalias and freed
42 1.1 cgd * in vgone.
43 1.1 cgd */
44 1.1 cgd struct specinfo {
45 1.1 cgd struct vnode **si_hashchain;
46 1.1 cgd struct vnode *si_specnext;
47 1.1 cgd long si_flags;
48 1.1 cgd dev_t si_rdev;
49 1.1 cgd };
50 1.1 cgd /*
51 1.1 cgd * Exported shorthand
52 1.1 cgd */
53 1.1 cgd #define v_rdev v_specinfo->si_rdev
54 1.1 cgd #define v_hashchain v_specinfo->si_hashchain
55 1.1 cgd #define v_specnext v_specinfo->si_specnext
56 1.1 cgd #define v_specflags v_specinfo->si_flags
57 1.1 cgd
58 1.1 cgd /*
59 1.1 cgd * Flags for specinfo
60 1.1 cgd */
61 1.1 cgd #define SI_MOUNTEDON 0x0001 /* block special device is mounted on */
62 1.1 cgd
63 1.1 cgd /*
64 1.1 cgd * Special device management
65 1.1 cgd */
66 1.1 cgd #define SPECHSZ 64
67 1.1 cgd #if ((SPECHSZ&(SPECHSZ-1)) == 0)
68 1.1 cgd #define SPECHASH(rdev) (((rdev>>5)+(rdev))&(SPECHSZ-1))
69 1.1 cgd #else
70 1.1 cgd #define SPECHASH(rdev) (((unsigned)((rdev>>5)+(rdev)))%SPECHSZ)
71 1.1 cgd #endif
72 1.1 cgd
73 1.1 cgd struct vnode *speclisth[SPECHSZ];
74 1.1 cgd
75 1.1 cgd /*
76 1.1 cgd * Prototypes for special file operations on vnodes.
77 1.1 cgd */
78 1.1 cgd struct nameidata;
79 1.1 cgd struct ucred;
80 1.1 cgd struct flock;
81 1.1 cgd struct buf;
82 1.1 cgd struct uio;
83 1.1 cgd
84 1.1 cgd int spec_badop(),
85 1.1 cgd spec_ebadf();
86 1.1 cgd
87 1.1 cgd int spec_lookup __P((
88 1.1 cgd struct vnode *vp,
89 1.1 cgd struct nameidata *ndp,
90 1.1 cgd struct proc *p));
91 1.1 cgd #define spec_create ((int (*) __P(( \
92 1.1 cgd struct nameidata *ndp, \
93 1.1 cgd struct vattr *vap, \
94 1.1 cgd struct proc *p))) spec_badop)
95 1.1 cgd #define spec_mknod ((int (*) __P(( \
96 1.1 cgd struct nameidata *ndp, \
97 1.1 cgd struct vattr *vap, \
98 1.1 cgd struct ucred *cred, \
99 1.1 cgd struct proc *p))) spec_badop)
100 1.1 cgd int spec_open __P((
101 1.1 cgd struct vnode *vp,
102 1.1 cgd int mode,
103 1.1 cgd struct ucred *cred,
104 1.1 cgd struct proc *p));
105 1.1 cgd int spec_close __P((
106 1.1 cgd struct vnode *vp,
107 1.1 cgd int fflag,
108 1.1 cgd struct ucred *cred,
109 1.1 cgd struct proc *p));
110 1.1 cgd #define spec_access ((int (*) __P(( \
111 1.1 cgd struct vnode *vp, \
112 1.1 cgd int mode, \
113 1.1 cgd struct ucred *cred, \
114 1.1 cgd struct proc *p))) spec_ebadf)
115 1.1 cgd #define spec_getattr ((int (*) __P(( \
116 1.1 cgd struct vnode *vp, \
117 1.1 cgd struct vattr *vap, \
118 1.1 cgd struct ucred *cred, \
119 1.1 cgd struct proc *p))) spec_ebadf)
120 1.1 cgd #define spec_setattr ((int (*) __P(( \
121 1.1 cgd struct vnode *vp, \
122 1.1 cgd struct vattr *vap, \
123 1.1 cgd struct ucred *cred, \
124 1.1 cgd struct proc *p))) spec_ebadf)
125 1.1 cgd int spec_read __P((
126 1.1 cgd struct vnode *vp,
127 1.1 cgd struct uio *uio,
128 1.1 cgd int ioflag,
129 1.1 cgd struct ucred *cred));
130 1.1 cgd int spec_write __P((
131 1.1 cgd struct vnode *vp,
132 1.1 cgd struct uio *uio,
133 1.1 cgd int ioflag,
134 1.1 cgd struct ucred *cred));
135 1.1 cgd int spec_ioctl __P((
136 1.1 cgd struct vnode *vp,
137 1.1 cgd int command,
138 1.1 cgd caddr_t data,
139 1.1 cgd int fflag,
140 1.1 cgd struct ucred *cred,
141 1.1 cgd struct proc *p));
142 1.1 cgd int spec_select __P((
143 1.1 cgd struct vnode *vp,
144 1.1 cgd int which,
145 1.1 cgd int fflags,
146 1.1 cgd struct ucred *cred,
147 1.1 cgd struct proc *p));
148 1.1 cgd #define spec_mmap ((int (*) __P(( \
149 1.1 cgd struct vnode *vp, \
150 1.1 cgd int fflags, \
151 1.1 cgd struct ucred *cred, \
152 1.1 cgd struct proc *p))) spec_badop)
153 1.1 cgd #define spec_fsync ((int (*) __P(( \
154 1.1 cgd struct vnode *vp, \
155 1.1 cgd int fflags, \
156 1.1 cgd struct ucred *cred, \
157 1.1 cgd int waitfor, \
158 1.1 cgd struct proc *p))) nullop)
159 1.1 cgd #define spec_seek ((int (*) __P(( \
160 1.1 cgd struct vnode *vp, \
161 1.1 cgd off_t oldoff, \
162 1.1 cgd off_t newoff, \
163 1.1 cgd struct ucred *cred))) spec_badop)
164 1.1 cgd #define spec_remove ((int (*) __P(( \
165 1.1 cgd struct nameidata *ndp, \
166 1.1 cgd struct proc *p))) spec_badop)
167 1.1 cgd #define spec_link ((int (*) __P(( \
168 1.1 cgd struct vnode *vp, \
169 1.1 cgd struct nameidata *ndp, \
170 1.1 cgd struct proc *p))) spec_badop)
171 1.1 cgd #define spec_rename ((int (*) __P(( \
172 1.1 cgd struct nameidata *fndp, \
173 1.1 cgd struct nameidata *tdnp, \
174 1.1 cgd struct proc *p))) spec_badop)
175 1.1 cgd #define spec_mkdir ((int (*) __P(( \
176 1.1 cgd struct nameidata *ndp, \
177 1.1 cgd struct vattr *vap, \
178 1.1 cgd struct proc *p))) spec_badop)
179 1.1 cgd #define spec_rmdir ((int (*) __P(( \
180 1.1 cgd struct nameidata *ndp, \
181 1.1 cgd struct proc *p))) spec_badop)
182 1.1 cgd #define spec_symlink ((int (*) __P(( \
183 1.1 cgd struct nameidata *ndp, \
184 1.1 cgd struct vattr *vap, \
185 1.1 cgd char *target, \
186 1.1 cgd struct proc *p))) spec_badop)
187 1.1 cgd #define spec_readdir ((int (*) __P(( \
188 1.1 cgd struct vnode *vp, \
189 1.1 cgd struct uio *uio, \
190 1.1 cgd struct ucred *cred, \
191 1.1 cgd int *eofflagp))) spec_badop)
192 1.1 cgd #define spec_readlink ((int (*) __P(( \
193 1.1 cgd struct vnode *vp, \
194 1.1 cgd struct uio *uio, \
195 1.1 cgd struct ucred *cred))) spec_badop)
196 1.1 cgd #define spec_abortop ((int (*) __P(( \
197 1.1 cgd struct nameidata *ndp))) spec_badop)
198 1.1 cgd #define spec_inactive ((int (*) __P(( \
199 1.1 cgd struct vnode *vp, \
200 1.1 cgd struct proc *p))) nullop)
201 1.1 cgd #define spec_reclaim ((int (*) __P(( \
202 1.1 cgd struct vnode *vp))) nullop)
203 1.1 cgd int spec_lock __P((
204 1.1 cgd struct vnode *vp));
205 1.1 cgd int spec_unlock __P((
206 1.1 cgd struct vnode *vp));
207 1.1 cgd int spec_bmap __P((
208 1.1 cgd struct vnode *vp,
209 1.1 cgd daddr_t bn,
210 1.1 cgd struct vnode **vpp,
211 1.1 cgd daddr_t *bnp));
212 1.1 cgd int spec_strategy __P((
213 1.1 cgd struct buf *bp));
214 1.1 cgd int spec_print __P((
215 1.1 cgd struct vnode *vp));
216 1.1 cgd #define spec_islocked ((int (*) __P(( \
217 1.1 cgd struct vnode *vp))) nullop)
218 1.1 cgd int spec_advlock __P((
219 1.1 cgd struct vnode *vp,
220 1.1 cgd caddr_t id,
221 1.1 cgd int op,
222 1.1 cgd struct flock *fl,
223 1.1 cgd int flags));
224 1.2 mycroft
225 1.2 mycroft #endif /* !_SYS_SPECDEV_H_ */
226