]> www.infradead.org Git - mtd-utils.git/commitdiff
Return correct error number in ubi_get_vol_info1
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Wed, 22 Mar 2017 09:10:23 +0000 (10:10 +0100)
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Wed, 22 Mar 2017 09:16:13 +0000 (10:16 +0100)
If the specified UBI device or volume does not exist, the function
is supposed to set errno to ENODEV.

This patch adds a check to ubi_get_vol_info1 to change the errno
to ENODEV if vol_get_major cannot access the underlying sysfs file,
so the function propperly returns that the device or volume does
not exist, instead of failing with errno set to ENOENT.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
lib/libubi.c

index 99022dd2675846a5e3f568d875990b536fc5d624..f1cc37ad78d2952f720dccd757dbbfcd8af385e4 100644 (file)
@@ -1242,8 +1242,11 @@ int ubi_get_vol_info1(libubi_t desc, int dev_num, int vol_id,
        info->dev_num = dev_num;
        info->vol_id = vol_id;
 
-       if (vol_get_major(lib, dev_num, vol_id, &info->major, &info->minor))
+       if (vol_get_major(lib, dev_num, vol_id, &info->major, &info->minor)) {
+               if (errno == ENOENT)
+                       errno = ENODEV;
                return -1;
+       }
 
        ret = vol_read_data(lib->vol_type, dev_num, vol_id, buf, 50);
        if (ret < 0)