ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / include / linux / dm-ioctl.h
1 /*
2  * Copyright (C) 2001 - 2003 Sistina Software (UK) Limited.
3  *
4  * This file is released under the LGPL.
5  */
6
7 #ifndef _LINUX_DM_IOCTL_V4_H
8 #define _LINUX_DM_IOCTL_V4_H
9
10 #include <linux/types.h>
11
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
16
17 /*
18  * A traditional ioctl interface for the device mapper.
19  *
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.
24  *
25  * DM_VERSION:
26  * Just get the version information for the ioctl interface.
27  *
28  * DM_REMOVE_ALL:
29  * Remove all dm devices, destroy all tables.  Only really used
30  * for debug.
31  *
32  * DM_LIST_DEVICES:
33  * Get a list of all the dm device names.
34  *
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.
40  *
41  * DM_DEV_REMOVE:
42  * Remove a device, destroy any tables.
43  *
44  * DM_DEV_RENAME:
45  * Rename a device.
46  *
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.
58  *
59  * DM_DEV_STATUS:
60  * Retrieves the status for the table in the 'active' slot.
61  *
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.
66  *
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.
70  *
71  * DM_TABLE_CLEAR:
72  * Destroy any table in the 'inactive' slot (ie. abort).
73  *
74  * DM_TABLE_DEPS:
75  * Return a set of device dependencies for the 'active' table.
76  *
77  * DM_TABLE_STATUS:
78  * Return the targets status for the 'active' table.
79  */
80
81 /*
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.
86  */
87 struct dm_ioctl {
88         /*
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.
93          *
94          * All clients of the ioctl interface should fill in the
95          * version number of the interface that they were
96          * compiled with.
97          *
98          * All recognised ioctl commands (ie. those that don't
99          * return -ENOTTY) fill out this field, even if the
100          * command failed.
101          */
102         uint32_t version[3];    /* in/out */
103         uint32_t data_size;     /* total size of data passed in
104                                  * including this struct */
105
106         uint32_t data_start;    /* offset to start of data
107                                  * relative to start of this struct */
108
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;
114
115         uint64_t dev;           /* in/out */
116
117         char name[DM_NAME_LEN]; /* device name */
118         char uuid[DM_UUID_LEN]; /* unique identifier for
119                                  * the block device */
120 };
121
122 /*
123  * Used to specify tables.  These structures appear after the
124  * dm_ioctl.
125  */
126 struct dm_target_spec {
127         uint64_t sector_start;
128         uint64_t length;
129         int32_t status;         /* used when reading from kernel only */
130
131         /*
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.
140          */
141         uint32_t next;
142
143         char target_type[DM_MAX_TYPE_NAME];
144
145         /*
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.
149          */
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 /*
162  * Used to get a list of all dm devices.
163  */
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];
169 };
170
171 /*
172  * Used to retrieve the target versions
173  */
174 struct dm_target_versions {
175         uint32_t next;
176         uint32_t version[3];
177
178         char name[0];
179 };
180
181 /*
182  * If you change this make sure you make the corresponding change
183  * to dm-ioctl.c:lookup_ioctl()
184  */
185 enum {
186         /* Top level cmds */
187         DM_VERSION_CMD = 0,
188         DM_REMOVE_ALL_CMD,
189         DM_LIST_DEVICES_CMD,
190
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,
198
199         /* Table level cmds */
200         DM_TABLE_LOAD_CMD,
201         DM_TABLE_CLEAR_CMD,
202         DM_TABLE_DEPS_CMD,
203         DM_TABLE_STATUS_CMD,
204
205         /* Added later */
206         DM_LIST_VERSIONS_CMD,
207 };
208
209 /*
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.
216  */
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)
222
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
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
236
237 #define DM_IOCTL 0xfd
238
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)
242
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)
249
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)
254
255 #define DM_LIST_VERSIONS _IOWR(DM_IOCTL, DM_LIST_VERSIONS_CMD, struct dm_ioctl)
256
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)"
261
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 */
266
267 /*
268  * Flag passed into ioctl STATUS command to get table information
269  * rather than current status.
270  */
271 #define DM_STATUS_TABLE_FLAG    (1 << 4) /* In */
272
273 /*
274  * Flags that indicate whether a table is present in either of
275  * the two table slots that a device has.
276  */
277 #define DM_ACTIVE_PRESENT_FLAG   (1 << 5) /* Out */
278 #define DM_INACTIVE_PRESENT_FLAG (1 << 6) /* Out */
279
280 /*
281  * Indicates that the buffer passed in wasn't big enough for the
282  * results.
283  */
284 #define DM_BUFFER_FULL_FLAG     (1 << 8) /* Out */
285
286 #endif                          /* _LINUX_DM_IOCTL_H */