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