summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorentin Chary <corentincj@iksaif.net>2009-05-09 11:41:06 +0200
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2009-05-11 18:28:53 +0300
commit999757f7e892375b1a8dfe8b0ccb3a139d8c7f71 (patch)
tree8961c1e947cb538a206586d7449468420fb6ed0d
parent29005d358c28e3adce51bee94472b4853267f84f (diff)
libubi: add ubi_is_mapped() function
Signed-off-by: Corentin Chary <corentincj@iksaif.net> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
-rw-r--r--ubi-utils/include/libubi.h17
-rw-r--r--ubi-utils/src/libubi.c5
2 files changed, 22 insertions, 0 deletions
diff --git a/ubi-utils/include/libubi.h b/ubi-utils/include/libubi.h
index 4ffe1e8..f52904d 100644
--- a/ubi-utils/include/libubi.h
+++ b/ubi-utils/include/libubi.h
@@ -414,6 +414,23 @@ int ubi_set_property(int fd, uint8_t property, uint64_t value);
*/
int ubi_leb_unmap(int fd, int lnum);
+/**
+ * ubi_is_mapped - check if logical eraseblock is mapped.
+ * @fd: volume character device file descriptor
+ * @lnum: logical eraseblock number
+ *
+ * This function checks if logical eraseblock @lnum is mapped to a physical
+ * eraseblock. If a logical eraseblock is un-mapped, this does not necessarily
+ * mean it will still be un-mapped after the UBI device is re-attached. The
+ * logical eraseblock may become mapped to the physical eraseblock it was last
+ * mapped to.
+ *
+ * This function returns %1 if the LEB is mapped, %0 if not, and %-1 in case of
+ * failure. If the volume is damaged because of an interrupted update errno
+ * set with %EBADF error code.
+ */
+int ubi_is_mapped(int fd, int lnum);
+
#ifdef __cplusplus
}
#endif
diff --git a/ubi-utils/src/libubi.c b/ubi-utils/src/libubi.c
index 5b22e21..158b919 100644
--- a/ubi-utils/src/libubi.c
+++ b/ubi-utils/src/libubi.c
@@ -1254,3 +1254,8 @@ int ubi_leb_unmap(int fd, int lnum)
{
return ioctl(fd, UBI_IOCEBUNMAP, &lnum);
}
+
+int ubi_is_mapped(int fd, int lnum)
+{
+ return ioctl(fd, UBI_IOCEBISMAP, &lnum);
+}