]> www.infradead.org Git - mtd-utils.git/commitdiff
libmtd: don't print an error message for devices without ecc support
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Wed, 12 Sep 2018 07:40:34 +0000 (09:40 +0200)
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Thu, 20 Sep 2018 09:27:01 +0000 (11:27 +0200)
The libmtd library tries to obtain the available OOB size via the sysfs
with a fallback to the ECCGETLAYOUT ioctl. For some devices (e.g. plat-ram),
the fallback path is always taken and prints an error message to stderr
since the ioctl fails.

This patch fixes the fallback path by suppressing the error message if
errno is set to EOPNOTSUPP (i.e. the device simply doesn't support that).

Fixes: a10353584f93 ("libmtd: Add support to access OOB available size")
Reported-by: Chris Packham <Chris.Packham@alliedtelesis.co.nz>
Reviewed-by: Xiaolei Li <xiaolei.li@mediatek.com>
Tested-by: Chris Packham <Chris.Packham@alliedtelesis.co.nz>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
lib/libmtd_legacy.c

index 97fef0499b7240617313f0c74a6a9da85c3137f7..2b7f65ff81b24e1b1fc967d7399f93e89fb875c6 100644 (file)
@@ -235,6 +235,8 @@ int legacy_get_mtd_oobavail(const char *node)
 
        ret = ioctl(fd, ECCGETLAYOUT, &usrlay);
        if (ret < 0) {
+               if (errno == EOPNOTSUPP)
+                       goto out_close;
                sys_errmsg("ECCGETLAYOUT ioctl request failed");
                goto out_close;
        }