aboutsummaryrefslogtreecommitdiffstats
path: root/package/system/mtd/src/mtd.c
diff options
context:
space:
mode:
authorJohn Crispin <john@openwrt.org>2014-03-30 09:14:58 +0000
committerJohn Crispin <john@openwrt.org>2014-03-30 09:14:58 +0000
commit00d7e84af6d857031f9dfe00fe0c2735ed9ada3b (patch)
tree38932cfd28842c4503ccfd772d98c66ce64a23ee /package/system/mtd/src/mtd.c
parent3ecffab05061b49c74768fe6c1d695ea84fcf863 (diff)
downloadupstream-00d7e84af6d857031f9dfe00fe0c2735ed9ada3b.tar.gz
upstream-00d7e84af6d857031f9dfe00fe0c2735ed9ada3b.tar.bz2
upstream-00d7e84af6d857031f9dfe00fe0c2735ed9ada3b.zip
mtd: improve mtd detection
Signed-off-by: John Crispin <blogic@openwrt.org> SVN-Revision: 40301
Diffstat (limited to 'package/system/mtd/src/mtd.c')
-rw-r--r--package/system/mtd/src/mtd.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/package/system/mtd/src/mtd.c b/package/system/mtd/src/mtd.c
index 604ca28ae2..7b80193b44 100644
--- a/package/system/mtd/src/mtd.c
+++ b/package/system/mtd/src/mtd.c
@@ -67,10 +67,12 @@ int mtd_open(const char *mtd, bool block)
int i;
int ret;
int flags = O_RDWR | O_SYNC;
+ char name[PATH_MAX];
+ snprintf(name, sizeof(name), "\"%s\"", mtd);
if ((fp = fopen("/proc/mtd", "r"))) {
while (fgets(dev, sizeof(dev), fp)) {
- if (sscanf(dev, "mtd%d:", &i) && strstr(dev, mtd)) {
+ if (sscanf(dev, "mtd%d:", &i) && strstr(dev, name)) {
snprintf(dev, sizeof(dev), "/dev/mtd%s/%d", (block ? "block" : ""), i);
if ((ret=open(dev, flags))<0) {
snprintf(dev, sizeof(dev), "/dev/mtd%s%d", (block ? "block" : ""), i);