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/mtdinfo.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'ubi-utils/src/mtdinfo.c') diff --git a/ubi-utils/src/mtdinfo.c b/ubi-utils/src/mtdinfo.c index 849d165..a7ce834 100644 --- a/ubi-utils/src/mtdinfo.c +++ b/ubi-utils/src/mtdinfo.c @@ -238,23 +238,20 @@ static int print_general_info(libmtd_t libmtd, const struct mtd_info *mtd_info, if (mtd_info->dev_count == 0) return 0; - printf("Present MTD devices: "); for (i = mtd_info->lowest_dev_num; i <= mtd_info->highest_dev_num; i++) { err = mtd_get_dev_info1(libmtd, i, &mtd); if (err == -1) { if (errno == ENODEV) continue; - - printf("\n"); return sys_errmsg("libmtd failed get MTD device %d " - "information", i); + "information", i); } if (!first) printf(", mtd%d", i); else { - printf("mtd%d", i); + printf("Present MTD devices: mtd%d", i); first = 0; } } -- cgit v1.2.3