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