aboutsummaryrefslogtreecommitdiffstats
path: root/include/mtd
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-01-24 09:15:14 -0500
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-01-25 09:41:25 -0500
commit866136827b9a71c39dcb06d23ce523f719eab74b (patch)
tree4ec353d1c0b4ad8bc43ea9f692268c654ba79f63 /include/mtd
parent60c031531a85b3580f66c2530f9b2802adcad4df (diff)
UBI: introduce atomic LEB change ioctl
We have to be able to change individual LEBs for utilities like ubifsck, ubifstune. For example, ubifsck has to be able to fix errors on the media, ubifstune has to be able to change the the superblock, hence this ioctl. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'include/mtd')
-rw-r--r--include/mtd/ubi-user.h51
1 files changed, 47 insertions, 4 deletions
diff --git a/include/mtd/ubi-user.h b/include/mtd/ubi-user.h
index 4d184a7f80a8..a7421f130cc0 100644
--- a/include/mtd/ubi-user.h
+++ b/include/mtd/ubi-user.h
@@ -63,7 +63,7 @@
63 * 63 *
64 * Volume update should be done via the %UBI_IOCVOLUP IOCTL command of the 64 * Volume update should be done via the %UBI_IOCVOLUP IOCTL command of the
65 * corresponding UBI volume character device. A pointer to a 64-bit update 65 * corresponding UBI volume character device. A pointer to a 64-bit update
66 * size should be passed to the IOCTL. After then, UBI expects user to write 66 * size should be passed to the IOCTL. After this, UBI expects user to write
67 * this number of bytes to the volume character device. The update is finished 67 * this number of bytes to the volume character device. The update is finished
68 * when the claimed number of bytes is passed. So, the volume update sequence 68 * when the claimed number of bytes is passed. So, the volume update sequence
69 * is something like: 69 * is something like:
@@ -72,6 +72,15 @@
72 * ioctl(fd, UBI_IOCVOLUP, &image_size); 72 * ioctl(fd, UBI_IOCVOLUP, &image_size);
73 * write(fd, buf, image_size); 73 * write(fd, buf, image_size);
74 * close(fd); 74 * close(fd);
75 *
76 * Atomic eraseblock change
77 * ~~~~~~~~~~~~~~~~~~~~~~~~
78 *
79 * Atomic eraseblock change operation is done via the %UBI_IOCEBCH IOCTL
80 * command of the corresponding UBI volume character device. A pointer to
81 * &struct ubi_leb_change_req has to be passed to the IOCTL. Then the user is
82 * expected to write the requested amount of bytes. This is similar to the
83 * "volume update" IOCTL.
75 */ 84 */
76 85
77/* 86/*
@@ -113,11 +122,30 @@
113#define UBI_IOCVOLUP _IOW(UBI_VOL_IOC_MAGIC, 0, int64_t) 122#define UBI_IOCVOLUP _IOW(UBI_VOL_IOC_MAGIC, 0, int64_t)
114/* An eraseblock erasure command, used for debugging, disabled by default */ 123/* An eraseblock erasure command, used for debugging, disabled by default */
115#define UBI_IOCEBER _IOW(UBI_VOL_IOC_MAGIC, 1, int32_t) 124#define UBI_IOCEBER _IOW(UBI_VOL_IOC_MAGIC, 1, int32_t)
125/* An atomic eraseblock change command */
126#define UBI_IOCEBCH _IOW(UBI_VOL_IOC_MAGIC, 2, int32_t)
116 127
117/* Maximum MTD device name length supported by UBI */ 128/* Maximum MTD device name length supported by UBI */
118#define MAX_UBI_MTD_NAME_LEN 127 129#define MAX_UBI_MTD_NAME_LEN 127
119 130
120/* 131/*
132 * UBI data type hint constants.
133 *
134 * UBI_LONGTERM: long-term data
135 * UBI_SHORTTERM: short-term data
136 * UBI_UNKNOWN: data persistence is unknown
137 *
138 * These constants are used when data is written to UBI volumes in order to
139 * help the UBI wear-leveling unit to find more appropriate physical
140 * eraseblocks.
141 */
142enum {
143 UBI_LONGTERM = 1,
144 UBI_SHORTTERM = 2,
145 UBI_UNKNOWN = 3,
146};
147
148/*
121 * UBI volume type constants. 149 * UBI volume type constants.
122 * 150 *
123 * @UBI_DYNAMIC_VOLUME: dynamic volume 151 * @UBI_DYNAMIC_VOLUME: dynamic volume
@@ -125,7 +153,7 @@
125 */ 153 */
126enum { 154enum {
127 UBI_DYNAMIC_VOLUME = 3, 155 UBI_DYNAMIC_VOLUME = 3,
128 UBI_STATIC_VOLUME = 4, 156 UBI_STATIC_VOLUME = 4,
129}; 157};
130 158
131/** 159/**
@@ -137,7 +165,7 @@ enum {
137 * 165 *
138 * This data structure is used to specify MTD device UBI has to attach and the 166 * This data structure is used to specify MTD device UBI has to attach and the
139 * parameters it has to use. The number which should be assigned to the new UBI 167 * parameters it has to use. The number which should be assigned to the new UBI
140 * device is passed in @ubi_num. UBI may automatically assing the number if 168 * device is passed in @ubi_num. UBI may automatically assign the number if
141 * @UBI_DEV_NUM_AUTO is passed. In this case, the device number is returned in 169 * @UBI_DEV_NUM_AUTO is passed. In this case, the device number is returned in
142 * @ubi_num. 170 * @ubi_num.
143 * 171 *
@@ -176,7 +204,7 @@ struct ubi_attach_req {
176 * @padding2: reserved for future, not used, has to be zeroed 204 * @padding2: reserved for future, not used, has to be zeroed
177 * @name: volume name 205 * @name: volume name
178 * 206 *
179 * This structure is used by userspace programs when creating new volumes. The 207 * This structure is used by user-space programs when creating new volumes. The
180 * @used_bytes field is only necessary when creating static volumes. 208 * @used_bytes field is only necessary when creating static volumes.
181 * 209 *
182 * The @alignment field specifies the required alignment of the volume logical 210 * The @alignment field specifies the required alignment of the volume logical
@@ -222,4 +250,19 @@ struct ubi_rsvol_req {
222 int32_t vol_id; 250 int32_t vol_id;
223} __attribute__ ((packed)); 251} __attribute__ ((packed));
224 252
253/**
254 * struct ubi_leb_change_req - a data structure used in atomic logical
255 * eraseblock change requests.
256 * @lnum: logical eraseblock number to change
257 * @bytes: how many bytes will be written to the logical eraseblock
258 * @dtype: data type (%UBI_LONGTERM, %UBI_SHORTTERM, %UBI_UNKNOWN)
259 * @padding: reserved for future, not used, has to be zeroed
260 */
261struct ubi_leb_change_req {
262 int32_t lnum;
263 int32_t bytes;
264 uint8_t dtype;
265 uint8_t padding[7];
266} __attribute__ ((packed));
267
225#endif /* __UBI_USER_H__ */ 268#endif /* __UBI_USER_H__ */