dm-ioctl.h revision 1.1 1 1.1 haad /* $NetBSD: dm-ioctl.h,v 1.1 2008/12/22 00:18:36 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 haad * Copyright (C) 2004 - 2005 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 haad uint32_t event_nr; /* in/out */
131 1.1 haad uint32_t padding;
132 1.1 haad
133 1.1 haad uint64_t dev; /* in/out */
134 1.1 haad
135 1.1 haad char name[DM_NAME_LEN]; /* device name */
136 1.1 haad char uuid[DM_UUID_LEN]; /* unique identifier for
137 1.1 haad * the block device */
138 1.1 haad char data[7]; /* padding or data */
139 1.1 haad };
140 1.1 haad
141 1.1 haad /*
142 1.1 haad * Used to specify tables. These structures appear after the
143 1.1 haad * dm_ioctl.
144 1.1 haad */
145 1.1 haad struct dm_target_spec {
146 1.1 haad uint64_t sector_start;
147 1.1 haad uint64_t length;
148 1.1 haad int32_t status; /* used when reading from kernel only */
149 1.1 haad
150 1.1 haad /*
151 1.1 haad * Location of the next dm_target_spec.
152 1.1 haad * - When specifying targets on a DM_TABLE_LOAD command, this value is
153 1.1 haad * the number of bytes from the start of the "current" dm_target_spec
154 1.1 haad * to the start of the "next" dm_target_spec.
155 1.1 haad * - When retrieving targets on a DM_TABLE_STATUS command, this value
156 1.1 haad * is the number of bytes from the start of the first dm_target_spec
157 1.1 haad * (that follows the dm_ioctl struct) to the start of the "next"
158 1.1 haad * dm_target_spec.
159 1.1 haad */
160 1.1 haad uint32_t next;
161 1.1 haad
162 1.1 haad char target_type[DM_MAX_TYPE_NAME];
163 1.1 haad
164 1.1 haad /*
165 1.1 haad * Parameter string starts immediately after this object.
166 1.1 haad * Be careful to add padding after string to ensure correct
167 1.1 haad * alignment of subsequent dm_target_spec.
168 1.1 haad */
169 1.1 haad };
170 1.1 haad
171 1.1 haad /*
172 1.1 haad * Used to retrieve the target dependencies.
173 1.1 haad */
174 1.1 haad struct dm_target_deps {
175 1.1 haad uint32_t count; /* Array size */
176 1.1 haad uint32_t padding; /* unused */
177 1.1 haad uint64_t dev[0]; /* out */
178 1.1 haad };
179 1.1 haad
180 1.1 haad /*
181 1.1 haad * Used to get a list of all dm devices.
182 1.1 haad */
183 1.1 haad struct dm_name_list {
184 1.1 haad uint64_t dev;
185 1.1 haad uint32_t next; /* offset to the next record from
186 1.1 haad the _start_ of this */
187 1.1 haad char name[0];
188 1.1 haad };
189 1.1 haad
190 1.1 haad /*
191 1.1 haad * Used to retrieve the target versions
192 1.1 haad */
193 1.1 haad struct dm_target_versions {
194 1.1 haad uint32_t next;
195 1.1 haad uint32_t version[3];
196 1.1 haad
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 pass message to a target
202 1.1 haad */
203 1.1 haad struct dm_target_msg {
204 1.1 haad uint64_t sector; /* Device sector */
205 1.1 haad
206 1.1 haad char message[0];
207 1.1 haad };
208 1.1 haad
209 1.1 haad /*
210 1.1 haad * If you change this make sure you make the corresponding change
211 1.1 haad * to dm-ioctl.c:lookup_ioctl()
212 1.1 haad */
213 1.1 haad enum {
214 1.1 haad /* Top level cmds */
215 1.1 haad DM_VERSION_CMD = 0,
216 1.1 haad DM_REMOVE_ALL_CMD,
217 1.1 haad DM_LIST_DEVICES_CMD,
218 1.1 haad
219 1.1 haad /* device level cmds */
220 1.1 haad DM_DEV_CREATE_CMD,
221 1.1 haad DM_DEV_REMOVE_CMD,
222 1.1 haad DM_DEV_RENAME_CMD,
223 1.1 haad DM_DEV_SUSPEND_CMD,
224 1.1 haad DM_DEV_STATUS_CMD,
225 1.1 haad DM_DEV_WAIT_CMD,
226 1.1 haad
227 1.1 haad /* Table level cmds */
228 1.1 haad DM_TABLE_LOAD_CMD,
229 1.1 haad DM_TABLE_CLEAR_CMD,
230 1.1 haad DM_TABLE_DEPS_CMD,
231 1.1 haad DM_TABLE_STATUS_CMD,
232 1.1 haad
233 1.1 haad /* Added later */
234 1.1 haad DM_LIST_VERSIONS_CMD,
235 1.1 haad DM_TARGET_MSG_CMD,
236 1.1 haad DM_DEV_SET_GEOMETRY_CMD
237 1.1 haad };
238 1.1 haad
239 1.1 haad #define DM_IOCTL 0xfd
240 1.1 haad
241 1.1 haad #define DM_VERSION _IOWR(DM_IOCTL, DM_VERSION_CMD, struct dm_ioctl)
242 1.1 haad #define DM_REMOVE_ALL _IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD, struct dm_ioctl)
243 1.1 haad #define DM_LIST_DEVICES _IOWR(DM_IOCTL, DM_LIST_DEVICES_CMD, struct dm_ioctl)
244 1.1 haad
245 1.1 haad #define DM_DEV_CREATE _IOWR(DM_IOCTL, DM_DEV_CREATE_CMD, struct dm_ioctl)
246 1.1 haad #define DM_DEV_REMOVE _IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD, struct dm_ioctl)
247 1.1 haad #define DM_DEV_RENAME _IOWR(DM_IOCTL, DM_DEV_RENAME_CMD, struct dm_ioctl)
248 1.1 haad #define DM_DEV_SUSPEND _IOWR(DM_IOCTL, DM_DEV_SUSPEND_CMD, struct dm_ioctl)
249 1.1 haad #define DM_DEV_STATUS _IOWR(DM_IOCTL, DM_DEV_STATUS_CMD, struct dm_ioctl)
250 1.1 haad #define DM_DEV_WAIT _IOWR(DM_IOCTL, DM_DEV_WAIT_CMD, struct dm_ioctl)
251 1.1 haad
252 1.1 haad #define DM_TABLE_LOAD _IOWR(DM_IOCTL, DM_TABLE_LOAD_CMD, struct dm_ioctl)
253 1.1 haad #define DM_TABLE_CLEAR _IOWR(DM_IOCTL, DM_TABLE_CLEAR_CMD, struct dm_ioctl)
254 1.1 haad #define DM_TABLE_DEPS _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, struct dm_ioctl)
255 1.1 haad #define DM_TABLE_STATUS _IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, struct dm_ioctl)
256 1.1 haad
257 1.1 haad #define DM_LIST_VERSIONS _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, struct dm_ioctl)
258 1.1 haad
259 1.1 haad #define DM_TARGET_MSG _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, struct dm_ioctl)
260 1.1 haad #define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
261 1.1 haad
262 1.1 haad #define DM_VERSION_MAJOR 4
263 1.1 haad #define DM_VERSION_MINOR 14
264 1.1 haad #define DM_VERSION_PATCHLEVEL 0
265 1.1 haad #define DM_VERSION_EXTRA "-ioctl (2008-04-23)"
266 1.1 haad
267 1.1 haad /* Status bits */
268 1.1 haad #define DM_READONLY_FLAG (1 << 0) /* In/Out */
269 1.1 haad #define DM_SUSPEND_FLAG (1 << 1) /* In/Out */
270 1.1 haad #define DM_PERSISTENT_DEV_FLAG (1 << 3) /* In */
271 1.1 haad
272 1.1 haad /*
273 1.1 haad * Flag passed into ioctl STATUS command to get table information
274 1.1 haad * rather than current status.
275 1.1 haad */
276 1.1 haad #define DM_STATUS_TABLE_FLAG (1 << 4) /* In */
277 1.1 haad
278 1.1 haad /*
279 1.1 haad * Flags that indicate whether a table is present in either of
280 1.1 haad * the two table slots that a device has.
281 1.1 haad */
282 1.1 haad #define DM_ACTIVE_PRESENT_FLAG (1 << 5) /* Out */
283 1.1 haad #define DM_INACTIVE_PRESENT_FLAG (1 << 6) /* Out */
284 1.1 haad
285 1.1 haad /*
286 1.1 haad * Indicates that the buffer passed in wasn't big enough for the
287 1.1 haad * results.
288 1.1 haad */
289 1.1 haad #define DM_BUFFER_FULL_FLAG (1 << 8) /* Out */
290 1.1 haad
291 1.1 haad /*
292 1.1 haad * This flag is now ignored.
293 1.1 haad */
294 1.1 haad #define DM_SKIP_BDGET_FLAG (1 << 9) /* In */
295 1.1 haad
296 1.1 haad /*
297 1.1 haad * Set this to avoid attempting to freeze any filesystem when suspending.
298 1.1 haad */
299 1.1 haad #define DM_SKIP_LOCKFS_FLAG (1 << 10) /* In */
300 1.1 haad
301 1.1 haad /*
302 1.1 haad * Set this to suspend without flushing queued ios.
303 1.1 haad */
304 1.1 haad #define DM_NOFLUSH_FLAG (1 << 11) /* In */
305 1.1 haad
306 1.1 haad #endif /* _LINUX_DM_IOCTL_H */
307