diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-01-07 09:10:58 -0500 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-01-18 07:02:08 -0500 |
commit | f7fc6f3f33703e3365c0ef9d4bf322b88cc9dae7 (patch) | |
tree | ad54a4c4fc8b480559f2d8600d4724384b0fb77f /include/mtd | |
parent | a27ce8f55dd5fddf0b8ea179cce8f399c13dc94f (diff) |
UBI: improve ioctl commentaries
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'include/mtd')
-rw-r--r-- | include/mtd/ubi-user.h | 88 |
1 files changed, 62 insertions, 26 deletions
diff --git a/include/mtd/ubi-user.h b/include/mtd/ubi-user.h index 5828d7879199..82113e160a2c 100644 --- a/include/mtd/ubi-user.h +++ b/include/mtd/ubi-user.h | |||
@@ -40,37 +40,37 @@ | |||
40 | * UBI volume creation | 40 | * UBI volume creation |
41 | * ~~~~~~~~~~~~~~~~~~~ | 41 | * ~~~~~~~~~~~~~~~~~~~ |
42 | * | 42 | * |
43 | * UBI volumes are created via the %UBI_IOCMKVOL IOCTL command of UBI character | 43 | * UBI volumes are created via the %UBI_IOCMKVOL ioctl command of UBI character |
44 | * device. A &struct ubi_mkvol_req object has to be properly filled and a | 44 | * device. A &struct ubi_mkvol_req object has to be properly filled and a |
45 | * pointer to it has to be passed to the IOCTL. | 45 | * pointer to it has to be passed to the ioctl. |
46 | * | 46 | * |
47 | * UBI volume deletion | 47 | * UBI volume deletion |
48 | * ~~~~~~~~~~~~~~~~~~~ | 48 | * ~~~~~~~~~~~~~~~~~~~ |
49 | * | 49 | * |
50 | * To delete a volume, the %UBI_IOCRMVOL IOCTL command of the UBI character | 50 | * To delete a volume, the %UBI_IOCRMVOL ioctl command of the UBI character |
51 | * device should be used. A pointer to the 32-bit volume ID hast to be passed | 51 | * device should be used. A pointer to the 32-bit volume ID hast to be passed |
52 | * to the IOCTL. | 52 | * to the ioctl. |
53 | * | 53 | * |
54 | * UBI volume re-size | 54 | * UBI volume re-size |
55 | * ~~~~~~~~~~~~~~~~~~ | 55 | * ~~~~~~~~~~~~~~~~~~ |
56 | * | 56 | * |
57 | * To re-size a volume, the %UBI_IOCRSVOL IOCTL command of the UBI character | 57 | * To re-size a volume, the %UBI_IOCRSVOL ioctl command of the UBI character |
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 | 61 | * UBI volumes re-name |
62 | * ~~~~~~~~~~~~~~~~~~~ | 62 | * ~~~~~~~~~~~~~~~~~~~ |
63 | * | 63 | * |
64 | * To re-name several volumes atomically at one go, the %UBI_IOCRNVOL command | 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 | 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. | 66 | * has to be properly filled and a pointer to it has to be passed to the ioctl. |
67 | * | 67 | * |
68 | * UBI volume update | 68 | * UBI volume update |
69 | * ~~~~~~~~~~~~~~~~~ | 69 | * ~~~~~~~~~~~~~~~~~ |
70 | * | 70 | * |
71 | * Volume update should be done via the %UBI_IOCVOLUP IOCTL command of the | 71 | * Volume update should be done via the %UBI_IOCVOLUP ioctl command of the |
72 | * corresponding UBI volume character device. A pointer to a 64-bit update | 72 | * corresponding UBI volume character device. A pointer to a 64-bit update |
73 | * size should be passed to the IOCTL. After this, UBI expects user to write | 73 | * size should be passed to the ioctl. After this, UBI expects user to write |
74 | * this number of bytes to the volume character device. The update is finished | 74 | * this number of bytes to the volume character device. The update is finished |
75 | * when the claimed number of bytes is passed. So, the volume update sequence | 75 | * when the claimed number of bytes is passed. So, the volume update sequence |
76 | * is something like: | 76 | * is something like: |
@@ -80,14 +80,50 @@ | |||
80 | * write(fd, buf, image_size); | 80 | * write(fd, buf, image_size); |
81 | * close(fd); | 81 | * close(fd); |
82 | * | 82 | * |
83 | * Atomic eraseblock change | 83 | * Logical eraseblock erase |
84 | * ~~~~~~~~~~~~~~~~~~~~~~~~ | 84 | * ~~~~~~~~~~~~~~~~~~~~~~~~ |
85 | * | 85 | * |
86 | * Atomic eraseblock change operation is done via the %UBI_IOCEBCH IOCTL | 86 | * To erase a logical eraseblock, the %UBI_IOCEBER ioctl command of the |
87 | * command of the corresponding UBI volume character device. A pointer to | 87 | * corresponding UBI volume character device should be used. This command |
88 | * &struct ubi_leb_change_req has to be passed to the IOCTL. Then the user is | 88 | * unmaps the requested logical eraseblock, makes sure the corresponding |
89 | * expected to write the requested amount of bytes. This is similar to the | 89 | * physical eraseblock is successfully erased, and returns. |
90 | * "volume update" IOCTL. | 90 | * |
91 | * Atomic logical eraseblock change | ||
92 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
93 | * | ||
94 | * Atomic logical eraseblock change operation is called using the %UBI_IOCEBCH | ||
95 | * ioctl command of the corresponding UBI volume character device. A pointer to | ||
96 | * a &struct ubi_leb_change_req object has to be passed to the ioctl. Then the | ||
97 | * user is expected to write the requested amount of bytes (similarly to what | ||
98 | * should be done in case of the "volume update" ioctl). | ||
99 | * | ||
100 | * Logical eraseblock map | ||
101 | * ~~~~~~~~~~~~~~~~~~~~~ | ||
102 | * | ||
103 | * To map a logical eraseblock to a physical eraseblock, the %UBI_IOCEBMAP | ||
104 | * ioctl command should be used. A pointer to a &struct ubi_map_req object is | ||
105 | * expected to be passed. The ioctl maps the requested logical eraseblock to | ||
106 | * a physical eraseblock and returns. Only non-mapped logical eraseblocks can | ||
107 | * be mapped. If the logical eraseblock specified in the request is already | ||
108 | * mapped to a physical eraseblock, the ioctl fails and returns error. | ||
109 | * | ||
110 | * Logical eraseblock unmap | ||
111 | * ~~~~~~~~~~~~~~~~~~~~~~~~ | ||
112 | * | ||
113 | * To unmap a logical eraseblock to a physical eraseblock, the %UBI_IOCEBUNMAP | ||
114 | * ioctl command should be used. The ioctl unmaps the logical eraseblocks, | ||
115 | * schedules corresponding physical eraseblock for erasure, and returns. Unlike | ||
116 | * the "LEB erase" command, it does not wait for the physical eraseblock being | ||
117 | * erased. Note, the side effect of this is that if an unclean reboot happens | ||
118 | * after the unmap ioctl returns, you may find the LEB mapped again to the same | ||
119 | * physical eraseblock after the UBI is run again. | ||
120 | * | ||
121 | * Check if logical eraseblock is mapped | ||
122 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
123 | * | ||
124 | * To check if a logical eraseblock is mapped to a physical eraseblock, the | ||
125 | * %UBI_IOCEBISMAP ioctl command should be used. It returns %0 if the LEB is | ||
126 | * not mapped, and %1 if it is mapped. | ||
91 | */ | 127 | */ |
92 | 128 | ||
93 | /* | 129 | /* |
@@ -101,7 +137,7 @@ | |||
101 | /* Maximum volume name length */ | 137 | /* Maximum volume name length */ |
102 | #define UBI_MAX_VOLUME_NAME 127 | 138 | #define UBI_MAX_VOLUME_NAME 127 |
103 | 139 | ||
104 | /* IOCTL commands of UBI character devices */ | 140 | /* ioctl commands of UBI character devices */ |
105 | 141 | ||
106 | #define UBI_IOC_MAGIC 'o' | 142 | #define UBI_IOC_MAGIC 'o' |
107 | 143 | ||
@@ -114,7 +150,7 @@ | |||
114 | /* Re-name volumes */ | 150 | /* Re-name volumes */ |
115 | #define UBI_IOCRNVOL _IOW(UBI_IOC_MAGIC, 3, struct ubi_rnvol_req) | 151 | #define UBI_IOCRNVOL _IOW(UBI_IOC_MAGIC, 3, struct ubi_rnvol_req) |
116 | 152 | ||
117 | /* IOCTL commands of the UBI control character device */ | 153 | /* ioctl commands of the UBI control character device */ |
118 | 154 | ||
119 | #define UBI_CTRL_IOC_MAGIC 'o' | 155 | #define UBI_CTRL_IOC_MAGIC 'o' |
120 | 156 | ||
@@ -123,21 +159,21 @@ | |||
123 | /* Detach an MTD device */ | 159 | /* Detach an MTD device */ |
124 | #define UBI_IOCDET _IOW(UBI_CTRL_IOC_MAGIC, 65, int32_t) | 160 | #define UBI_IOCDET _IOW(UBI_CTRL_IOC_MAGIC, 65, int32_t) |
125 | 161 | ||
126 | /* IOCTL commands of UBI volume character devices */ | 162 | /* ioctl commands of UBI volume character devices */ |
127 | 163 | ||
128 | #define UBI_VOL_IOC_MAGIC 'O' | 164 | #define UBI_VOL_IOC_MAGIC 'O' |
129 | 165 | ||
130 | /* Start UBI volume update */ | 166 | /* Start UBI volume update */ |
131 | #define UBI_IOCVOLUP _IOW(UBI_VOL_IOC_MAGIC, 0, int64_t) | 167 | #define UBI_IOCVOLUP _IOW(UBI_VOL_IOC_MAGIC, 0, int64_t) |
132 | /* An eraseblock erasure command, used for debugging, disabled by default */ | 168 | /* LEB erasure command, used for debugging, disabled by default */ |
133 | #define UBI_IOCEBER _IOW(UBI_VOL_IOC_MAGIC, 1, int32_t) | 169 | #define UBI_IOCEBER _IOW(UBI_VOL_IOC_MAGIC, 1, int32_t) |
134 | /* An atomic eraseblock change command */ | 170 | /* Atomic LEB change command */ |
135 | #define UBI_IOCEBCH _IOW(UBI_VOL_IOC_MAGIC, 2, int32_t) | 171 | #define UBI_IOCEBCH _IOW(UBI_VOL_IOC_MAGIC, 2, int32_t) |
136 | /* Map an eraseblock, used for debugging, disabled by default */ | 172 | /* Map LEB command */ |
137 | #define UBI_IOCEBMAP _IOW(UBI_VOL_IOC_MAGIC, 3, struct ubi_map_req) | 173 | #define UBI_IOCEBMAP _IOW(UBI_VOL_IOC_MAGIC, 3, struct ubi_map_req) |
138 | /* Unmap an eraseblock, used for debugging, disabled by default */ | 174 | /* Unmap LEB command */ |
139 | #define UBI_IOCEBUNMAP _IOW(UBI_VOL_IOC_MAGIC, 4, int32_t) | 175 | #define UBI_IOCEBUNMAP _IOW(UBI_VOL_IOC_MAGIC, 4, int32_t) |
140 | /* Check if an eraseblock is mapped, used for debugging, disabled by default */ | 176 | /* Check if LEB is mapped command */ |
141 | #define UBI_IOCEBISMAP _IOR(UBI_VOL_IOC_MAGIC, 5, int32_t) | 177 | #define UBI_IOCEBISMAP _IOR(UBI_VOL_IOC_MAGIC, 5, int32_t) |
142 | 178 | ||
143 | /* Maximum MTD device name length supported by UBI */ | 179 | /* Maximum MTD device name length supported by UBI */ |
@@ -311,8 +347,8 @@ struct ubi_rnvol_req { | |||
311 | } __attribute__ ((packed)); | 347 | } __attribute__ ((packed)); |
312 | 348 | ||
313 | /** | 349 | /** |
314 | * struct ubi_leb_change_req - a data structure used in atomic logical | 350 | * struct ubi_leb_change_req - a data structure used in atomic LEB change |
315 | * eraseblock change requests. | 351 | * requests. |
316 | * @lnum: logical eraseblock number to change | 352 | * @lnum: logical eraseblock number to change |
317 | * @bytes: how many bytes will be written to the logical eraseblock | 353 | * @bytes: how many bytes will be written to the logical eraseblock |
318 | * @dtype: data type (%UBI_LONGTERM, %UBI_SHORTTERM, %UBI_UNKNOWN) | 354 | * @dtype: data type (%UBI_LONGTERM, %UBI_SHORTTERM, %UBI_UNKNOWN) |
@@ -326,7 +362,7 @@ struct ubi_leb_change_req { | |||
326 | } __attribute__ ((packed)); | 362 | } __attribute__ ((packed)); |
327 | 363 | ||
328 | /** | 364 | /** |
329 | * struct ubi_map_req - a data structure used in map eraseblock requests. | 365 | * struct ubi_map_req - a data structure used in map LEB requests. |
330 | * @lnum: logical eraseblock number to unmap | 366 | * @lnum: logical eraseblock number to unmap |
331 | * @dtype: data type (%UBI_LONGTERM, %UBI_SHORTTERM, %UBI_UNKNOWN) | 367 | * @dtype: data type (%UBI_LONGTERM, %UBI_SHORTTERM, %UBI_UNKNOWN) |
332 | * @padding: reserved for future, not used, has to be zeroed | 368 | * @padding: reserved for future, not used, has to be zeroed |