From: hujianyang <hujianyang@huawei.com>
To: linux-mtd <linux-mtd@lists.infradead.org>
Cc: Bill Pringlemeir <bpringlemeir@nbsps.com>,
Artem Bityutskiy <dedekind1@gmail.com>
Subject: [PATCH 2/5] ubi-utils: Enable lnum2pnum ioctl in userspace
Date: Tue, 29 Jul 2014 17:35:16 +0800 [thread overview]
Message-ID: <53D76AD4.1010206@huawei.com> (raw)
In-Reply-To: <53D7677A.6000905@huawei.com>
Introduce ubi_lnum_to_pnum() to translate lnum into pnum by the
a new ioctl.
Signed-off-by: hujianyang <hujianyang@huawei.com>
---
include/mtd/ubi-user.h | 12 ++++++++++++
ubi-utils/include/libubi.h | 11 +++++++++++
ubi-utils/libubi.c | 12 ++++++++++++
3 files changed, 35 insertions(+)
diff --git a/include/mtd/ubi-user.h b/include/mtd/ubi-user.h
index 2b50dad..e4f57c6 100644
--- a/include/mtd/ubi-user.h
+++ b/include/mtd/ubi-user.h
@@ -200,6 +200,8 @@
#define UBI_IOCVOLCRBLK _IOW(UBI_VOL_IOC_MAGIC, 7, struct ubi_blkcreate_req)
/* Remove the R/O block device */
#define UBI_IOCVOLRMBLK _IO(UBI_VOL_IOC_MAGIC, 8)
+/* Get pnum of a specified leb */
+#define UBI_IOCEBGETPNUM _IOW(UBI_VOL_IOC_MAGIC, 9, struct ubi_lnum2pnum_req)
/* Maximum MTD device name length supported by UBI */
#define MAX_UBI_MTD_NAME_LEN 127
@@ -437,4 +439,14 @@ struct ubi_blkcreate_req {
int8_t padding[128];
} __attribute__((packed));
+/**
+ * struct ubi_lnum2pnum_req - a data structure used in lnum translate requests.
+ * @lnum: logical eraseblock num to translate
+ * @pnum: physical eraseblock num @lnum mapped
+ */
+struct ubi_lnum2pnum_req {
+ int32_t lnum;
+ int32_t pnum;
+} __attribute__((packed));
+
#endif /* __UBI_USER_H__ */
diff --git a/ubi-utils/include/libubi.h b/ubi-utils/include/libubi.h
index 4d6a7ee..618a6ba 100644
--- a/ubi-utils/include/libubi.h
+++ b/ubi-utils/include/libubi.h
@@ -478,6 +478,17 @@ int ubi_leb_unmap(int fd, int lnum);
*/
int ubi_is_mapped(int fd, int lnum);
+/**
+ * ubi_lnum_to_pnum - get the pnum of a specified leb.
+ * @fd: volume character device file descriptor
+ * @lnum: logical eraseblock number to translate
+ * @pnum: physical eraseblock number to return
+ *
+ * This function return %0 in case of success and %-1 in case of failure. The
+ * pnum of the specified leb is returned by @pnum.
+ */
+int ubi_lnum_to_pnum(int fd, int lnum, int *pnum);
+
#ifdef __cplusplus
}
#endif
diff --git a/ubi-utils/libubi.c b/ubi-utils/libubi.c
index 1e08b7d..9650b6a 100644
--- a/ubi-utils/libubi.c
+++ b/ubi-utils/libubi.c
@@ -1123,6 +1123,18 @@ int ubi_vol_block_remove(int fd)
return ioctl(fd, UBI_IOCVOLRMBLK);
}
+int ubi_lnum_to_pnum(int fd, int lnum, int *pnum)
+{
+ struct ubi_lnum2pnum_req request;
+
+ request.pnum = -1;
+ request.lnum = lnum;
+ if (ioctl(fd, UBI_IOCEBGETPNUM, &request))
+ return -1;
+ *pnum = request.pnum;
+ return 0;
+}
+
int ubi_update_start(libubi_t desc, int fd, long long bytes)
{
desc = desc;
--
1.8.1.4
next prev parent reply other threads:[~2014-07-29 9:36 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-29 9:20 [PATCH RFC v2] ubi-utils: Introduce a utility ubidump hujianyang
2014-07-29 9:26 ` [PATCH RFC v2] UBI: New ioctl() to support ubidump hujianyang
2014-07-29 14:48 ` Bill Pringlemeir
2014-07-30 2:01 ` hujianyang
2014-07-30 15:53 ` Bill Pringlemeir
2014-07-31 3:01 ` hujianyang
2014-07-31 13:24 ` Artem Bityutskiy
2014-08-01 2:50 ` hujianyang
2014-08-01 7:30 ` Artem Bityutskiy
2014-08-01 10:10 ` hujianyang
2014-08-01 15:35 ` Bill Pringlemeir
2014-08-04 3:54 ` hujianyang
2014-08-05 21:10 ` Bill Pringlemeir
2014-07-31 13:25 ` Artem Bityutskiy
2014-07-29 16:37 ` Richard Weinberger
2014-07-30 2:19 ` hujianyang
2014-07-29 9:31 ` [PATCH 1/5] ubi-utils: Add libdump files hujianyang
2014-07-29 9:35 ` hujianyang [this message]
2014-07-29 9:41 ` [PATCH 3/5] ubi-utils: Introduce ubidump hujianyang
2014-07-29 9:43 ` [PATCH 4/5] ubi-utils: Add ubifs-media.h hujianyang
2014-07-29 9:45 ` [PATCH 5/5] ubi-utils: Modified Makefile hujianyang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53D76AD4.1010206@huawei.com \
--to=hujianyang@huawei.com \
--cc=bpringlemeir@nbsps.com \
--cc=dedekind1@gmail.com \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.