mirror of
https://github.com/openwrt/openwrt.git
synced 2024-12-23 23:42:43 +00:00
fallback when devfs names aren't found
SVN-Revision: 6541
This commit is contained in:
parent
ed1a641e15
commit
99c848c555
@ -197,13 +197,18 @@ mtd_open(const char *mtd, int flags)
|
|||||||
FILE *fp;
|
FILE *fp;
|
||||||
char dev[PATH_MAX];
|
char dev[PATH_MAX];
|
||||||
int i;
|
int i;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if ((fp = fopen("/proc/mtd", "r"))) {
|
if ((fp = fopen("/proc/mtd", "r"))) {
|
||||||
while (fgets(dev, sizeof(dev), fp)) {
|
while (fgets(dev, sizeof(dev), fp)) {
|
||||||
if (sscanf(dev, "mtd%d:", &i) && strstr(dev, mtd)) {
|
if (sscanf(dev, "mtd%d:", &i) && strstr(dev, mtd)) {
|
||||||
snprintf(dev, sizeof(dev), "/dev/mtd/%d", i);
|
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);
|
fclose(fp);
|
||||||
return open(dev, flags);
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
Loading…
Reference in New Issue
Block a user