From 730148bc94411f13a0171204e872b0760fbde185 Mon Sep 17 00:00:00 2001 From: Brandon Maier Date: Mon, 12 Dec 2022 12:01:58 -0600 Subject: mtd-utils: Add new syntax to get devices by name This introduces a new feature to the MTD command line utilities that allows MTD devices to be referenced by name instead of device node. For example this looks like: > # Display info for the MTD device with name "data" > mtdinfo mtd:data > # Copy file to MTD device with name "data" > flashcp /my/file mtd:data This follows the syntax supported by the kernel which allows MTD device's to be mounted by name[1]. Add the function mtd_find_dev_node() that accepts an MTD "identifier" and returns the MTD's device node. The function accepts a string starting with "mtd:" which it treats as the MTD's name. It then attempts to search for the MTD, and if found maps it back to the /dev/mtdX device node. If the string does not start with "mtd:", then assume it's the old style and refers directly to a MTD device node. The function is then hooked into existing tools like flashcp, mtdinfo, flash_unlock, etc. To load in the new MTD parsing code in a consistent way across programs. [1] http://www.linux-mtd.infradead.org/faq/jffs2.html#L_mtdblock Signed-off-by: Brandon Maier Signed-off-by: David Oberhollenzer --- misc-utils/Makemodule.am | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'misc-utils/Makemodule.am') diff --git a/misc-utils/Makemodule.am b/misc-utils/Makemodule.am index bc69b1c..1ce1a68 100644 --- a/misc-utils/Makemodule.am +++ b/misc-utils/Makemodule.am @@ -7,8 +7,10 @@ ftl_check_SOURCES = misc-utils/ftl_check.c include/mtd_swab.h ftl_check_SOURCES += include/mtd/ftl-user.h mtd_debug_SOURCES = misc-utils/mtd_debug.c +mtd_debug_LDADD = libmtd.a mtdpart_SOURCES = misc-utils/mtdpart.c +mtdpart_LDADD = libmtd.a docfdisk_SOURCES = misc-utils/docfdisk.c include/mtd_swab.h docfdisk_SOURCES += include/mtd/inftl-user.h include/mtd/ftl-user.h @@ -23,8 +25,10 @@ fectest_SOURCES = misc-utils/fectest.c misc-utils/mcast_image.h fectest_LDADD = libmtd.a flash_lock_SOURCES = misc-utils/flash_lock.c +flash_lock_LDADD = libmtd.a flash_unlock_SOURCES = misc-utils/flash_unlock.c +flash_unlock_LDADD = libmtd.a flash_otp_info_SOURCES = misc-utils/flash_otp_info.c @@ -37,6 +41,7 @@ flash_otp_erase_SOURCES = misc-utils/flash_otp_erase.c flash_otp_write_SOURCES = misc-utils/flash_otp_write.c flashcp_SOURCES = misc-utils/flashcp.c +flashcp_LDADD = libmtd.a flash_erase_SOURCES = misc-utils/flash_erase.c flash_erase_LDADD = libmtd.a -- cgit v1.2.3