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