vndvar.h revision 1.8 1 /* $NetBSD: vndvar.h,v 1.8 2002/07/20 11:28:08 hannken Exp $ */
2
3 /*-
4 * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Jason R. Thorpe.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 /*
40 * Copyright (c) 1988 University of Utah.
41 * Copyright (c) 1990, 1993
42 * The Regents of the University of California. All rights reserved.
43 *
44 * This code is derived from software contributed to Berkeley by
45 * the Systems Programming Group of the University of Utah Computer
46 * Science Department.
47 *
48 * Redistribution and use in source and binary forms, with or without
49 * modification, are permitted provided that the following conditions
50 * are met:
51 * 1. Redistributions of source code must retain the above copyright
52 * notice, this list of conditions and the following disclaimer.
53 * 2. Redistributions in binary form must reproduce the above copyright
54 * notice, this list of conditions and the following disclaimer in the
55 * documentation and/or other materials provided with the distribution.
56 * 3. All advertising materials mentioning features or use of this software
57 * must display the following acknowledgement:
58 * This product includes software developed by the University of
59 * California, Berkeley and its contributors.
60 * 4. Neither the name of the University nor the names of its contributors
61 * may be used to endorse or promote products derived from this software
62 * without specific prior written permission.
63 *
64 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
65 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
66 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
67 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
68 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
69 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
70 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
71 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
72 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
73 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
74 * SUCH DAMAGE.
75 *
76 * from: Utah $Hdr: fdioctl.h 1.1 90/07/09$
77 *
78 * @(#)vnioctl.h 8.1 (Berkeley) 6/10/93
79 */
80
81 #include <sys/pool.h>
82
83 /*
84 * Vnode disk pseudo-geometry information.
85 */
86 struct vndgeom {
87 u_int32_t vng_secsize; /* # bytes per sector */
88 u_int32_t vng_nsectors; /* # data sectors per track */
89 u_int32_t vng_ntracks; /* # tracks per cylinder */
90 u_int32_t vng_ncylinders; /* # cylinders per unit */
91 };
92
93 /*
94 * Ioctl definitions for file (vnode) disk pseudo-device.
95 */
96 struct vnd_ioctl {
97 char *vnd_file; /* pathname of file to mount */
98 int vnd_flags; /* flags; see below */
99 struct vndgeom vnd_geom; /* geometry to emulate */
100 int vnd_size; /* (returned) size of disk */
101 };
102
103 /* vnd_flags */
104 #define VNDIOF_HASGEOM 0x01 /* use specified geometry */
105
106 #ifdef _KERNEL
107
108 struct vnode;
109 struct ucred;
110
111 /*
112 * A vnode disk's state information.
113 */
114 struct vnd_softc {
115 int sc_unit; /* logical unit number */
116 int sc_flags; /* flags */
117 size_t sc_size; /* size of vnd */
118 struct vnode *sc_vp; /* vnode */
119 struct ucred *sc_cred; /* credentials */
120 int sc_maxactive; /* max # of active requests */
121 struct bufq_state sc_tab; /* transfer queue */
122 int sc_active; /* number of active transfers */
123 char sc_xname[8]; /* XXX external name */
124 struct disk sc_dkdev; /* generic disk device info */
125 struct vndgeom sc_geom; /* virtual geometry */
126 struct pool sc_vxpool; /* vndxfer pool */
127 struct pool sc_vbpool; /* vndbuf pool */
128 };
129 #endif
130
131 /* sc_flags */
132 #define VNF_INITED 0x01 /* unit has been initialized */
133 #define VNF_WLABEL 0x02 /* label area is writable */
134 #define VNF_LABELLING 0x04 /* unit is currently being labelled */
135 #define VNF_WANTED 0x08 /* someone is waiting to obtain a lock */
136 #define VNF_LOCKED 0x10 /* unit is locked */
137 #define VNF_BUSY 0x20 /* unit is busy */
138
139 /*
140 * A simple structure for describing which vnd units are in use.
141 */
142 struct vnd_user {
143 int vnu_unit; /* which vnd unit */
144 dev_t vnu_dev; /* file is on this device... */
145 ino_t vnu_ino; /* ...at this inode */
146 };
147
148 /*
149 * Before you can use a unit, it must be configured with VNDIOCSET.
150 * The configuration persists across opens and closes of the device;
151 * an VNDIOCCLR must be used to reset a configuration. An attempt to
152 * VNDIOCSET an already active unit will return EBUSY.
153 */
154 #define VNDIOCSET _IOWR('F', 0, struct vnd_ioctl) /* enable disk */
155 #define VNDIOCCLR _IOW('F', 1, struct vnd_ioctl) /* disable disk */
156 #define VNDIOCGET _IOWR('F', 2, struct vnd_user) /* get list */
157