dm-ioctl.h 10 KB

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