xref: /dragonfly/sys/dev/disk/dm/netbsd-dm.h (revision e98bdfd3)
1 /*        $NetBSD: netbsd-dm.h,v 1.6 2009/12/05 11:30:26 haad Exp $      */
2 
3 /*
4  * Copyright (c) 2008 The NetBSD Foundation, Inc.
5  * All rights reserved.
6  *
7  * This code is derived from software contributed to The NetBSD Foundation
8  * by Adam Hamsik.
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 #ifndef __NETBSD_DM_H__
33 #define __NETBSD_DM_H__
34 
35 #include <libprop/proplib.h>
36 
37 #define DM_IOCTL 0xfd
38 
39 #define DM_IOCTL_CMD 0
40 
41 #define NETBSD_DM_IOCTL       _IOWR(DM_IOCTL, DM_IOCTL_CMD, struct plistref)
42 
43 
44 /*
45  * DM-ioctl dictionary.
46  *
47  * This contains general information about dm device.
48  *
49  * <dict>
50  *     <key>command</key>
51  *     <string>...</string>
52  *
53  *     <key>event_nr</key>
54  *     <integer>...</integer>
55  *
56  *     <key>name</key>
57  *     <string>...</string>
58  *
59  *     <key>uuid</key>
60  *     <string>...</string>
61  *
62  *     <key>dev</key>
63  *     <integer></integer>
64  *
65  *     <key>flags</key>
66  *     <integer></integer>
67  *
68  *     <key>version</key>
69  *      <array>
70  *       <integer>...</integer>
71  *       <integer>...</integer>
72  *       <integer>...</integer>
73  *      </array>
74  *
75  *      <key>cmd_data</key>
76  *       <array>
77  *        <!-- See below for command
78  *             specific dictionaries -->
79  *       </array>
80  * </dict>
81  *
82  * Available commands from _cmd_data_v4.
83  *
84  * create, reload, remove, remove_all, suspend,
85  * resume, info, deps, rename, version, status,
86  * table, waitevent, names, clear, mknodes,
87  * targets, message, setgeometry
88  *
89  */
90 
91 /*
92  * DM_LIST_VERSIONS == "targets" command dictionary entry.
93  * Lists all available targets with their version.
94  *
95  * <array>
96  *   <dict>
97  *    <key>name<key>
98  *    <string>...</string>
99  *
100  *    <key>version</key>
101  *      <array>
102  *       <integer>...</integer>
103  *       <integer>...</integer>
104  *       <integer>...</integer>
105  *      </array>
106  *   </dict>
107  * </array>
108  *
109  */
110 
111 /*
112  * DM_DEV_LIST == "names"
113  * Request list of device-mapper created devices from kernel.
114  *
115  * <array>
116  *   <dict>
117  *    <key>name<key>
118  *    <string>...</string>
119  *
120  *    <key>dev</key>
121  *    <integer>...</integer>
122  *   </dict>
123  * </array>
124  *
125  * dev is uint64_t
126  *
127  */
128 
129  /*
130   * DM_DEV_RENAME == "rename"
131   * Rename device to string.
132   *
133   * <array>
134   *    <string>...</string>
135   * </array>
136   *
137   */
138 
139  /*
140   * DM_DEV_STATUS == "info, mknodes"
141   * Will change fields DM_IOCTL_OPEN, DM_IOCTL_DEV in received dictionary,
142   * with dm device values with name or uuid from list.
143   *
144   */
145 
146  /*
147   * DM_TABLE_STATUS == "status,table"
148   * Request list of device-mapper created devices from kernel.
149   *
150   * <array>
151   *   <dict>
152   *    <key>type<key>
153   *    <string>...</string>
154   *
155   *    <key>start</key>
156   *    <integer>...</integer>
157   *
158   *    <key>length</key>
159   *    <integer>...</integer>
160   *
161   *    <key>params</key>
162   *    <string>...</string>
163   *   </dict>
164   * </array>
165   *
166   * params is string which contains {device} {parameters}
167   *
168   */
169 
170  /*
171   * DM_TABLE_DEPS == "deps"
172   * Request list active table device dependiences.
173   *
174   * This command is also run to get dm-device
175   * dependiences for existing real block device.
176   *
177   * eg. vgcreate calls DM_TABLE_DEPS
178   *
179   * <array>
180   *   <integer>...</integer>
181   * </array>
182   *
183   */
184 
185 
186 #define DM_IOCTL_COMMAND      "command"
187 #define DM_IOCTL_VERSION      "version"
188 #define DM_IOCTL_OPEN         "open_count"
189 #define DM_IOCTL_MINOR        "minor"
190 #define DM_IOCTL_NAME         "name"
191 #define DM_IOCTL_UUID         "uuid"
192 #define DM_IOCTL_TARGET_COUNT "target_count"
193 #define DM_IOCTL_EVENT        "event_nr"
194 #define DM_IOCTL_FLAGS        "flags"
195 #define DM_IOCTL_CMD_DATA     "cmd_data"
196 
197 #define DM_TARGETS_NAME       "name"
198 #define DM_TARGETS_VERSION    "ver"
199 
200 #define DM_DEV_NEWNAME        "newname"
201 #define DM_DEV_NAME           "name"
202 #define DM_DEV_DEV            "dev"
203 #define DM_DEV_UID            "uid"
204 #define DM_DEV_GID            "gid"
205 #define DM_DEV_MODE           "mode"
206 
207 #define DM_TABLE_TYPE         "type"
208 #define DM_TABLE_START        "start"
209 #define DM_TABLE_STAT         "status"
210 #define DM_TABLE_LENGTH       "length"
211 #define DM_TABLE_PARAMS       "params"
212 
213 #define DM_MESSAGE_SECTOR     "sector"
214 #define DM_MESSAGE_STR        "message"
215 
216 
217 /* Status bits */
218 /* IO mode of device */
219 #define DM_READONLY_FLAG	(1 << 0) /* In/Out *//* to kernel/from kernel */
220 #define DM_SUSPEND_FLAG		(1 << 1) /* In/Out */
221 /* XXX. This flag is undocumented. */
222 #define DM_EXISTS_FLAG          (1 << 2) /* In/Out */
223 /* Minor number is persistent */
224 #define DM_PERSISTENT_DEV_FLAG	(1 << 3) /* In */
225 
226 /*
227  * Flag passed into ioctl STATUS command to get table information
228  * rather than current status.
229  */
230 #define DM_STATUS_TABLE_FLAG	(1 << 4) /* In */
231 
232 /*
233  * Flags that indicate whether a table is present in either of
234  * the two table slots that a device has.
235  */
236 #define DM_ACTIVE_PRESENT_FLAG   (1 << 5) /* Out */
237 #define DM_INACTIVE_PRESENT_FLAG (1 << 6) /* Out */
238 
239 /*
240  * Indicates that the buffer passed in wasn't big enough for the
241  * results.
242  */
243 #define DM_BUFFER_FULL_FLAG	(1 << 8) /* Out */
244 
245 /*
246  * This flag is now ignored.
247  */
248 #define DM_SKIP_BDGET_FLAG	(1 << 9) /* In */
249 
250 /*
251  * Set this to avoid attempting to freeze any filesystem when suspending.
252  */
253 #define DM_SKIP_LOCKFS_FLAG	(1 << 10) /* In */
254 
255 /*
256  * Set this to suspend without flushing queued ios.
257  */
258 #define DM_NOFLUSH_FLAG		(1 << 11) /* In */
259 
260 /*
261  * If set, any table information returned will relate to the inactive
262  * table instead of the live one.  Always check DM_INACTIVE_PRESENT_FLAG
263  * is set before using the data returned.
264  */
265 #define DM_QUERY_INACTIVE_TABLE_FLAG    (1 << 12) /* In */
266 
267 /*
268  * If set, a rename affects the UUID instead of the name. Only valid
269  * if the UUID was empty before.
270  */
271 #define DM_UUID_FLAG		(1 << 14) /* In */
272 
273 /*
274  * Set this flag for the ioctl buffers to be wiped.
275  */
276 #define DM_SECURE_DATA_FLAG	(1 << 15) /* In */
277 
278 #endif /* __NETBSD_DM_H__ */
279