diff options
author | John Crispin <blogic@openwrt.org> | 2014-03-30 09:14:58 +0000 |
---|---|---|
committer | John Crispin <blogic@openwrt.org> | 2014-03-30 09:14:58 +0000 |
commit | 74e9dde7b0dcf63ed7f6596fe9b6c80167eb6105 (patch) | |
tree | 65927ead55068393cc42ccde4ace1d769c17fa6b /package/system | |
parent | a273f66de752c8e0c2ecb77c906208ae80f9a7ac (diff) | |
download | master-187ad058-74e9dde7b0dcf63ed7f6596fe9b6c80167eb6105.tar.gz master-187ad058-74e9dde7b0dcf63ed7f6596fe9b6c80167eb6105.tar.bz2 master-187ad058-74e9dde7b0dcf63ed7f6596fe9b6c80167eb6105.zip |
mtd: improve mtd detection
Signed-off-by: John Crispin <blogic@openwrt.org>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@40301 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/system')
-rw-r--r-- | package/system/mtd/src/mtd.c | 4 |
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); |