diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-06-02 16:11:35 +0300 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2009-06-02 17:06:36 +0300 |
commit | e783e75e09b4a0a519665afd7bdeaf2985e7a09c (patch) | |
tree | 911df9cc2909f8c04077f392d191fdfc8383fd7b /ubi-utils/src/libmtd_legacy.c | |
parent | a48340c335daba441c1f01a0cfce4d2ac6b2c9e1 (diff) |
libmts: recognize pre-MTD-sysfs kernels better
Not-so-old linux kernel like 2.6.29 do already have "/sys/class/mtd/mtdX"
directories, while very old kernels do not. But in 2.6.29 these
directories do not contain any information.
Anyway, the logic in libmtd which checked whether the system
supports sysfs was broken, because it assumed that old systems
do not even have "/sys/class/mtd/" directory.
Fix this problem by checking for "/sys/class/mtd/mtdX/name". If this
is present - the system really has sysfs support.
This patch also adds an extra print to libmtd.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'ubi-utils/src/libmtd_legacy.c')
-rw-r--r-- | ubi-utils/src/libmtd_legacy.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/ubi-utils/src/libmtd_legacy.c b/ubi-utils/src/libmtd_legacy.c index cd474b1..b477a4f 100644 --- a/ubi-utils/src/libmtd_legacy.c +++ b/ubi-utils/src/libmtd_legacy.c @@ -218,8 +218,13 @@ int legacy_get_dev_info(const char *node, struct mtd_dev_info *mtd) loff_t offs = 0; struct proc_parse_info pi; - if (stat(node, &st)) - return sys_errmsg("cannot open \"%s\"", node); + if (stat(node, &st)) { + sys_errmsg("cannot open \"%s\"", node); + if (errno == ENOENT) + normsg("MTD subsystem is old and does not support " + "sysfs, so MTD character device nodes have " + "to exist"); + } if (!S_ISCHR(st.st_mode)) { errno = EINVAL; |