1 | /* $NetBSD: vndvar.h,v 1.35 2015/09/06 06:00:59 dholland 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 | * |
19 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
20 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
21 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
22 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
23 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ |
31 | |
32 | /* |
33 | * Copyright (c) 1988 University of Utah. |
34 | * Copyright (c) 1990, 1993 |
35 | * The Regents of the University of California. All rights reserved. |
36 | * |
37 | * This code is derived from software contributed to Berkeley by |
38 | * the Systems Programming Group of the University of Utah Computer |
39 | * Science Department. |
40 | * |
41 | * Redistribution and use in source and binary forms, with or without |
42 | * modification, are permitted provided that the following conditions |
43 | * are met: |
44 | * 1. Redistributions of source code must retain the above copyright |
45 | * notice, this list of conditions and the following disclaimer. |
46 | * 2. Redistributions in binary form must reproduce the above copyright |
47 | * notice, this list of conditions and the following disclaimer in the |
48 | * documentation and/or other materials provided with the distribution. |
49 | * 3. Neither the name of the University nor the names of its contributors |
50 | * may be used to endorse or promote products derived from this software |
51 | * without specific prior written permission. |
52 | * |
53 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
54 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
55 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
56 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
57 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
58 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
59 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
60 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
61 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
62 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
63 | * SUCH DAMAGE. |
64 | * |
65 | * from: Utah $Hdr: fdioctl.h 1.1 90/07/09$ |
66 | * |
67 | * @(#)vnioctl.h 8.1 (Berkeley) 6/10/93 |
68 | */ |
69 | |
70 | #ifndef _SYS_DEV_VNDVAR_H_ |
71 | #define _SYS_DEV_VNDVAR_H_ |
72 | |
73 | #include <sys/ioccom.h> |
74 | #include <sys/pool.h> |
75 | |
76 | /* |
77 | * Vnode disk pseudo-geometry information. |
78 | */ |
79 | struct vndgeom { |
80 | u_int32_t vng_secsize; /* # bytes per sector */ |
81 | u_int32_t vng_nsectors; /* # data sectors per track */ |
82 | u_int32_t vng_ntracks; /* # tracks per cylinder */ |
83 | u_int32_t vng_ncylinders; /* # cylinders per unit */ |
84 | }; |
85 | |
86 | /* |
87 | * Ioctl definitions for file (vnode) disk pseudo-device. |
88 | */ |
89 | struct vnd_ioctl { |
90 | char *vnd_file; /* pathname of file to mount */ |
91 | int vnd_flags; /* flags; see below */ |
92 | struct vndgeom vnd_geom; /* geometry to emulate */ |
93 | unsigned int vnd_osize; /* (returned) size of disk */ |
94 | uint64_t vnd_size; /* (returned) size of disk */ |
95 | }; |
96 | |
97 | /* vnd_flags */ |
98 | #define VNDIOF_HASGEOM 0x01 /* use specified geometry */ |
99 | #define VNDIOF_READONLY 0x02 /* as read-only device */ |
100 | #define VNDIOF_FORCE 0x04 /* force close */ |
101 | |
102 | #ifdef _KERNEL |
103 | |
104 | struct vnode; |
105 | |
106 | /* |
107 | * A vnode disk's state information. |
108 | */ |
109 | struct vnd_softc { |
110 | device_t sc_dev; |
111 | int sc_flags; /* flags */ |
112 | uint64_t sc_size; /* size of vnd */ |
113 | struct vnode *sc_vp; /* vnode */ |
114 | kauth_cred_t sc_cred; /* credentials */ |
115 | int sc_maxactive; /* max # of active requests */ |
116 | struct bufq_state *sc_tab; /* transfer queue */ |
117 | int sc_pending; /* number of pending transfers */ |
118 | int sc_active; /* number of active transfers */ |
119 | struct disk sc_dkdev; /* generic disk device info */ |
120 | struct vndgeom sc_geom; /* virtual geometry */ |
121 | struct pool sc_vxpool; /* vndxfer pool */ |
122 | struct pool sc_vbpool; /* vndbuf pool */ |
123 | struct lwp *sc_kthread; /* kernel thread */ |
124 | u_int32_t sc_comp_blksz; /* precompressed block size */ |
125 | u_int32_t sc_comp_numoffs;/* count of compressed block offsets */ |
126 | u_int64_t *sc_comp_offsets;/* file idx's to compressed blocks */ |
127 | unsigned char *sc_comp_buff; /* compressed data buffer */ |
128 | unsigned char *sc_comp_decombuf;/* decompressed data buffer */ |
129 | int32_t sc_comp_buffblk;/*current decompressed block */ |
130 | z_stream sc_comp_stream;/* decompress descriptor */ |
131 | }; |
132 | #endif |
133 | |
134 | /* sc_flags */ |
135 | #define VNF_INITED 0x001 /* unit has been initialized */ |
136 | #define VNF_WLABEL 0x002 /* label area is writable */ |
137 | #define VNF_LABELLING 0x004 /* unit is currently being labelled */ |
138 | #define VNF_WANTED 0x008 /* someone is waiting to obtain a lock */ |
139 | #define VNF_LOCKED 0x010 /* unit is locked */ |
140 | #define VNF_READONLY 0x020 /* unit is read-only */ |
141 | #define VNF_KLABEL 0x040 /* keep label on close */ |
142 | #define VNF_VLABEL 0x080 /* label is valid */ |
143 | #define VNF_KTHREAD 0x100 /* thread is running */ |
144 | #define VNF_VUNCONF 0x200 /* device is unconfiguring */ |
145 | #define VNF_COMP 0x400 /* file is compressed */ |
146 | #define VNF_CLEARING 0x800 /* unit is being torn down */ |
147 | #define VNF_USE_VN_RDWR 0x1000 /* have to use vn_rdwr() */ |
148 | |
149 | /* structure of header in a compressed file */ |
150 | struct |
151 | { |
152 | char [128]; |
153 | u_int32_t ; |
154 | u_int32_t ; |
155 | }; |
156 | |
157 | /* |
158 | * A simple structure for describing which vnd units are in use. |
159 | */ |
160 | |
161 | struct vnd_user { |
162 | int vnu_unit; /* which vnd unit */ |
163 | dev_t vnu_dev; /* file is on this device... */ |
164 | ino_t vnu_ino; /* ...at this inode */ |
165 | }; |
166 | |
167 | /* |
168 | * Before you can use a unit, it must be configured with VNDIOCSET. |
169 | * The configuration persists across opens and closes of the device; |
170 | * an VNDIOCCLR must be used to reset a configuration. An attempt to |
171 | * VNDIOCSET an already active unit will return EBUSY. |
172 | */ |
173 | #define VNDIOCSET _IOWR('F', 0, struct vnd_ioctl) /* enable disk */ |
174 | #define VNDIOCCLR _IOW('F', 1, struct vnd_ioctl) /* disable disk */ |
175 | #define VNDIOCGET _IOWR('F', 3, struct vnd_user) /* get list */ |
176 | |
177 | #ifdef _KERNEL |
178 | /* |
179 | * Everything else is kernel-private, mostly exported for compat/netbsd32. |
180 | * |
181 | * NetBSD 3.0 had a 32-bit value for vnu_ino. |
182 | * |
183 | * NetBSD 5.0 had a 32-bit value for vnu_dev, and vnd_size. |
184 | */ |
185 | struct vnd_user30 { |
186 | int vnu_unit; /* which vnd unit */ |
187 | uint32_t vnu_dev; /* file is on this device... */ |
188 | uint32_t vnu_ino; /* ...at this inode */ |
189 | }; |
190 | #define VNDIOCGET30 _IOWR('F', 2, struct vnd_user30) /* get list */ |
191 | |
192 | struct vnd_user50 { |
193 | int vnu_unit; /* which vnd unit */ |
194 | uint32_t vnu_dev; /* file is on this device... */ |
195 | ino_t vnu_ino; /* ...at this inode */ |
196 | }; |
197 | #define VNDIOCGET50 _IOWR('F', 3, struct vnd_user50) /* get list */ |
198 | |
199 | struct vnd_ioctl50 { |
200 | char *vnd_file; /* pathname of file to mount */ |
201 | int vnd_flags; /* flags; see below */ |
202 | struct vndgeom vnd_geom; /* geometry to emulate */ |
203 | unsigned int vnd_size; /* (returned) size of disk */ |
204 | }; |
205 | #define VNDIOCSET50 _IOWR('F', 0, struct vnd_ioctl50) |
206 | #define VNDIOCCLR50 _IOW('F', 1, struct vnd_ioctl50) |
207 | |
208 | #endif /* _KERNEL */ |
209 | |
210 | #endif /* _SYS_DEV_VNDVAR_H_ */ |
211 | |