Blame view

include/mtd/ubi-user.h 15.1 KB
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
1
  /*
a1452a377   David Woodhouse   mtd: Update copyr...
2
   * Copyright © International Business Machines Corp., 2006
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License as published by
   * the Free Software Foundation; either version 2 of the License, or
   * (at your option) any later version.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
   * the GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
   *
   * Author: Artem Bityutskiy (Битюцкий Артём)
   */
  
  #ifndef __UBI_USER_H__
  #define __UBI_USER_H__
ccef7ab53   Arnd Bergmann   make MTD headers ...
23
  #include <linux/types.h>
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
24
  /*
9b79cc0f8   Artem Bityutskiy   UBI: introduce at...
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
   * UBI device creation (the same as MTD device attachment)
   * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   *
   * MTD devices may be attached using %UBI_IOCATT ioctl command of the UBI
   * control device. The caller has to properly fill and pass
   * &struct ubi_attach_req object - UBI will attach the MTD device specified in
   * the request and return the newly created UBI device number as the ioctl
   * return value.
   *
   * UBI device deletion (the same as MTD device detachment)
   * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   *
   * An UBI device maybe deleted with %UBI_IOCDET ioctl command of the UBI
   * control device.
   *
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
40
41
42
   * UBI volume creation
   * ~~~~~~~~~~~~~~~~~~~
   *
f7fc6f3f3   Artem Bityutskiy   UBI: improve ioct...
43
   * UBI volumes are created via the %UBI_IOCMKVOL ioctl command of UBI character
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
44
   * device. A &struct ubi_mkvol_req object has to be properly filled and a
f7fc6f3f3   Artem Bityutskiy   UBI: improve ioct...
45
   * pointer to it has to be passed to the ioctl.
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
46
47
48
49
   *
   * UBI volume deletion
   * ~~~~~~~~~~~~~~~~~~~
   *
f7fc6f3f3   Artem Bityutskiy   UBI: improve ioct...
50
   * To delete a volume, the %UBI_IOCRMVOL ioctl command of the UBI character
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
51
   * device should be used. A pointer to the 32-bit volume ID hast to be passed
f7fc6f3f3   Artem Bityutskiy   UBI: improve ioct...
52
   * to the ioctl.
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
53
54
55
56
   *
   * UBI volume re-size
   * ~~~~~~~~~~~~~~~~~~
   *
f7fc6f3f3   Artem Bityutskiy   UBI: improve ioct...
57
   * To re-size a volume, the %UBI_IOCRSVOL ioctl command of the UBI character
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
58
   * device should be used. A &struct ubi_rsvol_req object has to be properly
f7fc6f3f3   Artem Bityutskiy   UBI: improve ioct...
59
   * filled and a pointer to it has to be passed to the ioctl.
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
60
   *
f40ac9cdf   Artem Bityutskiy   UBI: implement mu...
61
62
63
64
65
   * UBI volumes re-name
   * ~~~~~~~~~~~~~~~~~~~
   *
   * To re-name several volumes atomically at one go, the %UBI_IOCRNVOL command
   * of the UBI character device should be used. A &struct ubi_rnvol_req object
f7fc6f3f3   Artem Bityutskiy   UBI: improve ioct...
66
   * has to be properly filled and a pointer to it has to be passed to the ioctl.
f40ac9cdf   Artem Bityutskiy   UBI: implement mu...
67
   *
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
68
69
70
   * UBI volume update
   * ~~~~~~~~~~~~~~~~~
   *
f7fc6f3f3   Artem Bityutskiy   UBI: improve ioct...
71
   * Volume update should be done via the %UBI_IOCVOLUP ioctl command of the
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
72
   * corresponding UBI volume character device. A pointer to a 64-bit update
f7fc6f3f3   Artem Bityutskiy   UBI: improve ioct...
73
   * size should be passed to the ioctl. After this, UBI expects user to write
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
74
75
76
77
78
79
80
81
   * this number of bytes to the volume character device. The update is finished
   * when the claimed number of bytes is passed. So, the volume update sequence
   * is something like:
   *
   * fd = open("/dev/my_volume");
   * ioctl(fd, UBI_IOCVOLUP, &image_size);
   * write(fd, buf, image_size);
   * close(fd);
866136827   Artem Bityutskiy   UBI: introduce at...
82
   *
f7fc6f3f3   Artem Bityutskiy   UBI: improve ioct...
83
   * Logical eraseblock erase
866136827   Artem Bityutskiy   UBI: introduce at...
84
85
   * ~~~~~~~~~~~~~~~~~~~~~~~~
   *
f7fc6f3f3   Artem Bityutskiy   UBI: improve ioct...
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
   * To erase a logical eraseblock, the %UBI_IOCEBER ioctl command of the
   * corresponding UBI volume character device should be used. This command
   * unmaps the requested logical eraseblock, makes sure the corresponding
   * physical eraseblock is successfully erased, and returns.
   *
   * Atomic logical eraseblock change
   * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   *
   * Atomic logical eraseblock change operation is called using the %UBI_IOCEBCH
   * ioctl command of the corresponding UBI volume character device. A pointer to
   * a &struct ubi_leb_change_req object has to be passed to the ioctl. Then the
   * user is expected to write the requested amount of bytes (similarly to what
   * should be done in case of the "volume update" ioctl).
   *
   * Logical eraseblock map
   * ~~~~~~~~~~~~~~~~~~~~~
   *
   * To map a logical eraseblock to a physical eraseblock, the %UBI_IOCEBMAP
   * ioctl command should be used. A pointer to a &struct ubi_map_req object is
   * expected to be passed. The ioctl maps the requested logical eraseblock to
   * a physical eraseblock and returns.  Only non-mapped logical eraseblocks can
   * be mapped. If the logical eraseblock specified in the request is already
   * mapped to a physical eraseblock, the ioctl fails and returns error.
   *
   * Logical eraseblock unmap
   * ~~~~~~~~~~~~~~~~~~~~~~~~
   *
   * To unmap a logical eraseblock to a physical eraseblock, the %UBI_IOCEBUNMAP
   * ioctl command should be used. The ioctl unmaps the logical eraseblocks,
   * schedules corresponding physical eraseblock for erasure, and returns. Unlike
   * the "LEB erase" command, it does not wait for the physical eraseblock being
   * erased. Note, the side effect of this is that if an unclean reboot happens
   * after the unmap ioctl returns, you may find the LEB mapped again to the same
   * physical eraseblock after the UBI is run again.
   *
   * Check if logical eraseblock is mapped
   * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   *
   * To check if a logical eraseblock is mapped to a physical eraseblock, the
   * %UBI_IOCEBISMAP ioctl command should be used. It returns %0 if the LEB is
   * not mapped, and %1 if it is mapped.
766fb95ba   Sidney Amani   UBI: allow direct...
127
128
129
130
131
   *
   * Set an UBI volume property
   * ~~~~~~~~~~~~~~~~~~~~~~~~~
   *
   * To set an UBI volume property the %UBI_IOCSETPROP ioctl command should be
6748482f4   Artem Bityutskiy   UBI: re-name set ...
132
   * used. A pointer to a &struct ubi_set_vol_prop_req object is expected to be
766fb95ba   Sidney Amani   UBI: allow direct...
133
134
   * passed. The object describes which property should be set, and to which value
   * it should be set.
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
135
136
137
   */
  
  /*
9b79cc0f8   Artem Bityutskiy   UBI: introduce at...
138
139
140
   * When a new UBI volume or UBI device is created, users may either specify the
   * volume/device number they want to create or to let UBI automatically assign
   * the number using these constants.
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
141
142
   */
  #define UBI_VOL_NUM_AUTO (-1)
9b79cc0f8   Artem Bityutskiy   UBI: introduce at...
143
  #define UBI_DEV_NUM_AUTO (-1)
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
144
145
146
  
  /* Maximum volume name length */
  #define UBI_MAX_VOLUME_NAME 127
f7fc6f3f3   Artem Bityutskiy   UBI: improve ioct...
147
  /* ioctl commands of UBI character devices */
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
148
149
150
151
152
153
  
  #define UBI_IOC_MAGIC 'o'
  
  /* Create an UBI volume */
  #define UBI_IOCMKVOL _IOW(UBI_IOC_MAGIC, 0, struct ubi_mkvol_req)
  /* Remove an UBI volume */
ccef7ab53   Arnd Bergmann   make MTD headers ...
154
  #define UBI_IOCRMVOL _IOW(UBI_IOC_MAGIC, 1, __s32)
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
155
156
  /* Re-size an UBI volume */
  #define UBI_IOCRSVOL _IOW(UBI_IOC_MAGIC, 2, struct ubi_rsvol_req)
f40ac9cdf   Artem Bityutskiy   UBI: implement mu...
157
158
  /* Re-name volumes */
  #define UBI_IOCRNVOL _IOW(UBI_IOC_MAGIC, 3, struct ubi_rnvol_req)
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
159

f7fc6f3f3   Artem Bityutskiy   UBI: improve ioct...
160
  /* ioctl commands of the UBI control character device */
9b79cc0f8   Artem Bityutskiy   UBI: introduce at...
161
162
163
164
165
166
  
  #define UBI_CTRL_IOC_MAGIC 'o'
  
  /* Attach an MTD device */
  #define UBI_IOCATT _IOW(UBI_CTRL_IOC_MAGIC, 64, struct ubi_attach_req)
  /* Detach an MTD device */
ccef7ab53   Arnd Bergmann   make MTD headers ...
167
  #define UBI_IOCDET _IOW(UBI_CTRL_IOC_MAGIC, 65, __s32)
9b79cc0f8   Artem Bityutskiy   UBI: introduce at...
168

f7fc6f3f3   Artem Bityutskiy   UBI: improve ioct...
169
  /* ioctl commands of UBI volume character devices */
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
170
171
172
173
  
  #define UBI_VOL_IOC_MAGIC 'O'
  
  /* Start UBI volume update */
ccef7ab53   Arnd Bergmann   make MTD headers ...
174
  #define UBI_IOCVOLUP _IOW(UBI_VOL_IOC_MAGIC, 0, __s64)
f7fc6f3f3   Artem Bityutskiy   UBI: improve ioct...
175
  /* LEB erasure command, used for debugging, disabled by default */
ccef7ab53   Arnd Bergmann   make MTD headers ...
176
  #define UBI_IOCEBER _IOW(UBI_VOL_IOC_MAGIC, 1, __s32)
f7fc6f3f3   Artem Bityutskiy   UBI: improve ioct...
177
  /* Atomic LEB change command */
ccef7ab53   Arnd Bergmann   make MTD headers ...
178
  #define UBI_IOCEBCH _IOW(UBI_VOL_IOC_MAGIC, 2, __s32)
f7fc6f3f3   Artem Bityutskiy   UBI: improve ioct...
179
  /* Map LEB command */
141e6ebd1   Corentin Chary   UBI: add ioctl fo...
180
  #define UBI_IOCEBMAP _IOW(UBI_VOL_IOC_MAGIC, 3, struct ubi_map_req)
f7fc6f3f3   Artem Bityutskiy   UBI: improve ioct...
181
  /* Unmap LEB command */
ccef7ab53   Arnd Bergmann   make MTD headers ...
182
  #define UBI_IOCEBUNMAP _IOW(UBI_VOL_IOC_MAGIC, 4, __s32)
f7fc6f3f3   Artem Bityutskiy   UBI: improve ioct...
183
  /* Check if LEB is mapped command */
ccef7ab53   Arnd Bergmann   make MTD headers ...
184
  #define UBI_IOCEBISMAP _IOR(UBI_VOL_IOC_MAGIC, 5, __s32)
766fb95ba   Sidney Amani   UBI: allow direct...
185
  /* Set an UBI volume property */
6748482f4   Artem Bityutskiy   UBI: re-name set ...
186
187
  #define UBI_IOCSETVOLPROP _IOW(UBI_VOL_IOC_MAGIC, 6, \
  			       struct ubi_set_vol_prop_req)
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
188

9b79cc0f8   Artem Bityutskiy   UBI: introduce at...
189
190
  /* Maximum MTD device name length supported by UBI */
  #define MAX_UBI_MTD_NAME_LEN 127
f40ac9cdf   Artem Bityutskiy   UBI: implement mu...
191
192
  /* Maximum amount of UBI volumes that can be re-named at one go */
  #define UBI_MAX_RNVOL 32
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
193
  /*
866136827   Artem Bityutskiy   UBI: introduce at...
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
   * UBI data type hint constants.
   *
   * UBI_LONGTERM: long-term data
   * UBI_SHORTTERM: short-term data
   * UBI_UNKNOWN: data persistence is unknown
   *
   * These constants are used when data is written to UBI volumes in order to
   * help the UBI wear-leveling unit to find more appropriate physical
   * eraseblocks.
   */
  enum {
  	UBI_LONGTERM  = 1,
  	UBI_SHORTTERM = 2,
  	UBI_UNKNOWN   = 3,
  };
  
  /*
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
211
212
213
214
215
216
217
   * UBI volume type constants.
   *
   * @UBI_DYNAMIC_VOLUME: dynamic volume
   * @UBI_STATIC_VOLUME:  static volume
   */
  enum {
  	UBI_DYNAMIC_VOLUME = 3,
866136827   Artem Bityutskiy   UBI: introduce at...
218
  	UBI_STATIC_VOLUME  = 4,
9b79cc0f8   Artem Bityutskiy   UBI: introduce at...
219
  };
766fb95ba   Sidney Amani   UBI: allow direct...
220
  /*
e8e088de3   Artem Bityutskiy   UBI: cleanup comm...
221
   * UBI set volume property ioctl constants.
766fb95ba   Sidney Amani   UBI: allow direct...
222
   *
e8e088de3   Artem Bityutskiy   UBI: cleanup comm...
223
224
225
   * @UBI_VOL_PROP_DIRECT_WRITE: allow (any non-zero value) or disallow (value 0)
   *                             user to directly write and erase individual
   *                             eraseblocks on dynamic volumes
766fb95ba   Sidney Amani   UBI: allow direct...
226
227
   */
  enum {
e8e088de3   Artem Bityutskiy   UBI: cleanup comm...
228
  	UBI_VOL_PROP_DIRECT_WRITE = 1,
766fb95ba   Sidney Amani   UBI: allow direct...
229
  };
9b79cc0f8   Artem Bityutskiy   UBI: introduce at...
230
231
232
233
234
235
236
237
238
  /**
   * struct ubi_attach_req - attach MTD device request.
   * @ubi_num: UBI device number to create
   * @mtd_num: MTD device number to attach
   * @vid_hdr_offset: VID header offset (use defaults if %0)
   * @padding: reserved for future, not used, has to be zeroed
   *
   * This data structure is used to specify MTD device UBI has to attach and the
   * parameters it has to use. The number which should be assigned to the new UBI
866136827   Artem Bityutskiy   UBI: introduce at...
239
   * device is passed in @ubi_num. UBI may automatically assign the number if
9b79cc0f8   Artem Bityutskiy   UBI: introduce at...
240
241
242
243
244
245
246
247
248
249
   * @UBI_DEV_NUM_AUTO is passed. In this case, the device number is returned in
   * @ubi_num.
   *
   * Most applications should pass %0 in @vid_hdr_offset to make UBI use default
   * offset of the VID header within physical eraseblocks. The default offset is
   * the next min. I/O unit after the EC header. For example, it will be offset
   * 512 in case of a 512 bytes page NAND flash with no sub-page support. Or
   * it will be 512 in case of a 2KiB page NAND flash with 4 512-byte sub-pages.
   *
   * But in rare cases, if this optimizes things, the VID header may be placed to
9c9ec1477   Artem Bityutskiy   UBI: fix checkpat...
250
251
252
253
254
255
256
257
   * a different offset. For example, the boot-loader might do things faster if
   * the VID header sits at the end of the first 2KiB NAND page with 4 sub-pages.
   * As the boot-loader would not normally need to read EC headers (unless it
   * needs UBI in RW mode), it might be faster to calculate ECC. This is weird
   * example, but it real-life example. So, in this example, @vid_hdr_offer would
   * be 2KiB-64 bytes = 1984. Note, that this position is not even 512-bytes
   * aligned, which is OK, as UBI is clever enough to realize this is 4th
   * sub-page of the first page and add needed padding.
9b79cc0f8   Artem Bityutskiy   UBI: introduce at...
258
259
   */
  struct ubi_attach_req {
ccef7ab53   Arnd Bergmann   make MTD headers ...
260
261
262
263
  	__s32 ubi_num;
  	__s32 mtd_num;
  	__s32 vid_hdr_offset;
  	__s8 padding[12];
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
264
265
266
267
  };
  
  /**
   * struct ubi_mkvol_req - volume description data structure used in
9b79cc0f8   Artem Bityutskiy   UBI: introduce at...
268
   *                        volume creation requests.
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
269
270
271
272
   * @vol_id: volume number
   * @alignment: volume alignment
   * @bytes: volume size in bytes
   * @vol_type: volume type (%UBI_DYNAMIC_VOLUME or %UBI_STATIC_VOLUME)
9b79cc0f8   Artem Bityutskiy   UBI: introduce at...
273
   * @padding1: reserved for future, not used, has to be zeroed
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
274
   * @name_len: volume name length
9b79cc0f8   Artem Bityutskiy   UBI: introduce at...
275
   * @padding2: reserved for future, not used, has to be zeroed
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
276
277
   * @name: volume name
   *
866136827   Artem Bityutskiy   UBI: introduce at...
278
   * This structure is used by user-space programs when creating new volumes. The
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
   * @used_bytes field is only necessary when creating static volumes.
   *
   * The @alignment field specifies the required alignment of the volume logical
   * eraseblock. This means, that the size of logical eraseblocks will be aligned
   * to this number, i.e.,
   *	(UBI device logical eraseblock size) mod (@alignment) = 0.
   *
   * To put it differently, the logical eraseblock of this volume may be slightly
   * shortened in order to make it properly aligned. The alignment has to be
   * multiple of the flash minimal input/output unit, or %1 to utilize the entire
   * available space of logical eraseblocks.
   *
   * The @alignment field may be useful, for example, when one wants to maintain
   * a block device on top of an UBI volume. In this case, it is desirable to fit
   * an integer number of blocks in logical eraseblocks of this UBI volume. With
   * alignment it is possible to update this volume using plane UBI volume image
   * BLOBs, without caring about how to properly align them.
   */
  struct ubi_mkvol_req {
ccef7ab53   Arnd Bergmann   make MTD headers ...
298
299
300
301
302
303
304
  	__s32 vol_id;
  	__s32 alignment;
  	__s64 bytes;
  	__s8 vol_type;
  	__s8 padding1;
  	__s16 name_len;
  	__s8 padding2[4];
9b79cc0f8   Artem Bityutskiy   UBI: introduce at...
305
  	char name[UBI_MAX_VOLUME_NAME + 1];
3627924ac   Artem Bityutskiy   UBI: use __packed...
306
  } __packed;
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
307
308
309
310
311
312
313
314
  
  /**
   * struct ubi_rsvol_req - a data structure used in volume re-size requests.
   * @vol_id: ID of the volume to re-size
   * @bytes: new size of the volume in bytes
   *
   * Re-sizing is possible for both dynamic and static volumes. But while dynamic
   * volumes may be re-sized arbitrarily, static volumes cannot be made to be
025dfdafe   Frederik Schwarzer   trivial: fix then...
315
   * smaller than the number of bytes they bear. To arbitrarily shrink a static
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
316
317
318
319
   * volume, it must be wiped out first (by means of volume update operation with
   * zero number of bytes).
   */
  struct ubi_rsvol_req {
ccef7ab53   Arnd Bergmann   make MTD headers ...
320
321
  	__s64 bytes;
  	__s32 vol_id;
3627924ac   Artem Bityutskiy   UBI: use __packed...
322
  } __packed;
801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
323

866136827   Artem Bityutskiy   UBI: introduce at...
324
  /**
f40ac9cdf   Artem Bityutskiy   UBI: implement mu...
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
   * struct ubi_rnvol_req - volumes re-name request.
   * @count: count of volumes to re-name
   * @padding1:  reserved for future, not used, has to be zeroed
   * @vol_id: ID of the volume to re-name
   * @name_len: name length
   * @padding2:  reserved for future, not used, has to be zeroed
   * @name: new volume name
   *
   * UBI allows to re-name up to %32 volumes at one go. The count of volumes to
   * re-name is specified in the @count field. The ID of the volumes to re-name
   * and the new names are specified in the @vol_id and @name fields.
   *
   * The UBI volume re-name operation is atomic, which means that should power cut
   * happen, the volumes will have either old name or new name. So the possible
   * use-cases of this command is atomic upgrade. Indeed, to upgrade, say, volumes
   * A and B one may create temporary volumes %A1 and %B1 with the new contents,
   * then atomically re-name A1->A and B1->B, in which case old %A and %B will
   * be removed.
   *
   * If it is not desirable to remove old A and B, the re-name request has to
   * contain 4 entries: A1->A, A->A1, B1->B, B->B1, in which case old A1 and B1
   * become A and B, and old A and B will become A1 and B1.
   *
   * It is also OK to request: A1->A, A1->X, B1->B, B->Y, in which case old A1
   * and B1 become A and B, and old A and B become X and Y.
   *
   * In other words, in case of re-naming into an existing volume name, the
   * existing volume is removed, unless it is re-named as well at the same
   * re-name request.
   */
  struct ubi_rnvol_req {
ccef7ab53   Arnd Bergmann   make MTD headers ...
356
357
  	__s32 count;
  	__s8 padding1[12];
f40ac9cdf   Artem Bityutskiy   UBI: implement mu...
358
  	struct {
ccef7ab53   Arnd Bergmann   make MTD headers ...
359
360
361
  		__s32 vol_id;
  		__s16 name_len;
  		__s8  padding2[2];
f40ac9cdf   Artem Bityutskiy   UBI: implement mu...
362
363
  		char    name[UBI_MAX_VOLUME_NAME + 1];
  	} ents[UBI_MAX_RNVOL];
3627924ac   Artem Bityutskiy   UBI: use __packed...
364
  } __packed;
f40ac9cdf   Artem Bityutskiy   UBI: implement mu...
365
366
  
  /**
f7fc6f3f3   Artem Bityutskiy   UBI: improve ioct...
367
368
   * struct ubi_leb_change_req - a data structure used in atomic LEB change
   *                             requests.
866136827   Artem Bityutskiy   UBI: introduce at...
369
370
371
372
373
374
   * @lnum: logical eraseblock number to change
   * @bytes: how many bytes will be written to the logical eraseblock
   * @dtype: data type (%UBI_LONGTERM, %UBI_SHORTTERM, %UBI_UNKNOWN)
   * @padding: reserved for future, not used, has to be zeroed
   */
  struct ubi_leb_change_req {
ccef7ab53   Arnd Bergmann   make MTD headers ...
375
376
377
378
  	__s32 lnum;
  	__s32 bytes;
  	__s8  dtype;
  	__s8  padding[7];
3627924ac   Artem Bityutskiy   UBI: use __packed...
379
  } __packed;
866136827   Artem Bityutskiy   UBI: introduce at...
380

141e6ebd1   Corentin Chary   UBI: add ioctl fo...
381
  /**
f7fc6f3f3   Artem Bityutskiy   UBI: improve ioct...
382
   * struct ubi_map_req - a data structure used in map LEB requests.
141e6ebd1   Corentin Chary   UBI: add ioctl fo...
383
384
385
386
387
   * @lnum: logical eraseblock number to unmap
   * @dtype: data type (%UBI_LONGTERM, %UBI_SHORTTERM, %UBI_UNKNOWN)
   * @padding: reserved for future, not used, has to be zeroed
   */
  struct ubi_map_req {
ccef7ab53   Arnd Bergmann   make MTD headers ...
388
389
390
  	__s32 lnum;
  	__s8  dtype;
  	__s8  padding[3];
3627924ac   Artem Bityutskiy   UBI: use __packed...
391
  } __packed;
141e6ebd1   Corentin Chary   UBI: add ioctl fo...
392

766fb95ba   Sidney Amani   UBI: allow direct...
393
394
  
  /**
e8e088de3   Artem Bityutskiy   UBI: cleanup comm...
395
   * struct ubi_set_vol_prop_req - a data structure used to set an UBI volume
6748482f4   Artem Bityutskiy   UBI: re-name set ...
396
397
   *                               property.
   * @property: property to set (%UBI_VOL_PROP_DIRECT_WRITE)
766fb95ba   Sidney Amani   UBI: allow direct...
398
399
400
   * @padding: reserved for future, not used, has to be zeroed
   * @value: value to set
   */
6748482f4   Artem Bityutskiy   UBI: re-name set ...
401
  struct ubi_set_vol_prop_req {
feddbb34e   Artem Bityutskiy   UBI: fix minor st...
402
403
404
  	__u8  property;
  	__u8  padding[7];
  	__u64 value;
3627924ac   Artem Bityutskiy   UBI: use __packed...
405
  }  __packed;
766fb95ba   Sidney Amani   UBI: allow direct...
406

801c135ce   Artem B. Bityutskiy   UBI: Unsorted Blo...
407
  #endif /* __UBI_USER_H__ */