From e783e75e09b4a0a519665afd7bdeaf2985e7a09c Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Tue, 2 Jun 2009 16:11:35 +0300 Subject: 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 --- ubi-utils/src/libmtd_legacy.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'ubi-utils/src/libmtd_legacy.c') 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; -- cgit v1.2.3