diff options
Diffstat (limited to 'include/mtd')
-rw-r--r-- | include/mtd/ubi-user.h | 76 |
1 files changed, 65 insertions, 11 deletions
diff --git a/include/mtd/ubi-user.h b/include/mtd/ubi-user.h index a7421f130cc0..ccdc562e444e 100644 --- a/include/mtd/ubi-user.h +++ b/include/mtd/ubi-user.h | |||
@@ -58,6 +58,13 @@ | |||
58 | * device should be used. A &struct ubi_rsvol_req object has to be properly | 58 | * device should be used. A &struct ubi_rsvol_req object has to be properly |
59 | * filled and a pointer to it has to be passed to the IOCTL. | 59 | * filled and a pointer to it has to be passed to the IOCTL. |
60 | * | 60 | * |
61 | * UBI volumes re-name | ||
62 | * ~~~~~~~~~~~~~~~~~~~ | ||
63 | * | ||
64 | * To re-name several volumes atomically at one go, the %UBI_IOCRNVOL command | ||
65 | * of the UBI character device should be used. A &struct ubi_rnvol_req object | ||
66 | * has to be properly filled and a pointer to it has to be passed to the IOCTL. | ||
67 | * | ||
61 | * UBI volume update | 68 | * UBI volume update |
62 | * ~~~~~~~~~~~~~~~~~ | 69 | * ~~~~~~~~~~~~~~~~~ |
63 | * | 70 | * |
@@ -104,6 +111,8 @@ | |||
104 | #define UBI_IOCRMVOL _IOW(UBI_IOC_MAGIC, 1, int32_t) | 111 | #define UBI_IOCRMVOL _IOW(UBI_IOC_MAGIC, 1, int32_t) |
105 | /* Re-size an UBI volume */ | 112 | /* Re-size an UBI volume */ |
106 | #define UBI_IOCRSVOL _IOW(UBI_IOC_MAGIC, 2, struct ubi_rsvol_req) | 113 | #define UBI_IOCRSVOL _IOW(UBI_IOC_MAGIC, 2, struct ubi_rsvol_req) |
114 | /* Re-name volumes */ | ||
115 | #define UBI_IOCRNVOL _IOW(UBI_IOC_MAGIC, 3, struct ubi_rnvol_req) | ||
107 | 116 | ||
108 | /* IOCTL commands of the UBI control character device */ | 117 | /* IOCTL commands of the UBI control character device */ |
109 | 118 | ||
@@ -128,6 +137,9 @@ | |||
128 | /* Maximum MTD device name length supported by UBI */ | 137 | /* Maximum MTD device name length supported by UBI */ |
129 | #define MAX_UBI_MTD_NAME_LEN 127 | 138 | #define MAX_UBI_MTD_NAME_LEN 127 |
130 | 139 | ||
140 | /* Maximum amount of UBI volumes that can be re-named at one go */ | ||
141 | #define UBI_MAX_RNVOL 32 | ||
142 | |||
131 | /* | 143 | /* |
132 | * UBI data type hint constants. | 144 | * UBI data type hint constants. |
133 | * | 145 | * |
@@ -176,20 +188,20 @@ enum { | |||
176 | * it will be 512 in case of a 2KiB page NAND flash with 4 512-byte sub-pages. | 188 | * it will be 512 in case of a 2KiB page NAND flash with 4 512-byte sub-pages. |
177 | * | 189 | * |
178 | * But in rare cases, if this optimizes things, the VID header may be placed to | 190 | * But in rare cases, if this optimizes things, the VID header may be placed to |
179 | * a different offset. For example, the boot-loader might do things faster if the | 191 | * a different offset. For example, the boot-loader might do things faster if |
180 | * VID header sits at the end of the first 2KiB NAND page with 4 sub-pages. As | 192 | * the VID header sits at the end of the first 2KiB NAND page with 4 sub-pages. |
181 | * the boot-loader would not normally need to read EC headers (unless it needs | 193 | * As the boot-loader would not normally need to read EC headers (unless it |
182 | * UBI in RW mode), it might be faster to calculate ECC. This is weird example, | 194 | * needs UBI in RW mode), it might be faster to calculate ECC. This is weird |
183 | * but it real-life example. So, in this example, @vid_hdr_offer would be | 195 | * example, but it real-life example. So, in this example, @vid_hdr_offer would |
184 | * 2KiB-64 bytes = 1984. Note, that this position is not even 512-bytes | 196 | * be 2KiB-64 bytes = 1984. Note, that this position is not even 512-bytes |
185 | * aligned, which is OK, as UBI is clever enough to realize this is 4th sub-page | 197 | * aligned, which is OK, as UBI is clever enough to realize this is 4th |
186 | * of the first page and add needed padding. | 198 | * sub-page of the first page and add needed padding. |
187 | */ | 199 | */ |
188 | struct ubi_attach_req { | 200 | struct ubi_attach_req { |
189 | int32_t ubi_num; | 201 | int32_t ubi_num; |
190 | int32_t mtd_num; | 202 | int32_t mtd_num; |
191 | int32_t vid_hdr_offset; | 203 | int32_t vid_hdr_offset; |
192 | uint8_t padding[12]; | 204 | int8_t padding[12]; |
193 | }; | 205 | }; |
194 | 206 | ||
195 | /** | 207 | /** |
@@ -251,6 +263,48 @@ struct ubi_rsvol_req { | |||
251 | } __attribute__ ((packed)); | 263 | } __attribute__ ((packed)); |
252 | 264 | ||
253 | /** | 265 | /** |
266 | * struct ubi_rnvol_req - volumes re-name request. | ||
267 | * @count: count of volumes to re-name | ||
268 | * @padding1: reserved for future, not used, has to be zeroed | ||
269 | * @vol_id: ID of the volume to re-name | ||
270 | * @name_len: name length | ||
271 | * @padding2: reserved for future, not used, has to be zeroed | ||
272 | * @name: new volume name | ||
273 | * | ||
274 | * UBI allows to re-name up to %32 volumes at one go. The count of volumes to | ||
275 | * re-name is specified in the @count field. The ID of the volumes to re-name | ||
276 | * and the new names are specified in the @vol_id and @name fields. | ||
277 | * | ||
278 | * The UBI volume re-name operation is atomic, which means that should power cut | ||
279 | * happen, the volumes will have either old name or new name. So the possible | ||
280 | * use-cases of this command is atomic upgrade. Indeed, to upgrade, say, volumes | ||
281 | * A and B one may create temporary volumes %A1 and %B1 with the new contents, | ||
282 | * then atomically re-name A1->A and B1->B, in which case old %A and %B will | ||
283 | * be removed. | ||
284 | * | ||
285 | * If it is not desirable to remove old A and B, the re-name request has to | ||
286 | * contain 4 entries: A1->A, A->A1, B1->B, B->B1, in which case old A1 and B1 | ||
287 | * become A and B, and old A and B will become A1 and B1. | ||
288 | * | ||
289 | * It is also OK to request: A1->A, A1->X, B1->B, B->Y, in which case old A1 | ||
290 | * and B1 become A and B, and old A and B become X and Y. | ||
291 | * | ||
292 | * In other words, in case of re-naming into an existing volume name, the | ||
293 | * existing volume is removed, unless it is re-named as well at the same | ||
294 | * re-name request. | ||
295 | */ | ||
296 | struct ubi_rnvol_req { | ||
297 | int32_t count; | ||
298 | int8_t padding1[12]; | ||
299 | struct { | ||
300 | int32_t vol_id; | ||
301 | int16_t name_len; | ||
302 | int8_t padding2[2]; | ||
303 | char name[UBI_MAX_VOLUME_NAME + 1]; | ||
304 | } ents[UBI_MAX_RNVOL]; | ||
305 | } __attribute__ ((packed)); | ||
306 | |||
307 | /** | ||
254 | * struct ubi_leb_change_req - a data structure used in atomic logical | 308 | * struct ubi_leb_change_req - a data structure used in atomic logical |
255 | * eraseblock change requests. | 309 | * eraseblock change requests. |
256 | * @lnum: logical eraseblock number to change | 310 | * @lnum: logical eraseblock number to change |
@@ -261,8 +315,8 @@ struct ubi_rsvol_req { | |||
261 | struct ubi_leb_change_req { | 315 | struct ubi_leb_change_req { |
262 | int32_t lnum; | 316 | int32_t lnum; |
263 | int32_t bytes; | 317 | int32_t bytes; |
264 | uint8_t dtype; | 318 | int8_t dtype; |
265 | uint8_t padding[7]; | 319 | int8_t padding[7]; |
266 | } __attribute__ ((packed)); | 320 | } __attribute__ ((packed)); |
267 | 321 | ||
268 | #endif /* __UBI_USER_H__ */ | 322 | #endif /* __UBI_USER_H__ */ |