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