blob: 4ece56b9cecea2d10af707274c5954930013dcd4 [file] [log] [blame]
Adriana Kobylakccb24382018-07-30 12:56:29 -05001From 0f833ac73ad631248826386e2918d8571ecf0347 Mon Sep 17 00:00:00 2001
2From: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
3Date: Sat, 9 Jun 2018 16:45:22 +0200
4Subject: [PATCH] Revert "Return correct error number in ubi_get_vol_info1"
5
6This reverts commit dede98ffb706676309488d7cc660f569548d5930.
7
8The original commit tried to fix a descrepancy between the implementation
9and the documentation by making the implementation comply.
10
11When making the change, it was overlooked, that ubinfo and ubirename were
12written against the implementation instead of the behaviour specified by
13the documentation. So were further internal functions like
14ubi_get_vol_info1_nm which further breaks ubirmvol.
15
16A report with an outline of a resulting problem can be read on
17the mailing list:
18
19http://lists.infradead.org/pipermail/linux-mtd/2018-June/081562.html
20
21From the report:
22
23steps to reproduce: have mtd-utils 2.0.1 or 2.0.2
24
250. make a bunch of ubi volumes in sequential order
26
27ubimkvol /dev/ubi0 -s 64KiB -N test1
28ubimkvol /dev/ubi0 -s 64KiB -N test2
29ubimkvol /dev/ubi0 -s 64KiB -N test3
30ubimkvol /dev/ubi0 -s 64KiB -N test4
31..
32
331. delete the test1 volume, making a hole in the volume table
34
35ubirmvol /dev/ubi0 -N test1
36
372. 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
43or "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
66Reported-by: Christian Lamparter <chunkeey@gmail.com>
67Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
68Upstream-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
73diff --git a/lib/libubi.c b/lib/libubi.c
74index 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--
912.14.4
92