Subversion Repositories shark

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
422 giacomo 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
         * Offset in bytes (from the start of this struct) to
133
         * next target_spec.
134
         */
135
        uint32_t next;
136
 
137
        char target_type[DM_MAX_TYPE_NAME];
138
 
139
        /*
140
         * Parameter string starts immediately after this object.
141
         * Be careful to add padding after string to ensure correct
142
         * alignment of subsequent dm_target_spec.
143
         */
144
};
145
 
146
/*
147
 * Used to retrieve the target dependencies.
148
 */
149
struct dm_target_deps {
150
        uint32_t count; /* Array size */
151
        uint32_t padding;       /* unused */
152
        uint64_t dev[0];        /* out */
153
};
154
 
155
/*
156
 * Used to get a list of all dm devices.
157
 */
158
struct dm_name_list {
159
        uint64_t dev;
160
        uint32_t next;          /* offset to the next record from
161
                                   the _start_ of this */
162
        char name[0];
163
};
164
 
165
/*
166
 * If you change this make sure you make the corresponding change
167
 * to dm-ioctl.c:lookup_ioctl()
168
 */
169
enum {
170
        /* Top level cmds */
171
        DM_VERSION_CMD = 0,
172
        DM_REMOVE_ALL_CMD,
173
        DM_LIST_DEVICES_CMD,
174
 
175
        /* device level cmds */
176
        DM_DEV_CREATE_CMD,
177
        DM_DEV_REMOVE_CMD,
178
        DM_DEV_RENAME_CMD,
179
        DM_DEV_SUSPEND_CMD,
180
        DM_DEV_STATUS_CMD,
181
        DM_DEV_WAIT_CMD,
182
 
183
        /* Table level cmds */
184
        DM_TABLE_LOAD_CMD,
185
        DM_TABLE_CLEAR_CMD,
186
        DM_TABLE_DEPS_CMD,
187
        DM_TABLE_STATUS_CMD,
188
};
189
 
190
#define DM_IOCTL 0xfd
191
 
192
#define DM_VERSION       _IOWR(DM_IOCTL, DM_VERSION_CMD, struct dm_ioctl)
193
#define DM_REMOVE_ALL    _IOWR(DM_IOCTL, DM_REMOVE_ALL_CMD, struct dm_ioctl)
194
#define DM_LIST_DEVICES  _IOWR(DM_IOCTL, DM_LIST_DEVICES_CMD, struct dm_ioctl)
195
 
196
#define DM_DEV_CREATE    _IOWR(DM_IOCTL, DM_DEV_CREATE_CMD, struct dm_ioctl)
197
#define DM_DEV_REMOVE    _IOWR(DM_IOCTL, DM_DEV_REMOVE_CMD, struct dm_ioctl)
198
#define DM_DEV_RENAME    _IOWR(DM_IOCTL, DM_DEV_RENAME_CMD, struct dm_ioctl)
199
#define DM_DEV_SUSPEND   _IOWR(DM_IOCTL, DM_DEV_SUSPEND_CMD, struct dm_ioctl)
200
#define DM_DEV_STATUS    _IOWR(DM_IOCTL, DM_DEV_STATUS_CMD, struct dm_ioctl)
201
#define DM_DEV_WAIT      _IOWR(DM_IOCTL, DM_DEV_WAIT_CMD, struct dm_ioctl)
202
 
203
#define DM_TABLE_LOAD    _IOWR(DM_IOCTL, DM_TABLE_LOAD_CMD, struct dm_ioctl)
204
#define DM_TABLE_CLEAR   _IOWR(DM_IOCTL, DM_TABLE_CLEAR_CMD, struct dm_ioctl)
205
#define DM_TABLE_DEPS    _IOWR(DM_IOCTL, DM_TABLE_DEPS_CMD, struct dm_ioctl)
206
#define DM_TABLE_STATUS  _IOWR(DM_IOCTL, DM_TABLE_STATUS_CMD, struct dm_ioctl)
207
 
208
#define DM_VERSION_MAJOR        4
209
#define DM_VERSION_MINOR        0
210
#define DM_VERSION_PATCHLEVEL   0
211
#define DM_VERSION_EXTRA        "-ioctl (2003-06-04)"
212
 
213
/* Status bits */
214
#define DM_READONLY_FLAG        (1 << 0) /* In/Out */
215
#define DM_SUSPEND_FLAG         (1 << 1) /* In/Out */
216
#define DM_PERSISTENT_DEV_FLAG  (1 << 3) /* In */
217
 
218
/*
219
 * Flag passed into ioctl STATUS command to get table information
220
 * rather than current status.
221
 */
222
#define DM_STATUS_TABLE_FLAG    (1 << 4) /* In */
223
 
224
/*
225
 * Flags that indicate whether a table is present in either of
226
 * the two table slots that a device has.
227
 */
228
#define DM_ACTIVE_PRESENT_FLAG   (1 << 5) /* Out */
229
#define DM_INACTIVE_PRESENT_FLAG (1 << 6) /* Out */
230
 
231
/*
232
 * Indicates that the buffer passed in wasn't big enough for the
233
 * results.
234
 */
235
#define DM_BUFFER_FULL_FLAG     (1 << 8) /* Out */
236
 
237
#endif                          /* _LINUX_DM_IOCTL_H */