Commit 5f052559 authored by Michael Bestas's avatar Michael Bestas Committed by Dees Troy

mtdutils: Fix mounting partitions by-name

Change-Id: I8314bb94bf5bcd9576995cd2ecdc5133c5f5ea11
parent 0d0d522b
......@@ -5,13 +5,17 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
mtdutils.c \
mounts.c
mounts.c
ifneq ($(filter rk30xx rk3188,$(TARGET_BOARD_PLATFORM)),)
LOCAL_SRC_FILES += rk3xhack.c
LOCAL_CFLAGS += -DRK3X
endif
ifeq ($(TARGET_MTD_BY_NAME),true)
LOCAL_CFLAGS += -DBYNAME
endif
LOCAL_MODULE := libmtdutils
LOCAL_STATIC_LIBRARIES := libcutils libc
LOCAL_CLANG := true
......@@ -22,13 +26,17 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
mtdutils.c \
mounts.c
mounts.c
ifneq ($(filter rk30xx rk3188,$(TARGET_BOARD_PLATFORM)),)
LOCAL_SRC_FILES += rk3xhack.c
LOCAL_CFLAGS += -DRK3X
endif
ifeq ($(TARGET_MTD_BY_NAME),true)
LOCAL_CFLAGS += -DBYNAME
endif
LOCAL_MODULE := libmtdutils
LOCAL_SHARED_LIBRARIES := libcutils libc
LOCAL_CLANG := true
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment