vndvar.h revision 1.4 1 /* $NetBSD: vndvar.h,v 1.4 1998/07/31 02:24:26 thorpej 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 struct vnode;
107 struct ucred;
108
109 /*
110 * A vnode disk's state information.
111 */
112 struct vnd_softc {
113 int sc_unit; /* logical unit number */
114 int sc_flags; /* flags */
115 size_t sc_size; /* size of vnd */
116 struct vnode *sc_vp; /* vnode */
117 struct ucred *sc_cred; /* credentials */
118 int sc_maxactive; /* max # of active requests */
119 struct buf sc_tab; /* transfer queue */
120 char sc_xname[8]; /* XXX external name */
121 struct disk sc_dkdev; /* generic disk device info */
122 struct vndgeom sc_geom; /* virtual geometry */
123 struct pool sc_vxpool; /* vndxfer pool */
124 struct pool sc_vbpool; /* vndbuf pool */
125 };
126
127 /* sc_flags */
128 #define VNF_INITED 0x01 /* unit has been initialized */
129 #define VNF_WLABEL 0x02 /* label area is writable */
130 #define VNF_LABELLING 0x04 /* unit is currently being labelled */
131 #define VNF_WANTED 0x08 /* someone is waiting to obtain a lock */
132 #define VNF_LOCKED 0x10 /* unit is locked */
133 #define VNF_BUSY 0x20 /* unit is busy */
134
135 /*
136 * Before you can use a unit, it must be configured with VNDIOCSET.
137 * The configuration persists across opens and closes of the device;
138 * an VNDIOCCLR must be used to reset a configuration. An attempt to
139 * VNDIOCSET an already active unit will return EBUSY.
140 */
141 #define VNDIOCSET _IOWR('F', 0, struct vnd_ioctl) /* enable disk */
142 #define VNDIOCCLR _IOW('F', 1, struct vnd_ioctl) /* disable disk */
143