summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorMike Baker <mbm@openwrt.org>2007-03-09 08:58:37 +0000
committerMike Baker <mbm@openwrt.org>2007-03-09 08:58:37 +0000
commit99c848c555319d2dd9e78926711153efcee264d0 (patch)
treea16bc3280a26f4b954d411e4cb33aff06d4ab1b3 /package
parented1a641e159e84f7d2659f123c8b630c28f5c15e (diff)
downloadmtk-20170518-99c848c555319d2dd9e78926711153efcee264d0.zip
mtk-20170518-99c848c555319d2dd9e78926711153efcee264d0.tar.gz
mtk-20170518-99c848c555319d2dd9e78926711153efcee264d0.tar.bz2
fallback when devfs names aren't found
SVN-Revision: 6541
Diffstat (limited to 'package')
-rw-r--r--package/mtd/src/mtd.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/package/mtd/src/mtd.c b/package/mtd/src/mtd.c
index 7d1e360..0a96840 100644
--- a/package/mtd/src/mtd.c
+++ b/package/mtd/src/mtd.c
@@ -197,13 +197,18 @@ mtd_open(const char *mtd, int flags)
FILE *fp;
char dev[PATH_MAX];
int i;
+ int ret;
if ((fp = fopen("/proc/mtd", "r"))) {
while (fgets(dev, sizeof(dev), fp)) {
if (sscanf(dev, "mtd%d:", &i) && strstr(dev, mtd)) {
snprintf(dev, sizeof(dev), "/dev/mtd/%d", i);
+ if ((ret=open(dev, flags))<0) {
+ snprintf(dev, sizeof(dev), "/dev/mtd%d", i);
+ ret=open(dev, flags);
+ }
fclose(fp);
- return open(dev, flags);
+ return ret;
}
}
fclose(fp);