dm-ioctl.h revision 1.1.1.2 1 1.1 haad /* $NetBSD: dm-ioctl.h,v 1.1.1.2 2009/12/02 00:26:09 haad Exp $ */
2 1.1 haad
3 1.1 haad /*
4 1.1 haad * Copyright (C) 2001 - 2003 Sistina Software (UK) Limited.
5 1.1.1.2 haad * Copyright (C) 2004 - 2009 Red Hat, Inc. All rights reserved.
6 1.1 haad *
7 1.1 haad * This file is released under the LGPL.
8 1.1 haad */
9 1.1 haad
10 1.1 haad #ifndef _LINUX_DM_IOCTL_V4_H
11 1.1 haad #define _LINUX_DM_IOCTL_V4_H
12 1.1 haad
13 1.1 haad #ifdef linux
14 1.1 haad # include <linux/types.h>
15 1.1 haad #endif
16 1.1 haad
17 1.1 haad #define DM_DIR "mapper" /* Slashes not supported */
18 1.1 haad #define DM_MAX_TYPE_NAME 16
19 1.1 haad #define DM_NAME_LEN 128
20 1.1 haad #define DM_UUID_LEN 129
21 1.1 haad
22 1.1 haad /*
23 1.1 haad * A traditional ioctl interface for the device mapper.
24 1.1 haad *
25 1.1 haad * Each device can have two tables associated with it, an
26 1.1 haad * 'active' table which is the one currently used by io passing
27 1.1 haad * through the device, and an 'inactive' one which is a table
28 1.1 haad * that is being prepared as a replacement for the 'active' one.
29 1.1 haad *
30 1.1 haad * DM_VERSION:
31 1.1 haad * Just get the version information for the ioctl interface.
32 1.1 haad *
33 1.1 haad * DM_REMOVE_ALL:
34 1.1 haad * Remove all dm devices, destroy all tables. Only really used
35 1.1 haad * for debug.
36 1.1 haad *
37 1.1 haad * DM_LIST_DEVICES:
38 1.1 haad * Get a list of all the dm device names.
39 1.1 haad *
40 1.1 haad * DM_DEV_CREATE:
41 1.1 haad * Create a new device, neither the 'active' or 'inactive' table
42 1.1 haad * slots will be filled. The device will be in suspended state
43 1.1 haad * after creation, however any io to the device will get errored
44 1.1 haad * since it will be out-of-bounds.
45 1.1 haad *
46 1.1 haad * DM_DEV_REMOVE:
47 1.1 haad * Remove a device, destroy any tables.
48 1.1 haad *
49 1.1 haad * DM_DEV_RENAME:
50 1.1 haad * Rename a device.
51 1.1 haad *
52 1.1 haad * DM_SUSPEND:
53 1.1 haad * This performs both suspend and resume, depending which flag is
54 1.1 haad * passed in.
55 1.1 haad * Suspend: This command will not return until all pending io to
56 1.1 haad * the device has completed. Further io will be deferred until
57 1.1 haad * the device is resumed.
58 1.1 haad * Resume: It is no longer an error to issue this command on an
59 1.1 haad * unsuspended device. If a table is present in the 'inactive'
60 1.1 haad * slot, it will be moved to the active slot, then the old table
61 1.1 haad * from the active slot will be _destroyed_. Finally the device
62 1.1 haad * is resumed.
63 1.1 haad *
64 1.1 haad * DM_DEV_STATUS:
65 1.1 haad * Retrieves the status for the table in the 'active' slot.
66 1.1 haad *
67 1.1 haad * DM_DEV_WAIT:
68 1.1 haad * Wait for a significant event to occur to the device. This
69 1.1 haad * could either be caused by an event triggered by one of the
70 1.1 haad * targets of the table in the 'active' slot, or a table change.
71 1.1 haad *
72 1.1 haad * DM_TABLE_LOAD:
73 1.1 haad * Load a table into the 'inactive' slot for the device. The
74 1.1 haad * device does _not_ need to be suspended prior to this command.
75 1.1 haad *
76 1.1 haad * DM_TABLE_CLEAR:
77 1.1 haad * Destroy any table in the 'inactive' slot (ie. abort).
78 1.1 haad *
79 1.1 haad * DM_TABLE_DEPS:
80 1.1 haad * Return a set of device dependencies for the 'active' table.
81 1.1 haad *
82 1.1 haad * DM_TABLE_STATUS:
83 1.1 haad * Return the targets status for the 'active' table.
84 1.1 haad *
85 1.1 haad * DM_TARGET_MSG:
86 1.1 haad * Pass a message string to the target at a specific offset of a device.
87 1.1 haad *
88 1.1 haad * DM_DEV_SET_GEOMETRY:
89 1.1 haad * Set the geometry of a device by passing in a string in this format:
90 1.1 haad *
91 1.1 haad * "cylinders heads sectors_per_track start_sector"
92 1.1 haad *
93 1.1 haad * Beware that CHS geometry is nearly obsolete and only provided
94 1.1 haad * for compatibility with dm devices that can be booted by a PC
95 1.1 haad * BIOS. See struct hd_geometry for range limits. Also note that
96 1.1 haad * the geometry is erased if the device size changes.
97 1.1 haad */
98 1.1 haad
99 1.1 haad /*
100 1.1 haad * All ioctl arguments consist of a single chunk of memory, with
101 1.1 haad * this structure at the start. If a uuid is specified any
102 1.1 haad * lookup (eg. for a DM_INFO) will be done on that, *not* the
103 1.1 haad * name.
104 1.1 haad */
105 1.1 haad struct dm_ioctl {
106 1.1 haad /*
107 1.1 haad * The version number is made up of three parts:
108 1.1 haad * major - no backward or forward compatibility,
109 1.1 haad * minor - only backwards compatible,
110 1.1 haad * patch - both backwards and forwards compatible.
111 1.1 haad *
112 1.1 haad * All clients of the ioctl interface should fill in the
113 1.1 haad * version number of the interface that they were
114 1.1 haad * compiled with.
115 1.1 haad *
116 1.1 haad * All recognised ioctl commands (ie. those that don't
117 1.1 haad * return -ENOTTY) fill out this field, even if the
118 1.1 haad * command failed.
119 1.1 haad */
120 1.1 haad uint32_t version[3]; /* in/out */
121 1.1 haad uint32_t data_size; /* total size of data passed in
122 1.1 haad * including this struct */
123 1.1 haad
124 1.1 haad uint32_t data_start; /* offset to start of data
125 1.1 haad * relative to start of this struct */
126 1.1 haad
127 1.1 haad uint32_t target_count; /* in/out */
128 1.1 haad int32_t open_count; /* out */
129 1.1 haad uint32_t flags; /* in/out */
130 1.1.1.2 haad
131 1.1.1.2 haad /*
132 1.1.1.2 haad * event_nr holds either the event number (input and output) or the
133 1.1.1.2 haad * udev cookie value (input only).
134 1.1.1.2 haad * The DM_DEV_WAIT ioctl takes an event number as input.
135 1.1.1.2 haad * The DM_SUSPEND, DM_DEV_REMOVE and DM_DEV_RENAME ioctls
136 1.1.1.2 haad * use the field as a cookie to return in the DM_COOKIE
137 1.1.1.2 haad * variable with the uevents they issue.
138 1.1.1.2 haad * For output, the ioctls return the event number, not the cookie.
139 1.1.1.2 haad */
140 1.1 haad uint32_t event_nr; /* in/out */
141 1.1 haad uint32_t padding;
142 1.1 haad
143 1.1 haad uint64_t dev; /* in/out */
144 1.1 haad
145 1.1 haad char name[DM_NAME_LEN]; /* device name */
146 1.1 haad char uuid[DM_UUID_LEN]; /* unique identifier for
147 1.1 haad * the block device */
148 1.1 haad char data[7]; /* padding or data */
149 1.1 haad };
150 1.1 haad
151 1.1 haad /*
152 1.1 haad * Used to specify tables. These structures appear after the
153 1.1 haad * dm_ioctl.
154 1.1 haad */
155 1.1 haad struct dm_target_spec {
156 1.1 haad uint64_t sector_start;
157 1.1 haad uint64_t length;
158 1.1 haad int32_t status; /* used when reading from kernel only */
159 1.1 haad
160 1.1 haad /*
161 1.1 haad * Location of the next dm_target_spec.
162 1.1 haad * - When specifying targets on a DM_TABLE_LOAD command, this value is
163 1.1 haad * the number of bytes from the start of the "current" dm_target_spec
164 1.1 haad * to the start of the "next" dm_target_spec.
165 1.1 haad * - When retrieving targets on a DM_TABLE_STATUS command, this value
166 1.1 haad * is the number of bytes from the start of the first dm_target_spec
167 1.1 haad * (that follows the dm_ioctl struct) to the start of the "next"
168 1.1 haad * dm_target_spec.
169 1.1 haad */
170 1.1 haad uint32_t next;
171 1.1 haad
172 1.1 haad char target_type[DM_MAX_TYPE_NAME];
173 1.1 haad
174 1.1 haad /*
175 1.1 haad * Parameter string starts immediately after this object.
176 1.1 haad * Be careful to add padding after string to ensure correct
177 1.1 haad * alignment of subsequent dm_target_spec.
178 1.1 haad */
179 1.1 haad };
180 1.1 haad
181 1.1 haad /*
182 1.1 haad * Used to retrieve the target dependencies.
183 1.1 haad */
184 1.1 haad struct dm_target_deps {
185 1.1 haad uint32_t count; /* Array size */
186 1.1 haad uint32_t padding; /* unused */
187 1.1 haad uint64_t dev[0]; /* out */
188 1.1 haad };
189 1.1 haad
190 1.1 haad /*
191 1.1 haad * Used to get a list of all dm devices.
192 1.1 haad */
193 1.1 haad struct dm_name_list {
194 1.1 haad uint64_t dev;
195 1.1 haad uint32_t next; /* offset to the next record from
196 1.1 haad the _start_ of this */
197 1.1 haad char name[0];
198 1.1 haad };
199 1.1 haad
200 1.1 haad /*
201 1.1 haad * Used to retrieve the target versions
202 1.1 haad */
203 1.1 haad struct dm_target_versions {
204 1.1 haad uint32_t next;
205 1.1 haad uint32_t version[3];
206 1.1 haad
207 1.1 haad char name[0];
208 1.1 haad };
209 1.1 haad
210 1.1 haad /*
211 1.1 haad * Used to pass message to a target
212 1.1 haad */
213 1.1 haad struct dm_target_msg {
214 1.1 haad uint64_t sector; /* Device sector */
215 1.1 haad
216 1.1 haad char message[0];
217 1.1 haad };
218 1.1 haad
219 1.1 haad /*
220 1.1 haad * If you change this make sure you make the corresponding change
221 1.1 haad * to dm-ioctl.c:lookup_ioctl()
222 1.1 haad */
223 1.1 haad enum {
224 1.1 haad /* Top level cmds */
225 1.1 haad DM_VERSION_CMD = 0,
226 1.1 haad DM_REMOVE_ALL_CMD,
227 1.1 haad DM_LIST_DEVICES_CMD,
228 1.1 haad
229 1.1 haad /* device level cmds */
230 1.1 haad DM_DEV_CREATE_CMD,
231 1.1 haad DM_DEV_REMOVE_CMD,
232 1.1 haad DM_DEV_RENAME_CMD,
233 1.1 haad DM_DEV_SUSPEND_CMD,
234 1.1 haad DM_DEV_STATUS_CMD,
235 1.1 haad DM_DEV_WAIT_CMD,
236 1.1 haad
237 1.1 haad /* Table level cmds */
238 1.1 haad DM_TABLE_LOAD_CMD,
239 1.1 haad DM_TABLE_CLEAR_CMD,
240 1.1 haad DM_TABLE_DEPS_CMD,
241 1.1 haad DM_TABLE_STATUS_CMD,
242 1.1 haad
243 1.1 haad /* Added later */
244 1.1 haad DM_LIST_VERSIONS_CMD,
245 1.1 haad DM_TARGET_MSG_CMD,
246 1.1 haad DM_DEV_SET_GEOMETRY_CMD
247 1.1 haad };
248 1.1 haad
249 1.1 haad #define DM_IOCTL 0xfd
250 1.1 haad
251 1.1 haad #define DM_VERSION _IOWR(DM_IOCTL, DM_VERSION_CMD, struct dm_ioctl)
252 1.1 haad #define DM_REMOVE_ALL _IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD, struct dm_ioctl)
253 1.1 haad #define DM_LIST_DEVICES _IOWR(DM_IOCTL, DM_LIST_DEVICES_CMD, struct dm_ioctl)
254 1.1 haad
255 1.1 haad #define DM_DEV_CREATE _IOWR(DM_IOCTL, DM_DEV_CREATE_CMD, struct dm_ioctl)
256 1.1 haad #define DM_DEV_REMOVE _IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD, struct dm_ioctl)
257 1.1 haad #define DM_DEV_RENAME _IOWR(DM_IOCTL, DM_DEV_RENAME_CMD, struct dm_ioctl)
258 1.1 haad #define DM_DEV_SUSPEND _IOWR(DM_IOCTL, DM_DEV_SUSPEND_CMD, struct dm_ioctl)
259 1.1 haad #define DM_DEV_STATUS _IOWR(DM_IOCTL, DM_DEV_STATUS_CMD, struct dm_ioctl)
260 1.1 haad #define DM_DEV_WAIT _IOWR(DM_IOCTL, DM_DEV_WAIT_CMD, struct dm_ioctl)
261 1.1 haad
262 1.1 haad #define DM_TABLE_LOAD _IOWR(DM_IOCTL, DM_TABLE_LOAD_CMD, struct dm_ioctl)
263 1.1 haad #define DM_TABLE_CLEAR _IOWR(DM_IOCTL, DM_TABLE_CLEAR_CMD, struct dm_ioctl)
264 1.1 haad #define DM_TABLE_DEPS _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, struct dm_ioctl)
265 1.1 haad #define DM_TABLE_STATUS _IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, struct dm_ioctl)
266 1.1 haad
267 1.1 haad #define DM_LIST_VERSIONS _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, struct dm_ioctl)
268 1.1 haad
269 1.1 haad #define DM_TARGET_MSG _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, struct dm_ioctl)
270 1.1 haad #define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
271 1.1 haad
272 1.1 haad #define DM_VERSION_MAJOR 4
273 1.1.1.2 haad #define DM_VERSION_MINOR 16
274 1.1 haad #define DM_VERSION_PATCHLEVEL 0
275 1.1.1.2 haad #define DM_VERSION_EXTRA "-ioctl (2009-11-05)"
276 1.1 haad
277 1.1 haad /* Status bits */
278 1.1 haad #define DM_READONLY_FLAG (1 << 0) /* In/Out */
279 1.1 haad #define DM_SUSPEND_FLAG (1 << 1) /* In/Out */
280 1.1 haad #define DM_PERSISTENT_DEV_FLAG (1 << 3) /* In */
281 1.1 haad
282 1.1 haad /*
283 1.1 haad * Flag passed into ioctl STATUS command to get table information
284 1.1 haad * rather than current status.
285 1.1 haad */
286 1.1 haad #define DM_STATUS_TABLE_FLAG (1 << 4) /* In */
287 1.1 haad
288 1.1 haad /*
289 1.1 haad * Flags that indicate whether a table is present in either of
290 1.1 haad * the two table slots that a device has.
291 1.1 haad */
292 1.1 haad #define DM_ACTIVE_PRESENT_FLAG (1 << 5) /* Out */
293 1.1 haad #define DM_INACTIVE_PRESENT_FLAG (1 << 6) /* Out */
294 1.1 haad
295 1.1 haad /*
296 1.1 haad * Indicates that the buffer passed in wasn't big enough for the
297 1.1 haad * results.
298 1.1 haad */
299 1.1 haad #define DM_BUFFER_FULL_FLAG (1 << 8) /* Out */
300 1.1 haad
301 1.1 haad /*
302 1.1 haad * This flag is now ignored.
303 1.1 haad */
304 1.1 haad #define DM_SKIP_BDGET_FLAG (1 << 9) /* In */
305 1.1 haad
306 1.1 haad /*
307 1.1 haad * Set this to avoid attempting to freeze any filesystem when suspending.
308 1.1 haad */
309 1.1 haad #define DM_SKIP_LOCKFS_FLAG (1 << 10) /* In */
310 1.1 haad
311 1.1 haad /*
312 1.1 haad * Set this to suspend without flushing queued ios.
313 1.1 haad */
314 1.1 haad #define DM_NOFLUSH_FLAG (1 << 11) /* In */
315 1.1 haad
316 1.1.1.2 haad /*
317 1.1.1.2 haad * If set, any table information returned will relate to the inactive
318 1.1.1.2 haad * table instead of the live one. Always check DM_INACTIVE_PRESENT_FLAG
319 1.1.1.2 haad * is set before using the data returned.
320 1.1.1.2 haad */
321 1.1.1.2 haad #define DM_QUERY_INACTIVE_TABLE_FLAG (1 << 12) /* In */
322 1.1.1.2 haad
323 1.1 haad #endif /* _LINUX_DM_IOCTL_H */
324