summaryrefslogtreecommitdiffstats
path: root/mtdutils/mtdutils.c
diff options
context:
space:
mode:
authorMichael Bestas <mikeioannina@gmail.com>2015-01-02 00:45:37 +0100
committerDees Troy <dees_troy@teamw.in>2017-05-15 22:17:39 +0200
commit5f0525591190890cd01238492c7bf6a039ca55e9 (patch)
treeac33aed8ad9fe89e6c625817b79e89349e8e1804 /mtdutils/mtdutils.c
parentgui: fix line wrapping in terminal, issue #876 (diff)
downloadandroid_bootable_recovery-5f0525591190890cd01238492c7bf6a039ca55e9.tar
android_bootable_recovery-5f0525591190890cd01238492c7bf6a039ca55e9.tar.gz
android_bootable_recovery-5f0525591190890cd01238492c7bf6a039ca55e9.tar.bz2
android_bootable_recovery-5f0525591190890cd01238492c7bf6a039ca55e9.tar.lz
android_bootable_recovery-5f0525591190890cd01238492c7bf6a039ca55e9.tar.xz
android_bootable_recovery-5f0525591190890cd01238492c7bf6a039ca55e9.tar.zst
android_bootable_recovery-5f0525591190890cd01238492c7bf6a039ca55e9.zip
Diffstat (limited to 'mtdutils/mtdutils.c')
-rw-r--r--mtdutils/mtdutils.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/mtdutils/mtdutils.c b/mtdutils/mtdutils.c
index 6779d6e9a..7a22efe2e 100644
--- a/mtdutils/mtdutils.c
+++ b/mtdutils/mtdutils.c
@@ -32,6 +32,11 @@
#include "rk3xhack.h"
#endif
+#ifdef BYNAME
+static const char mtdprefix[] = "/dev/block/mtd/by-name/";
+#define MTD_BASENAME_OFFSET (sizeof(mtdprefix)-1)
+#endif
+
struct MtdReadContext {
const MtdPartition *partition;
char *buffer;
@@ -141,7 +146,11 @@ mtd_scan_partitions()
p->device_index = mtdnum;
p->size = mtdsize;
p->erase_size = mtderasesize;
+#ifdef BYNAME
+ asprintf(&p->name, "%s%s", mtdprefix, mtdname);
+#else
p->name = strdup(mtdname);
+#endif
if (p->name == NULL) {
errno = ENOMEM;
goto bail;
@@ -180,6 +189,11 @@ mtd_find_partition_by_name(const char *name)
if (strcmp(p->name, name) == 0) {
return p;
}
+#ifdef BYNAME
+ if (strcmp(p->name+MTD_BASENAME_OFFSET, name) == 0) {
+ return p;
+ }
+#endif
}
}
}
@@ -795,4 +809,4 @@ int cmd_mtd_get_partition_device(const char *partition, char *device)
return -1;
sprintf(device, "/dev/block/mtdblock%d", p->device_index);
return 0;
-}
+} \ No newline at end of file