1 /* SPDX-License-Identifier: LGPL-2.0+ WITH Linux-syscall-note */
3 * Copyright (C) 2001 - 2003 Sistina Software (UK) Limited.
4 * Copyright (C) 2004 - 2009 Red Hat, Inc. All rights reserved.
6 * This file is released under the LGPL.
9 #ifndef _LINUX_DM_IOCTL_V4_H
10 #define _LINUX_DM_IOCTL_V4_H
12 #include <linux/types.h>
14 #define DM_DIR "mapper" /* Slashes not supported */
15 #define DM_CONTROL_NODE "control"
16 #define DM_MAX_TYPE_NAME 16
17 #define DM_NAME_LEN 128
18 #define DM_UUID_LEN 129
21 * A traditional ioctl interface for the device mapper.
23 * Each device can have two tables associated with it, an
24 * 'active' table which is the one currently used by io passing
25 * through the device, and an 'inactive' one which is a table
26 * that is being prepared as a replacement for the 'active' one.
29 * Just get the version information for the ioctl interface.
32 * Remove all dm devices, destroy all tables. Only really used
36 * Get a list of all the dm device names.
39 * Create a new device, neither the 'active' or 'inactive' table
40 * slots will be filled. The device will be in suspended state
41 * after creation, however any io to the device will get errored
42 * since it will be out-of-bounds.
45 * Remove a device, destroy any tables.
48 * Rename a device or set its uuid if none was previously supplied.
51 * This performs both suspend and resume, depending which flag is
53 * Suspend: This command will not return until all pending io to
54 * the device has completed. Further io will be deferred until
55 * the device is resumed.
56 * Resume: It is no longer an error to issue this command on an
57 * unsuspended device. If a table is present in the 'inactive'
58 * slot, it will be moved to the active slot, then the old table
59 * from the active slot will be _destroyed_. Finally the device
63 * Retrieves the status for the table in the 'active' slot.
66 * Wait for a significant event to occur to the device. This
67 * could either be caused by an event triggered by one of the
68 * targets of the table in the 'active' slot, or a table change.
71 * Load a table into the 'inactive' slot for the device. The
72 * device does _not_ need to be suspended prior to this command.
75 * Destroy any table in the 'inactive' slot (ie. abort).
78 * Return a set of device dependencies for the 'active' table.
81 * Return the targets status for the 'active' table.
84 * Pass a message string to the target at a specific offset of a device.
86 * DM_DEV_SET_GEOMETRY:
87 * Set the geometry of a device by passing in a string in this format:
89 * "cylinders heads sectors_per_track start_sector"
91 * Beware that CHS geometry is nearly obsolete and only provided
92 * for compatibility with dm devices that can be booted by a PC
93 * BIOS. See struct hd_geometry for range limits. Also note that
94 * the geometry is erased if the device size changes.
98 * All ioctl arguments consist of a single chunk of memory, with
99 * this structure at the start. If a uuid is specified any
100 * lookup (eg. for a DM_INFO) will be done on that, *not* the
105 * The version number is made up of three parts:
106 * major - no backward or forward compatibility,
107 * minor - only backwards compatible,
108 * patch - both backwards and forwards compatible.
110 * All clients of the ioctl interface should fill in the
111 * version number of the interface that they were
114 * All recognised ioctl commands (ie. those that don't
115 * return -ENOTTY) fill out this field, even if the
118 __u32 version[3]; /* in/out */
119 __u32 data_size; /* total size of data passed in
120 * including this struct */
122 __u32 data_start; /* offset to start of data
123 * relative to start of this struct */
125 __u32 target_count; /* in/out */
126 __s32 open_count; /* out */
127 __u32 flags; /* in/out */
130 * event_nr holds either the event number (input and output) or the
131 * udev cookie value (input only).
132 * The DM_DEV_WAIT ioctl takes an event number as input.
133 * The DM_SUSPEND, DM_DEV_REMOVE and DM_DEV_RENAME ioctls
134 * use the field as a cookie to return in the DM_COOKIE
135 * variable with the uevents they issue.
136 * For output, the ioctls return the event number, not the cookie.
138 __u32 event_nr; /* in/out */
141 __u64 dev; /* in/out */
143 char name[DM_NAME_LEN]; /* device name */
144 char uuid[DM_UUID_LEN]; /* unique identifier for
145 * the block device */
146 char data[7]; /* padding or data */
150 * Used to specify tables. These structures appear after the
153 struct dm_target_spec {
156 __s32 status; /* used when reading from kernel only */
159 * Location of the next dm_target_spec.
160 * - When specifying targets on a DM_TABLE_LOAD command, this value is
161 * the number of bytes from the start of the "current" dm_target_spec
162 * to the start of the "next" dm_target_spec.
163 * - When retrieving targets on a DM_TABLE_STATUS command, this value
164 * is the number of bytes from the start of the first dm_target_spec
165 * (that follows the dm_ioctl struct) to the start of the "next"
170 char target_type[DM_MAX_TYPE_NAME];
173 * Parameter string starts immediately after this object.
174 * Be careful to add padding after string to ensure correct
175 * alignment of subsequent dm_target_spec.
180 * Used to retrieve the target dependencies.
182 struct dm_target_deps {
183 __u32 count; /* Array size */
184 __u32 padding; /* unused */
185 __u64 dev[]; /* out */
189 * Used to get a list of all dm devices.
191 struct dm_name_list {
193 __u32 next; /* offset to the next record from
194 the _start_ of this */
198 * The following members can be accessed by taking a pointer that
199 * points immediately after the terminating zero character in "name"
200 * and aligning this pointer to next 8-byte boundary.
201 * Uuid is present if the flag DM_NAME_LIST_FLAG_HAS_UUID is set.
209 #define DM_NAME_LIST_FLAG_HAS_UUID 1
210 #define DM_NAME_LIST_FLAG_DOESNT_HAVE_UUID 2
213 * Used to retrieve the target versions
215 struct dm_target_versions {
223 * Used to pass message to a target
225 struct dm_target_msg {
226 __u64 sector; /* Device sector */
232 * If you change this make sure you make the corresponding change
233 * to dm-ioctl.c:lookup_ioctl()
241 /* device level cmds */
249 /* Table level cmds */
256 DM_LIST_VERSIONS_CMD,
258 DM_DEV_SET_GEOMETRY_CMD,
260 DM_GET_TARGET_VERSION_CMD,
263 #define DM_IOCTL 0xfd
265 #define DM_VERSION _IOWR(DM_IOCTL, DM_VERSION_CMD, struct dm_ioctl)
266 #define DM_REMOVE_ALL _IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD, struct dm_ioctl)
267 #define DM_LIST_DEVICES _IOWR(DM_IOCTL, DM_LIST_DEVICES_CMD, struct dm_ioctl)
269 #define DM_DEV_CREATE _IOWR(DM_IOCTL, DM_DEV_CREATE_CMD, struct dm_ioctl)
270 #define DM_DEV_REMOVE _IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD, struct dm_ioctl)
271 #define DM_DEV_RENAME _IOWR(DM_IOCTL, DM_DEV_RENAME_CMD, struct dm_ioctl)
272 #define DM_DEV_SUSPEND _IOWR(DM_IOCTL, DM_DEV_SUSPEND_CMD, struct dm_ioctl)
273 #define DM_DEV_STATUS _IOWR(DM_IOCTL, DM_DEV_STATUS_CMD, struct dm_ioctl)
274 #define DM_DEV_WAIT _IOWR(DM_IOCTL, DM_DEV_WAIT_CMD, struct dm_ioctl)
275 #define DM_DEV_ARM_POLL _IOWR(DM_IOCTL, DM_DEV_ARM_POLL_CMD, struct dm_ioctl)
277 #define DM_TABLE_LOAD _IOWR(DM_IOCTL, DM_TABLE_LOAD_CMD, struct dm_ioctl)
278 #define DM_TABLE_CLEAR _IOWR(DM_IOCTL, DM_TABLE_CLEAR_CMD, struct dm_ioctl)
279 #define DM_TABLE_DEPS _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, struct dm_ioctl)
280 #define DM_TABLE_STATUS _IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, struct dm_ioctl)
282 #define DM_LIST_VERSIONS _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, struct dm_ioctl)
283 #define DM_GET_TARGET_VERSION _IOWR(DM_IOCTL, DM_GET_TARGET_VERSION_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 48
290 #define DM_VERSION_PATCHLEVEL 0
291 #define DM_VERSION_EXTRA "-ioctl (2023-03-01)"
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.
329 * Also disables flushing uncommitted changes in the thin target before
330 * generating statistics for DM_TABLE_STATUS and DM_DEV_WAIT.
332 #define DM_NOFLUSH_FLAG (1 << 11) /* In */
335 * If set, any table information returned will relate to the inactive
336 * table instead of the live one. Always check DM_INACTIVE_PRESENT_FLAG
337 * is set before using the data returned.
339 #define DM_QUERY_INACTIVE_TABLE_FLAG (1 << 12) /* In */
342 * If set, a uevent was generated for which the caller may need to wait.
344 #define DM_UEVENT_GENERATED_FLAG (1 << 13) /* Out */
347 * If set, rename changes the uuid not the name. Only permitted
348 * if no uuid was previously supplied: an existing uuid cannot be changed.
350 #define DM_UUID_FLAG (1 << 14) /* In */
353 * If set, all buffers are wiped after use. Use when sending
354 * or requesting sensitive data such as an encryption key.
356 #define DM_SECURE_DATA_FLAG (1 << 15) /* In */
359 * If set, a message generated output data.
361 #define DM_DATA_OUT_FLAG (1 << 16) /* Out */
364 * If set with DM_DEV_REMOVE or DM_REMOVE_ALL this indicates that if
365 * the device cannot be removed immediately because it is still in use
366 * it should instead be scheduled for removal when it gets closed.
368 * On return from DM_DEV_REMOVE, DM_DEV_STATUS or other ioctls, this
369 * flag indicates that the device is scheduled to be removed when it
372 #define DM_DEFERRED_REMOVE (1 << 17) /* In/Out */
375 * If set, the device is suspended internally.
377 #define DM_INTERNAL_SUSPEND_FLAG (1 << 18) /* Out */
380 * If set, returns in the in buffer passed by UM, the raw table information
381 * that would be measured by IMA subsystem on device state change.
383 #define DM_IMA_MEASUREMENT_FLAG (1 << 19) /* In */
385 #endif /* _LINUX_DM_IOCTL_H */