summaryrefslogtreecommitdiff
path: root/lib/libubi.c
AgeCommit message (Collapse)Author
2020-02-09mtd-utils: Fix some simple cases of uninitialized value readsDavid Oberhollenzer
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 >= 0) {...} if (a == -1) {...}" inside recv_image into a more straight forward if/else branch. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-06-28libubi: add volume flags to ubi_mkvol_requestQuentin Schulz
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 <boris.brezillon@bootlin.com> Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com> Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-06-09Revert "Return correct error number in ubi_get_vol_info1"David Oberhollenzer
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 <chunkeey@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-11-02Remove self-assignments of unused paramtersDavid Oberhollenzer
Use casts to void instead. Clang generates warnings about that by default. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-03-29libubi.c: add klibc specific fixes for ioctlAndrea Adami
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 <andrea.adami@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-03-22Return correct error number in ubi_get_vol_info1David Oberhollenzer
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>
2017-02-20Remove UDEV_SETTLE_HACKRichard Weinberger
UDEV_SETTLE_HACK addresses a problem which does no longer exist on Linux. These days we have devtmpfs. New devices will automatically created on the kernel side and user space has no longer to wait for udev. As udev has a hard dependency on devtmpfs we can depend on it too. People which don't use udev nor plain devtmpfs are anyways on their own. Android, I'm looking at you... Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2016-11-17Move ubi-utils libraries to common library locationDavid Oberhollenzer
Historically, the mtd-utils and ubi-utils were seperate packages. The ubi-utils were at some point merged into the mtd-utils. They first appeared in the release tar-ball in version 1.1.0 in their own sub-hirarchy with their own buildsystem, readme, documentation, etc. A lot of the duplicated stuff got centralized/removed over time. This patch further cleans up the directory hirarchy duplication by moving common libraries from the ubi-utils/ into the central lib/ and include/ directories in the top directory of the mtd-utils package. This includes: - libuib.a & libubigen.a used by the ubi utilities - libscan.a currently only used by ubiformat - libiniparser.a used by ubinize Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>