aboutsummaryrefslogtreecommitdiffstats
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
commit5660ba01980d5923194f3f6dce767a1e209bda13 (patch)
treefd344f9d28d7a57d1ee454f5f87026766ecf1b28 /package
parent0c7837df28dd8ef162ed92bf2e719c59d07997a0 (diff)
downloadmaster-187ad058-5660ba01980d5923194f3f6dce767a1e209bda13.tar.gz
master-187ad058-5660ba01980d5923194f3f6dce767a1e209bda13.tar.bz2
master-187ad058-5660ba01980d5923194f3f6dce767a1e209bda13.zip
fallback when devfs names aren't found
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@6541 3c298f89-4303-0410-b956-a3cf2f4a3e73
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 7d1e36010c..0a968409a8 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);