1 /* $OpenBSD: specdev.h,v 1.20 2007/06/02 00:45:21 thib Exp $ */
2 /* $NetBSD: specdev.h,v 1.12 1996/02/13 13:13:01 mycroft Exp $ */
3
4 /*
5 * Copyright (c) 1990, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 *
32 * @(#)specdev.h 8.3 (Berkeley) 8/10/94
33 */
34
35 /*
36 * This structure defines the information maintained about
37 * special devices. It is allocated in checkalias and freed
38 * in vgone.
39 */
40 struct specinfo {
41 struct vnode **si_hashchain;
42 struct vnode *si_specnext;
43 struct mount *si_mountpoint;
44 dev_t si_rdev;
45 struct lockf *si_lockf;
46 daddr64_t si_lastr;
47 union {
48 struct vnode *ci_parent; /* pointer back to parent device */
49 u_int8_t ci_bitmap[8]; /* bitmap of devices cloned off us */
50 } si_ci;
51 };
52
53 struct cloneinfo {
54 struct vnode *ci_vp; /* cloned vnode */
55 void *ci_data; /* original vnode's v_data */
56 };
57
58 /*
59 * Exported shorthand
60 */
61 #define v_rdev v_specinfo->si_rdev
62 #define v_hashchain v_specinfo->si_hashchain
63 #define v_specnext v_specinfo->si_specnext
64 #define v_specmountpoint v_specinfo->si_mountpoint
65 #define v_speclockf v_specinfo->si_lockf
66 #define v_specparent v_specinfo->si_ci.ci_parent
67 #define v_specbitmap v_specinfo->si_ci.ci_bitmap
68
69 /*
70 * Special device management
71 */
72 #define SPECHSZ 64
73 #if ((SPECHSZ&(SPECHSZ-1)) == 0)
74 #define SPECHASH(rdev) (((rdev>>5)+(rdev))&(SPECHSZ-1))
75 #else
76 #define SPECHASH(rdev) (((unsigned)((rdev>>5)+(rdev)))%SPECHSZ)
77 #endif
78
79 extern struct vnode *speclisth[SPECHSZ];
80
81 /*
82 * Prototypes for special file operations on vnodes.
83 */
84 extern int (**spec_vnodeop_p)(void *);
85 struct nameidata;
86 struct componentname;
87 struct ucred;
88 struct flock;
89 struct buf;
90 struct uio;
91
92 int spec_badop(void *);
93 int spec_ebadf(void *);
94
95 int spec_lookup(void *);
96 #define spec_create spec_badop
97 #define spec_mknod spec_badop
98 int spec_open(void *);
99 int spec_close(void *);
100 #define spec_access spec_ebadf
101 #define spec_getattr spec_ebadf
102 #define spec_setattr spec_ebadf
103 int spec_read(void *);
104 int spec_write(void *);
105 int spec_ioctl(void *);
106 int spec_poll(void *);
107 int spec_kqfilter(void *);
108 int spec_fsync(void *);
109 #define spec_remove spec_badop
110 #define spec_link spec_badop
111 #define spec_rename spec_badop
112 #define spec_mkdir spec_badop
113 #define spec_rmdir spec_badop
114 #define spec_symlink spec_badop
115 #define spec_readdir spec_badop
116 #define spec_readlink spec_badop
117 #define spec_abortop spec_badop
118 int spec_inactive(void *);
119 #define spec_reclaim nullop
120 #define spec_lock vop_generic_lock
121 #define spec_unlock vop_generic_unlock
122 #define spec_islocked vop_generic_islocked
123 int spec_bmap(void *);
124 int spec_strategy(void *);
125 int spec_print(void *);
126 int spec_pathconf(void *);
127 int spec_advlock(void *);
128 #define spec_reallocblks spec_badop
129 #define spec_bwrite vop_generic_bwrite
130 #define spec_revoke vop_generic_revoke
131
132 int spec_vnoperate(void *);
133
134 /* spec_subr.c */
135 int spec_open_clone(struct vop_open_args *);
136 int spec_close_clone(struct vop_close_args *);