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