<feed xmlns='http://www.w3.org/2005/Atom'>
<title>mtd-utils.git/lib/libubi.c, branch v2.3.1</title>
<subtitle>A mirror of http://git.infradead.org/mtd-utils.git</subtitle>
<id>https://git.infraroot.at/mtd-utils.git/atom?h=v2.3.1</id>
<link rel='self' href='https://git.infraroot.at/mtd-utils.git/atom?h=v2.3.1'/>
<link rel='alternate' type='text/html' href='https://git.infraroot.at/mtd-utils.git/'/>
<updated>2024-11-11T09:32:45+00:00</updated>
<entry>
<title>libubi: Add new interface ubi_leb_map()</title>
<updated>2024-11-11T09:32:45+00:00</updated>
<author>
<name>Zhihao Cheng</name>
<email>chengzhihao1@huawei.com</email>
</author>
<published>2024-11-11T08:36:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.infraroot.at/mtd-utils.git/commit/?id=d539a3951fc5eba852b1fd79e151e1879611a5df'/>
<id>urn:sha1:d539a3951fc5eba852b1fd79e151e1879611a5df</id>
<content type='text'>
Add ubi_leb_map() implementation, it is used in UBIFS linux kernel libs.

This is a preparation for replacing implementation of UBIFS utils with
linux kernel libs.

Signed-off-by: Zhihao Cheng &lt;chengzhihao1@huawei.com&gt;
Signed-off-by: David Oberhollenzer &lt;david.oberhollenzer@sigma-star.at&gt;
</content>
</entry>
<entry>
<title>ubiattach: introduce need_resv_pool in UBI_IOCATT</title>
<updated>2023-11-20T06:43:34+00:00</updated>
<author>
<name>Zhihao Cheng</name>
<email>chengzhihao1@huawei.com</email>
</author>
<published>2023-11-13T09:48:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.infraroot.at/mtd-utils.git/commit/?id=2425614638a798e55e79e1b1f9b8d84567769311'/>
<id>urn:sha1:2425614638a798e55e79e1b1f9b8d84567769311</id>
<content type='text'>
The ioctl UBI_IOCATT has been extended with need_resv_pool parameter in
[1].

This parameter is used for deciding whether to reserve PEBs for filling
pool/wl_pool for target ubi device. This parameter will be effective
when fastmap is enabled, which will slow down the frequency of updating
fastmap by filling more free PEBs in pool/wl_pool. See details in [2].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ac085cfe57df2cc1d7a5c4c5e64b8780c8ad452f
[2] https://bugzilla.kernel.org/show_bug.cgi?id=217787

Signed-off-by: Zhihao Cheng &lt;chengzhihao1@huawei.com&gt;
Signed-off-by: David Oberhollenzer &lt;david.oberhollenzer@sigma-star.at&gt;
</content>
</entry>
<entry>
<title>ubiattach: introduce disable_fm in UBI_IOCATT</title>
<updated>2023-11-20T06:43:30+00:00</updated>
<author>
<name>Zhihao Cheng</name>
<email>chengzhihao1@huawei.com</email>
</author>
<published>2023-11-13T09:48:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.infraroot.at/mtd-utils.git/commit/?id=b4b45994a9ba02d575625e3b1076c337be7d4861'/>
<id>urn:sha1:b4b45994a9ba02d575625e3b1076c337be7d4861</id>
<content type='text'>
The ioctl UBI_IOCATT has been extended with disable_fm parameter after
[1].

This parameter is used for disabling fastmap for target ubi device.
If 'disable_fm' is set, ubi doesn't create new fastmap even the module
param 'fm_autoconvert' is set, and existed old fastmap will be destroyed
after attaching process.

A simple test case in [2].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=669d204469c46e91d99da24914130f78277a71d3
[2] https://bugzilla.kernel.org/show_bug.cgi?id=216278

Signed-off-by: Zhihao Cheng &lt;chengzhihao1@huawei.com&gt;
Signed-off-by: David Oberhollenzer &lt;david.oberhollenzer@sigma-star.at&gt;
</content>
</entry>
<entry>
<title>mtd-utils: Fix potentially unterminated strings</title>
<updated>2020-02-09T21:13:18+00:00</updated>
<author>
<name>David Oberhollenzer</name>
<email>david.oberhollenzer@sigma-star.at</email>
</author>
<published>2020-01-25T13:39:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.infraroot.at/mtd-utils.git/commit/?id=dcfd984d8e09db9d5a7b4d121d914442966c254f'/>
<id>urn:sha1:dcfd984d8e09db9d5a7b4d121d914442966c254f</id>
<content type='text'>
This commit fixes some uses of strncpy that could leave the destination
buffer unterminated.

Signed-off-by: David Oberhollenzer &lt;david.oberhollenzer@sigma-star.at&gt;
</content>
</entry>
<entry>
<title>mtd-utils: Fix "are we really at EOF" test logic in libubi read_data</title>
<updated>2020-02-09T21:13:18+00:00</updated>
<author>
<name>David Oberhollenzer</name>
<email>david.oberhollenzer@sigma-star.at</email>
</author>
<published>2020-01-24T22:59:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.infraroot.at/mtd-utils.git/commit/?id=83c675ac9aed767e4431a5bbc25f3ccd7f77cf84'/>
<id>urn:sha1:83c675ac9aed767e4431a5bbc25f3ccd7f77cf84</id>
<content type='text'>
The function reads file data into a buffer and then checks if we
actually are at the end-of-file by trying to read one more byte.
For whatever reason, the code uses an int instead of a char. It's
not pretty but works. But again, this is something that every
static analysis tool barks at.

Further more, the error messages are inverted. "We aren't at EOF yet"
is printed on failure and something like "read error %m" is printed
on success.

This patch fixes all of the above.

Signed-off-by: David Oberhollenzer &lt;david.oberhollenzer@sigma-star.at&gt;
</content>
</entry>
<entry>
<title>mtd-utils: Fix some simple cases of uninitialized value reads</title>
<updated>2020-02-09T21:13:18+00:00</updated>
<author>
<name>David Oberhollenzer</name>
<email>david.oberhollenzer@sigma-star.at</email>
</author>
<published>2020-01-24T22:40:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.infraroot.at/mtd-utils.git/commit/?id=24b0e6277b36c46075e2e23896aa9ec43729efab'/>
<id>urn:sha1:24b0e6277b36c46075e2e23896aa9ec43729efab</id>
<content type='text'>
This patch modifies the internal helpers to read and parse integers
from sysfs files by initializing them first and removes turns an
obscure "a = open(...) if (a &gt;= 0) {...} if (a == -1) {...}" inside
recv_image into a more straight forward if/else branch.

Signed-off-by: David Oberhollenzer &lt;david.oberhollenzer@sigma-star.at&gt;
</content>
</entry>
<entry>
<title>libubi: add volume flags to ubi_mkvol_request</title>
<updated>2018-06-28T08:21:51+00:00</updated>
<author>
<name>Quentin Schulz</name>
<email>quentin.schulz@bootlin.com</email>
</author>
<published>2018-06-28T07:43:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.infraroot.at/mtd-utils.git/commit/?id=5e9bc0daa41d84ce5de81c4a1665d65f51893c10'/>
<id>urn:sha1:5e9bc0daa41d84ce5de81c4a1665d65f51893c10</id>
<content type='text'>
Now that we have per-UBI volume flags (for instance for skipping CRC
check when opening it) from the Linux header, let's add it to the
ubi_mkvol_request in libubi and assign the flags to ubi_mkvol_req from
the Linux header from ubi_mkvol.

Suggested-by: Boris Brezillon &lt;boris.brezillon@bootlin.com&gt;
Reviewed-by: Boris Brezillon &lt;boris.brezillon@bootlin.com&gt;
Signed-off-by: Quentin Schulz &lt;quentin.schulz@bootlin.com&gt;
Signed-off-by: David Oberhollenzer &lt;david.oberhollenzer@sigma-star.at&gt;
</content>
</entry>
<entry>
<title>Revert "Return correct error number in ubi_get_vol_info1"</title>
<updated>2018-06-09T16:09:39+00:00</updated>
<author>
<name>David Oberhollenzer</name>
<email>david.oberhollenzer@sigma-star.at</email>
</author>
<published>2018-06-09T14:45:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.infraroot.at/mtd-utils.git/commit/?id=0f833ac73ad631248826386e2918d8571ecf0347'/>
<id>urn:sha1:0f833ac73ad631248826386e2918d8571ecf0347</id>
<content type='text'>
This reverts commit dede98ffb706676309488d7cc660f569548d5930.

The original commit tried to fix a descrepancy between the implementation
and the documentation by making the implementation comply.

When making the change, it was overlooked, that ubinfo and ubirename were
written against the implementation instead of the behaviour specified by
the documentation. So were further internal functions like
ubi_get_vol_info1_nm which further breaks ubirmvol.

A report with an outline of a resulting problem can be read on
the mailing list:

http://lists.infradead.org/pipermail/linux-mtd/2018-June/081562.html

From the report:

steps to reproduce: have mtd-utils 2.0.1 or 2.0.2

0. make a bunch of ubi volumes in sequential order

ubimkvol /dev/ubi0 -s 64KiB -N test1
ubimkvol /dev/ubi0 -s 64KiB -N test2
ubimkvol /dev/ubi0 -s 64KiB -N test3
ubimkvol /dev/ubi0 -s 64KiB -N test4
..

1. delete the test1 volume, making a hole in the volume table

ubirmvol /dev/ubi0 -N test1

2. try an affected tool (i.e. "ubirmvol /dev/ubi0 -N test4" )

 |root at mr24:/# ubirmvol /dev/ubi0 -N test4
 |ubirmvol: error!: cannot find UBI volume "test4"
 |         error 19 (No such device)

or "ubinfo -a"

 | root at mr24:/# ubinfo -a
 | UBI version:                    1
 | Count of UBI devices:           1
 | UBI control device major/minor: 10:59
 | Present UBI devices:            ubi0
 |
 | ubi0
 | Volumes count:                           11
 | Logical eraseblock size:                 15872 bytes, 15.5 KiB
 | Total amount of logical eraseblocks:     1952 (30982144 bytes, 29.5 MiB)
 | Amount of available logical eraseblocks: 75 (1190400 bytes, 1.1 MiB)
 | Maximum count of volumes                 92
 | Count of bad physical eraseblocks:       0
 | Count of reserved physical eraseblocks:  40
 | Current maximum erase counter value:     984
 | Minimum input/output unit size:          512 bytes
 | Character device major/minor:            251:0
 | ubinfo: error!: libubi failed to probe volume 5 on ubi0
 |        error 19 (No such device)
 | Present volumes:                         0, 1, 2, 3, 4root at mr24:/#

Reported-by: Christian Lamparter &lt;chunkeey@gmail.com&gt;
Signed-off-by: David Oberhollenzer &lt;david.oberhollenzer@sigma-star.at&gt;
</content>
</entry>
<entry>
<title>Remove self-assignments of unused paramters</title>
<updated>2017-11-02T00:14:34+00:00</updated>
<author>
<name>David Oberhollenzer</name>
<email>david.oberhollenzer@sigma-star.at</email>
</author>
<published>2017-11-01T23:50:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.infraroot.at/mtd-utils.git/commit/?id=81fd176a6b4958147302ef900f2651c476a3d4e7'/>
<id>urn:sha1:81fd176a6b4958147302ef900f2651c476a3d4e7</id>
<content type='text'>
Use casts to void instead. Clang generates warnings about that by
default.

Signed-off-by: David Oberhollenzer &lt;david.oberhollenzer@sigma-star.at&gt;
</content>
</entry>
<entry>
<title>libubi.c: add klibc specific fixes for ioctl</title>
<updated>2017-03-29T11:35:48+00:00</updated>
<author>
<name>Andrea Adami</name>
<email>andrea.adami@gmail.com</email>
</author>
<published>2014-06-28T22:40:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.infraroot.at/mtd-utils.git/commit/?id=5c57076891fd773190eb0f1657a09a4b64dfbc47'/>
<id>urn:sha1:5c57076891fd773190eb0f1657a09a4b64dfbc47</id>
<content type='text'>
First issue is that ioctl() in klibc doesn't expect a constant as arg3.
Second issue is that arg3 in klibc ioctl() implementation is not optional.

Fixes:

| ubi-utils/libubi.c: In function 'do_attach':
| ubi-utils/libubi.c:698:8: warning: passing argument 3 of 'ioctl' discards
| 'const' qualifier from pointer target type
|   ret = ioctl(fd, UBI_IOCATT, r);
|         ^
| In file included from ubi-utils/libubi.c:32:0:
| .../lib/klibc/include/sys/ioctl.h:15:14: note: expected 'void *' but argument
| is of type 'const struct ubi_attach_req *'
|  __extern int ioctl(int, int, void *);
|               ^

| ubi-utils/libubi.c: In function 'ubi_vol_block_create':
| ubi-utils/libubi.c:1118:9: error: too few arguments to function 'ioctl'
|   return ioctl(fd, UBI_IOCVOLCRBLK);
|          ^
| In file included from ubi-utils/libubi.c:32:0:
| .../lib/klibc/include/sys/ioctl.h:15:14: note: declared here
|  __extern int ioctl(int, int, void *);
|               ^
| ubi-utils/libubi.c: In function 'ubi_vol_block_remove':
| ubi-utils/libubi.c:1123:9: error: too few arguments to function 'ioctl'
|   return ioctl(fd, UBI_IOCVOLRMBLK);
|          ^
| In file included from ubi-utils/libubi.c:32:0:
| .../usr/lib/klibc/include/sys/ioctl.h:15:14: note: declared here
|  __extern int ioctl(int, int, void *);
|               ^

Signed-off-by: Andrea Adami &lt;andrea.adami@gmail.com&gt;
Signed-off-by: David Oberhollenzer &lt;david.oberhollenzer@sigma-star.at&gt;
</content>
</entry>
</feed>
