dm-ioctl.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. /*
  2. * Copyright (C) 2001 - 2003 Sistina Software (UK) Limited.
  3. * Copyright (C) 2004 - 2005 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_MAX_TYPE_NAME 16
  12. #define DM_NAME_LEN 128
  13. #define DM_UUID_LEN 129
  14. /*
  15. * A traditional ioctl interface for the device mapper.
  16. *
  17. * Each device can have two tables associated with it, an
  18. * 'active' table which is the one currently used by io passing
  19. * through the device, and an 'inactive' one which is a table
  20. * that is being prepared as a replacement for the 'active' one.
  21. *
  22. * DM_VERSION:
  23. * Just get the version information for the ioctl interface.
  24. *
  25. * DM_REMOVE_ALL:
  26. * Remove all dm devices, destroy all tables. Only really used
  27. * for debug.
  28. *
  29. * DM_LIST_DEVICES:
  30. * Get a list of all the dm device names.
  31. *
  32. * DM_DEV_CREATE:
  33. * Create a new device, neither the 'active' or 'inactive' table
  34. * slots will be filled. The device will be in suspended state
  35. * after creation, however any io to the device will get errored
  36. * since it will be out-of-bounds.
  37. *
  38. * DM_DEV_REMOVE:
  39. * Remove a device, destroy any tables.
  40. *
  41. * DM_DEV_RENAME:
  42. * Rename a device.
  43. *
  44. * DM_SUSPEND:
  45. * This performs both suspend and resume, depending which flag is
  46. * passed in.
  47. * Suspend: This command will not return until all pending io to
  48. * the device has completed. Further io will be deferred until
  49. * the device is resumed.
  50. * Resume: It is no longer an error to issue this command on an
  51. * unsuspended device. If a table is present in the 'inactive'
  52. * slot, it will be moved to the active slot, then the old table
  53. * from the active slot will be _destroyed_. Finally the device
  54. * is resumed.
  55. *
  56. * DM_DEV_STATUS:
  57. * Retrieves the status for the table in the 'active' slot.
  58. *
  59. * DM_DEV_WAIT:
  60. * Wait for a significant event to occur to the device. This
  61. * could either be caused by an event triggered by one of the
  62. * targets of the table in the 'active' slot, or a table change.
  63. *
  64. * DM_TABLE_LOAD:
  65. * Load a table into the 'inactive' slot for the device. The
  66. * device does _not_ need to be suspended prior to this command.
  67. *
  68. * DM_TABLE_CLEAR:
  69. * Destroy any table in the 'inactive' slot (ie. abort).
  70. *
  71. * DM_TABLE_DEPS:
  72. * Return a set of device dependencies for the 'active' table.
  73. *
  74. * DM_TABLE_STATUS:
  75. * Return the targets status for the 'active' table.
  76. *
  77. * DM_TARGET_MSG:
  78. * Pass a message string to the target at a specific offset of a device.
  79. */
  80. /*
  81. * All ioctl arguments consist of a single chunk of memory, with
  82. * this structure at the start. If a uuid is specified any
  83. * lookup (eg. for a DM_INFO) will be done on that, *not* the
  84. * name.
  85. */
  86. struct dm_ioctl {
  87. /*
  88. * The version number is made up of three parts:
  89. * major - no backward or forward compatibility,
  90. * minor - only backwards compatible,
  91. * patch - both backwards and forwards compatible.
  92. *
  93. * All clients of the ioctl interface should fill in the
  94. * version number of the interface that they were
  95. * compiled with.
  96. *
  97. * All recognised ioctl commands (ie. those that don't
  98. * return -ENOTTY) fill out this field, even if the
  99. * command failed.
  100. */
  101. uint32_t version[3]; /* in/out */
  102. uint32_t data_size; /* total size of data passed in
  103. * including this struct */
  104. uint32_t data_start; /* offset to start of data
  105. * relative to start of this struct */
  106. uint32_t target_count; /* in/out */
  107. int32_t open_count; /* out */
  108. uint32_t flags; /* in/out */
  109. uint32_t event_nr; /* in/out */
  110. uint32_t padding;
  111. uint64_t dev; /* in/out */
  112. char name[DM_NAME_LEN]; /* device name */
  113. char uuid[DM_UUID_LEN]; /* unique identifier for
  114. * the block device */
  115. };
  116. /*
  117. * Used to specify tables. These structures appear after the
  118. * dm_ioctl.
  119. */
  120. struct dm_target_spec {
  121. uint64_t sector_start;
  122. uint64_t length;
  123. int32_t status; /* used when reading from kernel only */
  124. /*
  125. * Location of the next dm_target_spec.
  126. * - When specifying targets on a DM_TABLE_LOAD command, this value is
  127. * the number of bytes from the start of the "current" dm_target_spec
  128. * to the start of the "next" dm_target_spec.
  129. * - When retrieving targets on a DM_TABLE_STATUS command, this value
  130. * is the number of bytes from the start of the first dm_target_spec
  131. * (that follows the dm_ioctl struct) to the start of the "next"
  132. * dm_target_spec.
  133. */
  134. uint32_t next;
  135. char target_type[DM_MAX_TYPE_NAME];
  136. /*
  137. * Parameter string starts immediately after this object.
  138. * Be careful to add padding after string to ensure correct
  139. * alignment of subsequent dm_target_spec.
  140. */
  141. };
  142. /*
  143. * Used to retrieve the target dependencies.
  144. */
  145. struct dm_target_deps {
  146. uint32_t count; /* Array size */
  147. uint32_t padding; /* unused */
  148. uint64_t dev[0]; /* out */
  149. };
  150. /*
  151. * Used to get a list of all dm devices.
  152. */
  153. struct dm_name_list {
  154. uint64_t dev;
  155. uint32_t next; /* offset to the next record from
  156. the _start_ of this */
  157. char name[0];
  158. };
  159. /*
  160. * Used to retrieve the target versions
  161. */
  162. struct dm_target_versions {
  163. uint32_t next;
  164. uint32_t version[3];
  165. char name[0];
  166. };
  167. /*
  168. * Used to pass message to a target
  169. */
  170. struct dm_target_msg {
  171. uint64_t sector; /* Device sector */
  172. char message[0];
  173. };
  174. /*
  175. * If you change this make sure you make the corresponding change
  176. * to dm-ioctl.c:lookup_ioctl()
  177. */
  178. enum {
  179. /* Top level cmds */
  180. DM_VERSION_CMD = 0,
  181. DM_REMOVE_ALL_CMD,
  182. DM_LIST_DEVICES_CMD,
  183. /* device level cmds */
  184. DM_DEV_CREATE_CMD,
  185. DM_DEV_REMOVE_CMD,
  186. DM_DEV_RENAME_CMD,
  187. DM_DEV_SUSPEND_CMD,
  188. DM_DEV_STATUS_CMD,
  189. DM_DEV_WAIT_CMD,
  190. /* Table level cmds */
  191. DM_TABLE_LOAD_CMD,
  192. DM_TABLE_CLEAR_CMD,
  193. DM_TABLE_DEPS_CMD,
  194. DM_TABLE_STATUS_CMD,
  195. /* Added later */
  196. DM_LIST_VERSIONS_CMD,
  197. DM_TARGET_MSG_CMD,
  198. };
  199. /*
  200. * The dm_ioctl struct passed into the ioctl is just the header
  201. * on a larger chunk of memory. On x86-64 and other
  202. * architectures the dm-ioctl struct will be padded to an 8 byte
  203. * boundary so the size will be different, which would change the
  204. * ioctl code - yes I really messed up. This hack forces these
  205. * architectures to have the correct ioctl code.
  206. */
  207. #ifdef CONFIG_COMPAT
  208. typedef char ioctl_struct[308];
  209. #define DM_VERSION_32 _IOWR(DM_IOCTL, DM_VERSION_CMD, ioctl_struct)
  210. #define DM_REMOVE_ALL_32 _IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD, ioctl_struct)
  211. #define DM_LIST_DEVICES_32 _IOWR(DM_IOCTL, DM_LIST_DEVICES_CMD, ioctl_struct)
  212. #define DM_DEV_CREATE_32 _IOWR(DM_IOCTL, DM_DEV_CREATE_CMD, ioctl_struct)
  213. #define DM_DEV_REMOVE_32 _IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD, ioctl_struct)
  214. #define DM_DEV_RENAME_32 _IOWR(DM_IOCTL, DM_DEV_RENAME_CMD, ioctl_struct)
  215. #define DM_DEV_SUSPEND_32 _IOWR(DM_IOCTL, DM_DEV_SUSPEND_CMD, ioctl_struct)
  216. #define DM_DEV_STATUS_32 _IOWR(DM_IOCTL, DM_DEV_STATUS_CMD, ioctl_struct)
  217. #define DM_DEV_WAIT_32 _IOWR(DM_IOCTL, DM_DEV_WAIT_CMD, ioctl_struct)
  218. #define DM_TABLE_LOAD_32 _IOWR(DM_IOCTL, DM_TABLE_LOAD_CMD, ioctl_struct)
  219. #define DM_TABLE_CLEAR_32 _IOWR(DM_IOCTL, DM_TABLE_CLEAR_CMD, ioctl_struct)
  220. #define DM_TABLE_DEPS_32 _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, ioctl_struct)
  221. #define DM_TABLE_STATUS_32 _IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, ioctl_struct)
  222. #define DM_LIST_VERSIONS_32 _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, ioctl_struct)
  223. #define DM_TARGET_MSG_32 _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, ioctl_struct)
  224. #endif
  225. #define DM_IOCTL 0xfd
  226. #define DM_VERSION _IOWR(DM_IOCTL, DM_VERSION_CMD, struct dm_ioctl)
  227. #define DM_REMOVE_ALL _IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD, struct dm_ioctl)
  228. #define DM_LIST_DEVICES _IOWR(DM_IOCTL, DM_LIST_DEVICES_CMD, struct dm_ioctl)
  229. #define DM_DEV_CREATE _IOWR(DM_IOCTL, DM_DEV_CREATE_CMD, struct dm_ioctl)
  230. #define DM_DEV_REMOVE _IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD, struct dm_ioctl)
  231. #define DM_DEV_RENAME _IOWR(DM_IOCTL, DM_DEV_RENAME_CMD, struct dm_ioctl)
  232. #define DM_DEV_SUSPEND _IOWR(DM_IOCTL, DM_DEV_SUSPEND_CMD, struct dm_ioctl)
  233. #define DM_DEV_STATUS _IOWR(DM_IOCTL, DM_DEV_STATUS_CMD, struct dm_ioctl)
  234. #define DM_DEV_WAIT _IOWR(DM_IOCTL, DM_DEV_WAIT_CMD, struct dm_ioctl)
  235. #define DM_TABLE_LOAD _IOWR(DM_IOCTL, DM_TABLE_LOAD_CMD, struct dm_ioctl)
  236. #define DM_TABLE_CLEAR _IOWR(DM_IOCTL, DM_TABLE_CLEAR_CMD, struct dm_ioctl)
  237. #define DM_TABLE_DEPS _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, struct dm_ioctl)
  238. #define DM_TABLE_STATUS _IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, struct dm_ioctl)
  239. #define DM_LIST_VERSIONS _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, struct dm_ioctl)
  240. #define DM_TARGET_MSG _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, struct dm_ioctl)
  241. #define DM_VERSION_MAJOR 4
  242. #define DM_VERSION_MINOR 4
  243. #define DM_VERSION_PATCHLEVEL 0
  244. #define DM_VERSION_EXTRA "-ioctl (2005-01-12)"
  245. /* Status bits */
  246. #define DM_READONLY_FLAG (1 << 0) /* In/Out */
  247. #define DM_SUSPEND_FLAG (1 << 1) /* In/Out */
  248. #define DM_PERSISTENT_DEV_FLAG (1 << 3) /* In */
  249. /*
  250. * Flag passed into ioctl STATUS command to get table information
  251. * rather than current status.
  252. */
  253. #define DM_STATUS_TABLE_FLAG (1 << 4) /* In */
  254. /*
  255. * Flags that indicate whether a table is present in either of
  256. * the two table slots that a device has.
  257. */
  258. #define DM_ACTIVE_PRESENT_FLAG (1 << 5) /* Out */
  259. #define DM_INACTIVE_PRESENT_FLAG (1 << 6) /* Out */
  260. /*
  261. * Indicates that the buffer passed in wasn't big enough for the
  262. * results.
  263. */
  264. #define DM_BUFFER_FULL_FLAG (1 << 8) /* Out */
  265. /*
  266. * Set this to improve performance when you aren't going to use open_count
  267. */
  268. #define DM_SKIP_BDGET_FLAG (1 << 9) /* In */
  269. #endif /* _LINUX_DM_IOCTL_H */