1/* $OpenBSD: specdev.h,v 1.41 2022/06/26 05:20:42 visa 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
35SLIST_HEAD(vnodechain, vnode);
36
37/*
38 * This structure defines the information maintained about
39 * special devices. It is allocated in checkalias and freed
40 * in vgone.
41 */
42struct specinfo {
43 struct vnodechain *si_hashchain;
44 SLIST_ENTRY(vnode) si_specnext;
45 struct mount *si_mountpoint;
46 dev_t si_rdev;
47 struct lockf_state *si_lockf;
48 daddr_t si_lastr;
49 union {
50 struct vnode *ci_parent; /* pointer back to parent device */
51 u_int8_t *ci_bitmap; /* bitmap of devices cloned off us */
52 } si_ci;
53};
54
55struct cloneinfo {
56 struct vnode *ci_vp; /* cloned vnode */
57 void *ci_data; /* original vnode's v_data */
58};
59
60/*
61 * Exported shorthand
62 */
63#define v_rdev v_specinfo->si_rdev
64#define v_hashchain v_specinfo->si_hashchain
65#define v_specnext v_specinfo->si_specnext
66#define v_specmountpoint v_specinfo->si_mountpoint
67#define v_speclockf v_specinfo->si_lockf
68#define v_specparent v_specinfo->si_ci.ci_parent
69#define v_specbitmap v_specinfo->si_ci.ci_bitmap
70
71/*
72 * We use the upper 16 bits of the minor to record the clone instance.
73 * This gives us 8 bits for encoding the real minor number.
74 */
75#define CLONE_SHIFT 8
76#define CLONE_MAPSZ 128
77
78/*
79 * Special device management
80 */
81#define SPECHSZ 64
82#if ((SPECHSZ&(SPECHSZ-1)) == 0)
83#define SPECHASH(rdev) (((rdev>>5)+(rdev))&(SPECHSZ-1))
84#else
85#define SPECHASH(rdev) (((unsigned)((rdev>>5)+(rdev)))%SPECHSZ)
86#endif
87
88#ifdef _KERNEL
89
90extern struct vnodechain speclisth[SPECHSZ];
91
92/*
93 * Prototypes for special file operations on vnodes.
94 */
95int spec_getattr(void *);
96int spec_setattr(void *);
97int spec_access(void *);
98int spec_open(void *);
99int spec_close(void *);
100int spec_read(void *);
101int spec_write(void *);
102int spec_ioctl(void *);
103int spec_kqfilter(void *);
104int spec_fsync(void *);
105int spec_inactive(void *);
106int spec_strategy(void *);
107int spec_print(void *);
108int spec_pathconf(void *);
109int spec_advlock(void *);
110
111#endif /* _KERNEL */