dm-ioctl.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331
  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. * DM_DEV_SET_GEOMETRY:
  81. * Set the geometry of a device by passing in a string in this format:
  82. *
  83. * "cylinders heads sectors_per_track start_sector"
  84. *
  85. * Beware that CHS geometry is nearly obsolete and only provided
  86. * for compatibility with dm devices that can be booted by a PC
  87. * BIOS. See struct hd_geometry for range limits. Also note that
  88. * the geometry is erased if the device size changes.
  89. */
  90. /*
  91. * All ioctl arguments consist of a single chunk of memory, with
  92. * this structure at the start. If a uuid is specified any
  93. * lookup (eg. for a DM_INFO) will be done on that, *not* the
  94. * name.
  95. */
  96. struct dm_ioctl {
  97. /*
  98. * The version number is made up of three parts:
  99. * major - no backward or forward compatibility,
  100. * minor - only backwards compatible,
  101. * patch - both backwards and forwards compatible.
  102. *
  103. * All clients of the ioctl interface should fill in the
  104. * version number of the interface that they were
  105. * compiled with.
  106. *
  107. * All recognised ioctl commands (ie. those that don't
  108. * return -ENOTTY) fill out this field, even if the
  109. * command failed.
  110. */
  111. uint32_t version[3]; /* in/out */
  112. uint32_t data_size; /* total size of data passed in
  113. * including this struct */
  114. uint32_t data_start; /* offset to start of data
  115. * relative to start of this struct */
  116. uint32_t target_count; /* in/out */
  117. int32_t open_count; /* out */
  118. uint32_t flags; /* in/out */
  119. uint32_t event_nr; /* in/out */
  120. uint32_t padding;
  121. uint64_t dev; /* in/out */
  122. char name[DM_NAME_LEN]; /* device name */
  123. char uuid[DM_UUID_LEN]; /* unique identifier for
  124. * the block device */
  125. };
  126. /*
  127. * Used to specify tables. These structures appear after the
  128. * dm_ioctl.
  129. */
  130. struct dm_target_spec {
  131. uint64_t sector_start;
  132. uint64_t length;
  133. int32_t status; /* used when reading from kernel only */
  134. /*
  135. * Location of the next dm_target_spec.
  136. * - When specifying targets on a DM_TABLE_LOAD command, this value is
  137. * the number of bytes from the start of the "current" dm_target_spec
  138. * to the start of the "next" dm_target_spec.
  139. * - When retrieving targets on a DM_TABLE_STATUS command, this value
  140. * is the number of bytes from the start of the first dm_target_spec
  141. * (that follows the dm_ioctl struct) to the start of the "next"
  142. * dm_target_spec.
  143. */
  144. uint32_t next;
  145. char target_type[DM_MAX_TYPE_NAME];
  146. /*
  147. * Parameter string starts immediately after this object.
  148. * Be careful to add padding after string to ensure correct
  149. * alignment of subsequent dm_target_spec.
  150. */
  151. };
  152. /*
  153. * Used to retrieve the target dependencies.
  154. */
  155. struct dm_target_deps {
  156. uint32_t count; /* Array size */
  157. uint32_t padding; /* unused */
  158. uint64_t dev[0]; /* out */
  159. };
  160. /*
  161. * Used to get a list of all dm devices.
  162. */
  163. struct dm_name_list {
  164. uint64_t dev;
  165. uint32_t next; /* offset to the next record from
  166. the _start_ of this */
  167. char name[0];
  168. };
  169. /*
  170. * Used to retrieve the target versions
  171. */
  172. struct dm_target_versions {
  173. uint32_t next;
  174. uint32_t version[3];
  175. char name[0];
  176. };
  177. /*
  178. * Used to pass message to a target
  179. */
  180. struct dm_target_msg {
  181. uint64_t sector; /* Device sector */
  182. char message[0];
  183. };
  184. /*
  185. * If you change this make sure you make the corresponding change
  186. * to dm-ioctl.c:lookup_ioctl()
  187. */
  188. enum {
  189. /* Top level cmds */
  190. DM_VERSION_CMD = 0,
  191. DM_REMOVE_ALL_CMD,
  192. DM_LIST_DEVICES_CMD,
  193. /* device level cmds */
  194. DM_DEV_CREATE_CMD,
  195. DM_DEV_REMOVE_CMD,
  196. DM_DEV_RENAME_CMD,
  197. DM_DEV_SUSPEND_CMD,
  198. DM_DEV_STATUS_CMD,
  199. DM_DEV_WAIT_CMD,
  200. /* Table level cmds */
  201. DM_TABLE_LOAD_CMD,
  202. DM_TABLE_CLEAR_CMD,
  203. DM_TABLE_DEPS_CMD,
  204. DM_TABLE_STATUS_CMD,
  205. /* Added later */
  206. DM_LIST_VERSIONS_CMD,
  207. DM_TARGET_MSG_CMD,
  208. DM_DEV_SET_GEOMETRY_CMD
  209. };
  210. /*
  211. * The dm_ioctl struct passed into the ioctl is just the header
  212. * on a larger chunk of memory. On x86-64 and other
  213. * architectures the dm-ioctl struct will be padded to an 8 byte
  214. * boundary so the size will be different, which would change the
  215. * ioctl code - yes I really messed up. This hack forces these
  216. * architectures to have the correct ioctl code.
  217. */
  218. #ifdef CONFIG_COMPAT
  219. typedef char ioctl_struct[308];
  220. #define DM_VERSION_32 _IOWR(DM_IOCTL, DM_VERSION_CMD, ioctl_struct)
  221. #define DM_REMOVE_ALL_32 _IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD, ioctl_struct)
  222. #define DM_LIST_DEVICES_32 _IOWR(DM_IOCTL, DM_LIST_DEVICES_CMD, ioctl_struct)
  223. #define DM_DEV_CREATE_32 _IOWR(DM_IOCTL, DM_DEV_CREATE_CMD, ioctl_struct)
  224. #define DM_DEV_REMOVE_32 _IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD, ioctl_struct)
  225. #define DM_DEV_RENAME_32 _IOWR(DM_IOCTL, DM_DEV_RENAME_CMD, ioctl_struct)
  226. #define DM_DEV_SUSPEND_32 _IOWR(DM_IOCTL, DM_DEV_SUSPEND_CMD, ioctl_struct)
  227. #define DM_DEV_STATUS_32 _IOWR(DM_IOCTL, DM_DEV_STATUS_CMD, ioctl_struct)
  228. #define DM_DEV_WAIT_32 _IOWR(DM_IOCTL, DM_DEV_WAIT_CMD, ioctl_struct)
  229. #define DM_TABLE_LOAD_32 _IOWR(DM_IOCTL, DM_TABLE_LOAD_CMD, ioctl_struct)
  230. #define DM_TABLE_CLEAR_32 _IOWR(DM_IOCTL, DM_TABLE_CLEAR_CMD, ioctl_struct)
  231. #define DM_TABLE_DEPS_32 _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, ioctl_struct)
  232. #define DM_TABLE_STATUS_32 _IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, ioctl_struct)
  233. #define DM_LIST_VERSIONS_32 _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, ioctl_struct)
  234. #define DM_TARGET_MSG_32 _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, ioctl_struct)
  235. #define DM_DEV_SET_GEOMETRY_32 _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, ioctl_struct)
  236. #endif
  237. #define DM_IOCTL 0xfd
  238. #define DM_VERSION _IOWR(DM_IOCTL, DM_VERSION_CMD, struct dm_ioctl)
  239. #define DM_REMOVE_ALL _IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD, struct dm_ioctl)
  240. #define DM_LIST_DEVICES _IOWR(DM_IOCTL, DM_LIST_DEVICES_CMD, struct dm_ioctl)
  241. #define DM_DEV_CREATE _IOWR(DM_IOCTL, DM_DEV_CREATE_CMD, struct dm_ioctl)
  242. #define DM_DEV_REMOVE _IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD, struct dm_ioctl)
  243. #define DM_DEV_RENAME _IOWR(DM_IOCTL, DM_DEV_RENAME_CMD, struct dm_ioctl)
  244. #define DM_DEV_SUSPEND _IOWR(DM_IOCTL, DM_DEV_SUSPEND_CMD, struct dm_ioctl)
  245. #define DM_DEV_STATUS _IOWR(DM_IOCTL, DM_DEV_STATUS_CMD, struct dm_ioctl)
  246. #define DM_DEV_WAIT _IOWR(DM_IOCTL, DM_DEV_WAIT_CMD, struct dm_ioctl)
  247. #define DM_TABLE_LOAD _IOWR(DM_IOCTL, DM_TABLE_LOAD_CMD, struct dm_ioctl)
  248. #define DM_TABLE_CLEAR _IOWR(DM_IOCTL, DM_TABLE_CLEAR_CMD, struct dm_ioctl)
  249. #define DM_TABLE_DEPS _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, struct dm_ioctl)
  250. #define DM_TABLE_STATUS _IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, struct dm_ioctl)
  251. #define DM_LIST_VERSIONS _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, struct dm_ioctl)
  252. #define DM_TARGET_MSG _IOWR(DM_IOCTL, DM_TARGET_MSG_CMD, struct dm_ioctl)
  253. #define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl)
  254. #define DM_VERSION_MAJOR 4
  255. #define DM_VERSION_MINOR 11
  256. #define DM_VERSION_PATCHLEVEL 0
  257. #define DM_VERSION_EXTRA "-ioctl (2006-10-12)"
  258. /* Status bits */
  259. #define DM_READONLY_FLAG (1 << 0) /* In/Out */
  260. #define DM_SUSPEND_FLAG (1 << 1) /* In/Out */
  261. #define DM_PERSISTENT_DEV_FLAG (1 << 3) /* In */
  262. /*
  263. * Flag passed into ioctl STATUS command to get table information
  264. * rather than current status.
  265. */
  266. #define DM_STATUS_TABLE_FLAG (1 << 4) /* In */
  267. /*
  268. * Flags that indicate whether a table is present in either of
  269. * the two table slots that a device has.
  270. */
  271. #define DM_ACTIVE_PRESENT_FLAG (1 << 5) /* Out */
  272. #define DM_INACTIVE_PRESENT_FLAG (1 << 6) /* Out */
  273. /*
  274. * Indicates that the buffer passed in wasn't big enough for the
  275. * results.
  276. */
  277. #define DM_BUFFER_FULL_FLAG (1 << 8) /* Out */
  278. /*
  279. * This flag is now ignored.
  280. */
  281. #define DM_SKIP_BDGET_FLAG (1 << 9) /* In */
  282. /*
  283. * Set this to avoid attempting to freeze any filesystem when suspending.
  284. */
  285. #define DM_SKIP_LOCKFS_FLAG (1 << 10) /* In */
  286. /*
  287. * Set this to suspend without flushing queued ios.
  288. */
  289. #define DM_NOFLUSH_FLAG (1 << 11) /* In */
  290. #endif /* _LINUX_DM_IOCTL_H */