Adriana Kobylak | ccb2438 | 2018-07-30 12:56:29 -0500 | [diff] [blame] | 1 | From 0f833ac73ad631248826386e2918d8571ecf0347 Mon Sep 17 00:00:00 2001 |
| 2 | From: David Oberhollenzer <david.oberhollenzer@sigma-star.at> |
| 3 | Date: Sat, 9 Jun 2018 16:45:22 +0200 |
| 4 | Subject: [PATCH] Revert "Return correct error number in ubi_get_vol_info1" |
| 5 | |
| 6 | This reverts commit dede98ffb706676309488d7cc660f569548d5930. |
| 7 | |
| 8 | The original commit tried to fix a descrepancy between the implementation |
| 9 | and the documentation by making the implementation comply. |
| 10 | |
| 11 | When making the change, it was overlooked, that ubinfo and ubirename were |
| 12 | written against the implementation instead of the behaviour specified by |
| 13 | the documentation. So were further internal functions like |
| 14 | ubi_get_vol_info1_nm which further breaks ubirmvol. |
| 15 | |
| 16 | A report with an outline of a resulting problem can be read on |
| 17 | the mailing list: |
| 18 | |
| 19 | http://lists.infradead.org/pipermail/linux-mtd/2018-June/081562.html |
| 20 | |
| 21 | From the report: |
| 22 | |
| 23 | steps to reproduce: have mtd-utils 2.0.1 or 2.0.2 |
| 24 | |
| 25 | 0. make a bunch of ubi volumes in sequential order |
| 26 | |
| 27 | ubimkvol /dev/ubi0 -s 64KiB -N test1 |
| 28 | ubimkvol /dev/ubi0 -s 64KiB -N test2 |
| 29 | ubimkvol /dev/ubi0 -s 64KiB -N test3 |
| 30 | ubimkvol /dev/ubi0 -s 64KiB -N test4 |
| 31 | .. |
| 32 | |
| 33 | 1. delete the test1 volume, making a hole in the volume table |
| 34 | |
| 35 | ubirmvol /dev/ubi0 -N test1 |
| 36 | |
| 37 | 2. try an affected tool (i.e. "ubirmvol /dev/ubi0 -N test4" ) |
| 38 | |
| 39 | |root at mr24:/# ubirmvol /dev/ubi0 -N test4 |
| 40 | |ubirmvol: error!: cannot find UBI volume "test4" |
| 41 | | error 19 (No such device) |
| 42 | |
| 43 | or "ubinfo -a" |
| 44 | |
| 45 | | root at mr24:/# ubinfo -a |
| 46 | | UBI version: 1 |
| 47 | | Count of UBI devices: 1 |
| 48 | | UBI control device major/minor: 10:59 |
| 49 | | Present UBI devices: ubi0 |
| 50 | | |
| 51 | | ubi0 |
| 52 | | Volumes count: 11 |
| 53 | | Logical eraseblock size: 15872 bytes, 15.5 KiB |
| 54 | | Total amount of logical eraseblocks: 1952 (30982144 bytes, 29.5 MiB) |
| 55 | | Amount of available logical eraseblocks: 75 (1190400 bytes, 1.1 MiB) |
| 56 | | Maximum count of volumes 92 |
| 57 | | Count of bad physical eraseblocks: 0 |
| 58 | | Count of reserved physical eraseblocks: 40 |
| 59 | | Current maximum erase counter value: 984 |
| 60 | | Minimum input/output unit size: 512 bytes |
| 61 | | Character device major/minor: 251:0 |
| 62 | | ubinfo: error!: libubi failed to probe volume 5 on ubi0 |
| 63 | | error 19 (No such device) |
| 64 | | Present volumes: 0, 1, 2, 3, 4root at mr24:/# |
| 65 | |
| 66 | Reported-by: Christian Lamparter <chunkeey@gmail.com> |
| 67 | Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at> |
| 68 | Upstream-Status: Accepted [http://git.infradead.org/mtd-utils.git/commit/0f833ac73ad631248826386e2918d8571ecf0347] |
| 69 | --- |
| 70 | lib/libubi.c | 5 +---- |
| 71 | 1 file changed, 1 insertion(+), 4 deletions(-) |
| 72 | |
| 73 | diff --git a/lib/libubi.c b/lib/libubi.c |
| 74 | index b50e68a..978b433 100644 |
| 75 | --- a/lib/libubi.c |
| 76 | +++ b/lib/libubi.c |
| 77 | @@ -1240,11 +1240,8 @@ int ubi_get_vol_info1(libubi_t desc, int dev_num, int vol_id, |
| 78 | info->dev_num = dev_num; |
| 79 | info->vol_id = vol_id; |
| 80 | |
| 81 | - if (vol_get_major(lib, dev_num, vol_id, &info->major, &info->minor)) { |
| 82 | - if (errno == ENOENT) |
| 83 | - errno = ENODEV; |
| 84 | + if (vol_get_major(lib, dev_num, vol_id, &info->major, &info->minor)) |
| 85 | return -1; |
| 86 | - } |
| 87 | |
| 88 | ret = vol_read_data(lib->vol_type, dev_num, vol_id, buf, 50); |
| 89 | if (ret < 0) |
| 90 | -- |
| 91 | 2.14.4 |
| 92 | |