2 * Copyright (C) 2001 - 2003 Sistina Software (UK) Limited.
3 * Copyright (C) 2004 - 2005 Red Hat, Inc. All rights reserved.
5 * This file is released under the LGPL.
8 #ifndef _LINUX_DM_IOCTL_V4_H
9 #define _LINUX_DM_IOCTL_V4_H
11 #include <linux/types.h>
13 #define DM_DIR "mapper" /* Slashes not supported */
14 #define DM_MAX_TYPE_NAME 16
15 #define DM_NAME_LEN 128
16 #define DM_UUID_LEN 129
19 * A traditional ioctl interface for the device mapper.
21 * Each device can have two tables associated with it, an
22 * 'active' table which is the one currently used by io passing
23 * through the device, and an 'inactive' one which is a table
24 * that is being prepared as a replacement for the 'active' one.
27 * Just get the version information for the ioctl interface.
30 * Remove all dm devices, destroy all tables. Only really used
34 * Get a list of all the dm device names.
37 * Create a new device, neither the 'active' or 'inactive' table
38 * slots will be filled. The device will be in suspended state
39 * after creation, however any io to the device will get errored
40 * since it will be out-of-bounds.
43 * Remove a device, destroy any tables.
49 * This performs both suspend and resume, depending which flag is
51 * Suspend: This command will not return until all pending io to
52 * the device has completed. Further io will be deferred until
53 * the device is resumed.
54 * Resume: It is no longer an error to issue this command on an
55 * unsuspended device. If a table is present in the 'inactive'
56 * slot, it will be moved to the active slot, then the old table
57 * from the active slot will be _destroyed_. Finally the device
61 * Retrieves the status for the table in the 'active' slot.
64 * Wait for a significant event to occur to the device. This
65 * could either be caused by an event triggered by one of the
66 * targets of the table in the 'active' slot, or a table change.
69 * Load a table into the 'inactive' slot for the device. The
70 * device does _not_ need to be suspended prior to this command.
73 * Destroy any table in the 'inactive' slot (ie. abort).
76 * Return a set of device dependencies for the 'active' table.
79 * Return the targets status for the 'active' table.
82 * Pass a message string to the target at a specific offset of a device.
84 * DM_DEV_SET_GEOMETRY:
85 * Set the geometry of a device by passing in a string in this format:
87 * "cylinders heads sectors_per_track start_sector"
89 * Beware that CHS geometry is nearly obsolete and only provided
90 * for compatibility with dm devices that can be booted by a PC
91 * BIOS. See struct hd_geometry for range limits. Also note that
92 * the geometry is erased if the device size changes.
96 * All ioctl arguments consist of a single chunk of memory, with
97 * this structure at the start. If a uuid is specified any
98 * lookup (eg. for a DM_INFO) will be done on that, *not* the
103 * The version number is made up of three parts:
104 * major - no backward or forward compatibility,
105 * minor - only backwards compatible,
106 * patch - both backwards and forwards compatible.
108 * All clients of the ioctl interface should fill in the
109 * version number of the interface that they were
112 * All recognised ioctl commands (ie. those that don't
113 * return -ENOTTY) fill out this field, even if the
116 uint32_t version[3]; /* in/out */
117 uint32_t data_size; /* total size of data passed in
118 * including this struct */
120 uint32_t data_start; /* offset to start of data
121 * relative to start of this struct */
123 uint32_t target_count; /* in/out */
124 int32_t open_count; /* out */
125 uint32_t flags; /* in/out */
126 uint32_t event_nr; /* in/out */
129 uint64_t dev; /* in/out */
131 char name[DM_NAME_LEN]; /* device name */
132 char uuid[DM_UUID_LEN]; /* unique identifier for
133 * the block device */
134 char data[7]; /* padding or data */
138 * Used to specify tables. These structures appear after the
141 struct dm_target_spec {
142 uint64_t sector_start;
144 int32_t status; /* used when reading from kernel only */
147 * Location of the next dm_target_spec.
148 * - When specifying targets on a DM_TABLE_LOAD command, this value is
149 * the number of bytes from the start of the "current" dm_target_spec
150 * to the start of the "next" dm_target_spec.
151 * - When retrieving targets on a DM_TABLE_STATUS command, this value
152 * is the number of bytes from the start of the first dm_target_spec
153 * (that follows the dm_ioctl struct) to the start of the "next"
158 char target_type[DM_MAX_TYPE_NAME];
161 * Parameter string starts immediately after this object.
162 * Be careful to add padding after string to ensure correct
163 * alignment of subsequent dm_target_spec.
168 * Used to retrieve the target dependencies.
170 struct dm_target_deps {
171 uint32_t count; /* Array size */
172 uint32_t padding; /* unused */
173 uint64_t dev[0]; /* out */
177 * Used to get a list of all dm devices.
179 struct dm_name_list {
181 uint32_t next; /* offset to the next record from
182 the _start_ of this */
187 * Used to retrieve the target versions
189 struct dm_target_versions {
197 * Used to pass message to a target
199 struct dm_target_msg {
200 uint64_t sector; /* Device sector */
206 * If you change this make sure you make the corresponding change
207 * to dm-ioctl.c:lookup_ioctl()
215 /* device level cmds */
223 /* Table level cmds */
230 DM_LIST_VERSIONS_CMD,
232 DM_DEV_SET_GEOMETRY_CMD
236 * The dm_ioctl struct passed into the ioctl is just the header
237 * on a larger chunk of memory. On x86-64 and other
238 * architectures the dm-ioctl struct will be padded to an 8 byte
239 * boundary so the size will be different, which would change the
240 * ioctl code - yes I really messed up. This hack forces these
241 * architectures to have the correct ioctl code.
244 typedef char ioctl_struct[308];
245 #define DM_VERSION_32 _IOWR(DM_IOCTL, DM_VERSION_CMD, ioctl_struct)
246 #define DM_REMOVE_ALL_32 _IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD, ioctl_struct)
247 #define DM_LIST_DEVICES_32 _IOWR(DM_IOCTL, DM_LIST_DEVICES_CMD, ioctl_struct)
249 #define DM_DEV_CREATE_32 _IOWR(DM_IOCTL, DM_DEV_CREATE_CMD, ioctl_struct)
250 #define DM_DEV_REMOVE_32 _IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD, ioctl_struct)
251 #define DM_DEV_RENAME_32 _IOWR(DM_IOCTL, DM_DEV_RENAME_CMD, ioctl_struct)
252 #define DM_DEV_SUSPEND_32 _IOWR(DM_IOCTL, DM_DEV_SUSPEND_CMD, ioctl_struct)
253 #define DM_DEV_STATUS_32 _IOWR(DM_IOCTL, DM_DEV_STATUS_CMD, ioctl_struct)
254 #define DM_DEV_WAIT_32 _IOWR(DM_IOCTL, DM_DEV_WAIT_CMD, ioctl_struct)
256 #define DM_TABLE_LOAD_32 _IOWR(DM_IOCTL, DM_TABLE_LOAD_CMD, ioctl_struct)
257 #define DM_TABLE_CLEAR_32 _IOWR(DM_IOCTL, DM_TABLE_CLEAR_CMD, ioctl_struct)
258 #define DM_TABLE_DEPS_32 _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, ioctl_struct)
259 #define DM_TABLE_STATUS_32 _IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, ioctl_struct)
260 #define DM_LIST_VERSIONS_32 _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, ioctl_struct)
261 #define DM_TARGET_MSG_32 _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, ioctl_struct)
262 #define DM_DEV_SET_GEOMETRY_32 _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, ioctl_struct)
265 #define DM_IOCTL 0xfd
267 #define DM_VERSION _IOWR(DM_IOCTL, DM_VERSION_CMD, struct dm_ioctl)
268 #define DM_REMOVE_ALL _IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD, struct dm_ioctl)
269 #define DM_LIST_DEVICES _IOWR(DM_IOCTL, DM_LIST_DEVICES_CMD, struct dm_ioctl)
271 #define DM_DEV_CREATE _IOWR(DM_IOCTL, DM_DEV_CREATE_CMD, struct dm_ioctl)
272 #define DM_DEV_REMOVE _IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD, struct dm_ioctl)
273 #define DM_DEV_RENAME _IOWR(DM_IOCTL, DM_DEV_RENAME_CMD, struct dm_ioctl)
274 #define DM_DEV_SUSPEND _IOWR(DM_IOCTL, DM_DEV_SUSPEND_CMD, struct dm_ioctl)
275 #define DM_DEV_STATUS _IOWR(DM_IOCTL, DM_DEV_STATUS_CMD, struct dm_ioctl)
276 #define DM_DEV_WAIT _IOWR(DM_IOCTL, DM_DEV_WAIT_CMD, struct dm_ioctl)
278 #define DM_TABLE_LOAD _IOWR(DM_IOCTL, DM_TABLE_LOAD_CMD, struct dm_ioctl)
279 #define DM_TABLE_CLEAR _IOWR(DM_IOCTL, DM_TABLE_CLEAR_CMD, struct dm_ioctl)
280 #define DM_TABLE_DEPS _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, struct dm_ioctl)
281 #define DM_TABLE_STATUS _IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, struct dm_ioctl)
283 #define DM_LIST_VERSIONS _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, struct dm_ioctl)
285 #define DM_TARGET_MSG _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, struct dm_ioctl)
286 #define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
288 #define DM_VERSION_MAJOR 4
289 #define DM_VERSION_MINOR 12
290 #define DM_VERSION_PATCHLEVEL 0
291 #define DM_VERSION_EXTRA "-ioctl (2007-10-02)"
294 #define DM_READONLY_FLAG (1 << 0) /* In/Out */
295 #define DM_SUSPEND_FLAG (1 << 1) /* In/Out */
296 #define DM_PERSISTENT_DEV_FLAG (1 << 3) /* In */
299 * Flag passed into ioctl STATUS command to get table information
300 * rather than current status.
302 #define DM_STATUS_TABLE_FLAG (1 << 4) /* In */
305 * Flags that indicate whether a table is present in either of
306 * the two table slots that a device has.
308 #define DM_ACTIVE_PRESENT_FLAG (1 << 5) /* Out */
309 #define DM_INACTIVE_PRESENT_FLAG (1 << 6) /* Out */
312 * Indicates that the buffer passed in wasn't big enough for the
315 #define DM_BUFFER_FULL_FLAG (1 << 8) /* Out */
318 * This flag is now ignored.
320 #define DM_SKIP_BDGET_FLAG (1 << 9) /* In */
323 * Set this to avoid attempting to freeze any filesystem when suspending.
325 #define DM_SKIP_LOCKFS_FLAG (1 << 10) /* In */
328 * Set this to suspend without flushing queued ios.
330 #define DM_NOFLUSH_FLAG (1 << 11) /* In */
332 #endif /* _LINUX_DM_IOCTL_H */