summaryrefslogtreecommitdiff
path: root/ubi-utils
diff options
context:
space:
mode:
Diffstat (limited to 'ubi-utils')
-rw-r--r--ubi-utils/include/libubi.h19
-rw-r--r--ubi-utils/src/libubi.c15
2 files changed, 32 insertions, 2 deletions
diff --git a/ubi-utils/include/libubi.h b/ubi-utils/include/libubi.h
index 61d886f..5f75108 100644
--- a/ubi-utils/include/libubi.h
+++ b/ubi-utils/include/libubi.h
@@ -146,7 +146,7 @@ struct ubi_dev_info
* @rsvd_bytes: how many bytes are reserved for this volume
* @rsvd_lebs: how many logical eraseblocks are reserved for this volume
* @leb_size: logical eraseblock size of this volume (may be less then
- * device's logical eraseblock size due to alignment)
+ * device's logical eraseblock size due to alignment)
* @corrupted: non-zero if the volume is corrupted
* @name: volume name (null-terminated)
*/
@@ -329,10 +329,25 @@ int ubi_get_vol_info1(libubi_t desc, int dev_num, int vol_id,
* @bytes: how many bytes will be written to the volume
*
* This function initiates UBI volume update and returns %0 in case of success
- * and %-1 in case of error.
+ * and %-1 in case of error. The caller is assumed to write @bytes data to the
+ * volume @fd afterwards.
*/
int ubi_update_start(libubi_t desc, int fd, long long bytes);
+/**
+ * ubi_update_start - start atomic LEB change.
+ * @desc: UBI library descriptor
+ * @fd: volume character devie file descriptor
+ * @lnum: LEB number to change
+ * @bytes: how many bytes of new data will be written to the LEB
+ * @dtype: data type (%UBI_LONGTERM, %UBI_SHORTTERM, %UBI_UNKNOWN)
+ *
+ * This function initiates atomic LEB change operation and returns %0 in case
+ * of success and %-1 in case of error. he caller is assumed to write @bytes
+ * data to the volume @fd afterwards.
+ */
+int ubi_leb_change_start(libubi_t desc, int fd, int lnum, int bytes, int dtype);
+
#ifdef __cplusplus
}
#endif
diff --git a/ubi-utils/src/libubi.c b/ubi-utils/src/libubi.c
index be06f70..023fa07 100644
--- a/ubi-utils/src/libubi.c
+++ b/ubi-utils/src/libubi.c
@@ -1012,6 +1012,21 @@ int ubi_update_start(libubi_t desc, int fd, long long bytes)
return 0;
}
+int ubi_leb_change_start(libubi_t desc, int fd, int lnum, int bytes, int dtype)
+{
+ struct ubi_leb_change_req req;
+
+ desc = desc;
+ memset(&req, 0, sizeof(struct ubi_leb_change_req));
+ req.lnum = lnum;
+ req.bytes = bytes;
+ req.dtype = dtype;
+
+ if (ioctl(fd, UBI_IOCEBCH, &req))
+ return -1;
+ return 0;
+}
+
int ubi_get_dev_info1(libubi_t desc, int dev_num, struct ubi_dev_info *info)
{
DIR *sysfs_ubi;