]> www.infradead.org Git - mtd-utils.git/commitdiff
libubi: add ubi_is_mapped() function
authorCorentin Chary <corentincj@iksaif.net>
Sat, 9 May 2009 09:41:06 +0000 (11:41 +0200)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Mon, 11 May 2009 15:28:53 +0000 (18:28 +0300)
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
ubi-utils/include/libubi.h
ubi-utils/src/libubi.c

index 4ffe1e8dad870f06f80b895d4550e094f77c4c97..f52904d912bdf0f5071d15efea6e599ca51b0174 100644 (file)
@@ -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
index 5b22e215216a5fce02440430e9f8e641bf26f985..158b919f93555d7d90697ee6afd9d96b266ae1fc 100644 (file)
@@ -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);
+}