diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-07-13 14:47:47 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-07-24 06:34:46 -0400 |
commit | f40ac9cdf6991287f19bdafe9b0752ee40137908 (patch) | |
tree | a49120d5be3729feaa40880962f29e3679c1800e /include | |
parent | c8566350a3229ca505b84313c65d1403b4d0cbfc (diff) |
UBI: implement multiple volumes rename
Quite useful ioctl which allows to make atomic system upgrades.
The idea belongs to Richard Titmuss <richard_titmuss@logitech.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/mtd/ubi-user.h | 60 |
1 files changed, 57 insertions, 3 deletions
diff --git a/include/mtd/ubi-user.h b/include/mtd/ubi-user.h index a7421f130cc0..e8e57c3dfcdb 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 | * |
@@ -189,7 +201,7 @@ 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__ */ |