Age | Commit message (Collapse) | Author |
|
This commit removes the C header files from the EXTRA_DIST variables
and instead assigns them to the SOURCE variable of the respective
components they belong to.
This takes care of having them distributed in the release tar ball and
helps with dependency tracking a little.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: Bastian Germann <bastiangermann@fishpost.de>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
libubi.h includes ubi-media.h which was made private in the kernel a
long time ago. There are users of libubi.h, e.g. swupdate, which have to
have ubi-media.h available at build time with this inclusion.
However, libubi.h uses only one symbol from ubi-media.h. Define that symbol
in the header to enable using libubi.h without installing ubi-media.h.
Make up for the transitive symbol use in ubiformat.c by including ubi-media.h.
Signed-off-by: Bastian Germann <bastiangermann@fishpost.de>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
This changeset fixes a feature regression in ubiformat. Older versions of
ubiformat, when invoked with a flash-image, would return 0 in the case no error
was encountered. Upon upgrading to latest, it was discovered that ubiformat
returned 255 even without encountering an error condition.
This changeset corrects the above issue and causes ubiformat, when given an
image file, to return 0 when no errors are detected.
Tested by running through my loading scripts and verifying ubiformat returned
0.
Signed-off-by: Barry Grussling <barry@grussling.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
The ubihealthd depends on sys/random.h , which is not present on some
older systems. Build ubihealthd only if sys/random.h is present.
Signed-off-by: Marek Vasut <marex@denx.de>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
The original code had a 'goto out_close' directly after a return error
code, which is obviously not what was intended.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Using '?' as option did not work, and would be strange to pass anyway,
because it's a glob char for the shell and you would have to escape it
like ./ubihealthd -\? … use the more common -h/--help instead.
Note: this does not touch the output, just changes the options itself.
Signed-off-by: Alexander Dahl <post@lespocky.de>
Acked-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
`getopt_long()` requires a null terminated array, otherwise we get
segfaults when passing invalid options.
Fixes: 7f0e2dc21fb2 ("ubi-utils: Implement a ubihealthd")
Signed-off-by: Alexander Dahl <post@lespocky.de>
Acked-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
libubi_close(libubi) is called in the error handler if libubi is null.
Prevent that by handling the error case similar to the other ubi
executables.
Signed-off-by: Bastian Germann <bastiangermann@fishpost.de>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
ubihealthd is a simple daemon which scans every PEB
of an UBI device in random order.
It helps to deal with read disturb on systems which either
reboot seldom, use fastmap or read few data.
To use this daemon you need Linux >= v5.1.
Signed-off-by: Richard Weinberger <richard@nod.at>
|
|
...specifically -1 in all of the new cases.
Signed-off-by: Patrick Doyle <pdoyle@irobot.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Image sequence number for the UBI header can be specified for the
ubiformat tool according to the documentation and the help message for
ubiformat. The CLI option --image-seq for image sequence number is not
supported. -Q option for image sequence number is silently ignored.
This patch adds the CLI support for image sequence number.
Signed-off-by: Amol Vengurlekar <amol.sven@gmail.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
When we create a ubi image by ubinize, a UBI_LAYOUT_VOLUME_ID
volume will be created by ubigen_write_layout_vol().
However, after the commit 4c00cf2c5816 (ubiformat: remove
no-volume-table option), ubiformat remove novtbl args in format().
As a result, it will also create a layout volume.
When we attempt to do ubiattach, it will fail for ubi_compare_lebs error:
ubi0 error: ubi_compare_lebs: unsupported on-flash UBI format
ubi0 error: ubi_attach_mtd_dev: failed to attach mtd1, error -22
Signed-off-by: Yufen Yu <yuyufen@huawei.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
default
The program expects req.flags to be zero-initialized, but it's not
the case. Let's explicitly initialize req to zero at declaration time.
Fixes: 7b4a65a27d26 ("ubi-utils: ubimkvol: add support for skipping CRC check of a static volume when opening")
Reviewed-by: Quentin Schulz <quentin.schulz@bootlin.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
when opening
Let's let the user configure static UBI volume with CRC checking at
opening disabled if desired.
Introduce the skip-check setting for vol_flags configuration of a
volume.
There is no point in having both autoresize and skip-check set as
skip-check is reserved for static volumes only and it's useless to have
a static volume's size set to autoresize.
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>
|
|
when opening
Let's let the user create static UBI volume with CRC checking at opening
disabled if desired.
Introduce the `--skipcheck` or `-k` option for such feature.
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>
|
|
Using the -n or --no-volume-table flags, ubiformat can format an mtd device
to a broken UBI that does not attach on recent kernel. Only very old UBIs
had no volume table.
This patch removes the option entirely from ubiformat.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
If libmtd_open fails, the program always exists with failure status
and prints "MTD subsystem is not present".
Even `ubiformat --help` produces the same result, which is definitely
undesired.
This patch moves command line option processing first to get the desired
behavior.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Do not cast percent to double, it is just used as upper limit.
Avoid floating point to fix compilation for aarch64 against klibc:
error: '-mgeneral-regs-only' is incompatible with floating-point code
| int percent = ((double)si->ok_cnt)/si->good_cnt * 100;
| ^~~~~~~
Notes:
* The checks in the code above this line ensure that si->good_cnt is not 0.
* The code assumes si->good_cnt * 100 will not overflow, then we can use
(si->ok_cnt * 100) safely because the former is bigger.
* The truncated result does not affect the logic:
i.e. a value of 49.9 is truncated to 49 and is still <50.
Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
When a command line option is used (e.g. --version), the tool
tries to open it as a file first, then *uppon success* attempts
to process the command line options (including what it assumed
to be an input file) which is obviously broken.
This patch moves command line processing first and then attempts
to open *the first unprocessed* argument.
Reported-by: Uwe Kleine-König <ukleinek@debian.org>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Now that C++17 introduced a special fallthrough keyword for
explicitly tagging switch cases that are supposed to fall
through, newer gcc versions also implement a feature request
from 2002 to warn about maybe unwanted fall-throughs in switch
cases in other languages (like C).
For C code, we can either add a gcc specific attribute at the
end of the switch case, or use a special comment that gcc checks
for, indicating that the fall-through behaviour is indeed
intended.
This patch adds a "/* fall-through */" comment at the end of
various case blocks to silence gcc warnings and in some cases
a break, where fall-through was probably not intended.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Adds a check if the UBI device number is specified when passing a volume
name as parameter.
This fixes an issue, where by default an inexistent UBI device named
"ubi-1" is selected because of missing checks.
Signed-off-by: Aaron Marcher <me@drkhsh.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
The tools in question will quit with an exit code 0 if the command
line option was not recognized. By returning an error code a calling
script has the possibility to distinguish between a real success and
an invalid invocation.
We need to return -1 instead of EXIT_FAILURE to be consistent with the
other exit code places.
Signed-off-by: Daniel Wagner <daniel.wagner@siemens.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
The documentation of libmtd_open says, if it returns NULL and errno is
zero, MTD is not present. However, the current version always returns
a libmtd_t object. The function internally checks, if it can access the
MTD sysfs files and, if not, sets a flag to use the procfs fallback.
This patch adds an additional check to libmtd_open, to test if the
MTD procfs file can be read and fails with errno cleared if it does
not exist.
Furhtermore, mtd_get_info is documented to fail with errno set to ENODEV
if MTD is not present. First of all, this was broken in the original
version. It was implemented to specification for the sysfs code path,
but if MTD is not present, that won't be executed, because of the flag
set by libmtd_open. This makes the check not only redundant, but masks
an actual error (the sysfs paths suddenly not being readable anymore).
The legacy path that was used if the sysfs files are not avaible fails
with ENOENT if it cannot read the procfs file. With the above changes
in addition, we don't have a libmtd_t object if neither sysfs nor
procfs is readable, so this error status no longer makes sense.
This patch removes the documentation on the ENODEV errno, and
makes sure that mtd_get_info always returns with apropriate errno
on failure.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Add a missing space after PROGRAM_NAME and fix a typo.
Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
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>
|
|
This patch moves the remaining 3 functions from ubiutils-common.{c,h}
into libmtd common.{c,h}.
The functions are only generic utility functions that other mtd-utils
programs may also find usefull and every program that uses libubi links
against libmtd anyway so there is no real reason for keeping around a
seperate ubiutils-common with only generic helper functions.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
The function ubiutils_print_text was previously used by ubinize to
pretty-print parts of the help text. Since the help text has been
moved to a man page, the function is no longer used/needed.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
This patch removes the lengthy help text from the ubinize utility
that attempted to describte the file format and every minor detail,
and reformats it into a more readable man page.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
In order to use test files, allow sysfs root
to be set during compile time
Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
|
|
This patch is largely based on Richards original RFC.
The major differences to the RFC patch are:
- Add missing sumtools & mtdpart targets
- Fix name of mkfs.jffs2 target
- Add missing subdir-objects option for non-recursive make
- Move all automake options to configure.ac
- Add manpages to install target
- Make XATTR & LZO support configurable
- Install binaries to sbin directory like in the old build system
- Install flash_erase wrapper script
- Add files missing from distribution target
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
|
|
ubinize should not fail silenty, this can be very annoying when using
it from other tools that rely on the exit code for determining the
success of their operation.
Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
|
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
|
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
|
ioctl(MEMGETREGIONINFO) has one input parameter (regionindex) and three
output parameters (info about the erase region). There are two problems
in mtdinfo/libmtd here:
1. mtdinfo.c doesn't initialize its region_info_user struct, instead
passing uninitialized data to mtd_regioninfo()
2. mtd_regioninfo() fails to utilize the 'regidx' parameter to fill out
the regionindex parameter properly, so the garbage from mtdinfo.c is
propagated to the ioctl()
This means that mtdinfo will continuously probe the same (possibly
out-of-range) erase region, instead of looping over the valid regions.
Let's fix this in the mtd_regioninfo() helper, and at the same time,
let's zero out the mtdinfo.c buffer, as an additional precaution to keep
from using uninitialized data.
Initial error report from Yang, when running "mtdinfo /dev/mtd0" on a
Cavium 6100 board:
root@CN61XX:~# mtdinfo /dev/mtd0
mtd0
Name: phys_mapped_flash
Type: nor
Eraseblock size: 65536 bytes, 64.0 KiB
Amount of eraseblocks: 128 (8388608 bytes, 8.0 MiB)
Minimum input/output unit size: 1 byte
Sub-page size: 1 byte
Additional erase regions: 0
Character device major/minor: 90:0
Bad blocks are allowed: false
Device is writable: true
libmtd: error!: MEMGETREGIONINFO ioctl failed for erase region 0
error 22 (Invalid argument)
Eraseblock region 0: info is unavailable
libmtd: error!: MEMGETREGIONINFO ioctl failed for erase region 1
error 22 (Invalid argument)
Eraseblock region 1: info is unavailable
Reported-by: Yang Wei <Wei.Yang@windriver.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
|
David Binderman <dcb314@hotmail.com> reports that the following piece of looks
wrong:
if (!args.subpage_size != mtd->min_io_size)
normsg("may be sub-page size is incorrect?");
I totally agree with him and I believe that we actually meant to have no
negation in fron to f 'args.subpage_size', so instead, the code should look
like this:
if (args.subpage_size != mtd->min_io_size)
normsg("may be sub-page size is incorrect?");
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
UBI's raw flash scan actually scans for UBI data, not UBIFS data (there
*are* UBI users that are not UBIFS!), so correct the warning message.
This also matches the comment in libscan.h.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
Amended by Artem.
Signed-off-by: Daniel van Gerpen <daniel@vangerpen.de>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
With the addition of block device access to UBI volumes, we now
add a simple userspace tool to access the new ioctls.
Usage of this tool is as simple as it gets:
$ ubiblock --create /dev/ubi0_0
will create a new block device /dev/ubiblock0_0, and
$ ubiblock --remove /dev/ubi0_0
will remove the device.
Artem: slightly changed the header comment.
Signed-off-by: Ezequiel Garcia <ezequiel.garcia@free-electrons.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
In the current code, the MTD_NANDFLASH stands for both the SLC and MLC.
In the kernel, the MTD_NANDFLASH only stands for the SLC now,
so in order to keep the logic unchanged, we should also check the MLC
NAND by MTD_MLCNANDFLASH.
Signed-off-by: Huang Shijie <b32955@freescale.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
|
|
This already has a --size option for controlling how many bytes to read
from the input. Add a --skip option to control the offset into the input
too. This way people don't have to do `dd | ubiupdatevol`.
While we're here, I've fixed the types used with args.size and the read
loop so that they can hold the right sizes (like setting a 32bit+ size).
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
We've got a few tools that prompt the user for "yes/no" questions.
Add a common helper to simplify the various implementations.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
Drop duplicate "and the", and tweak grammar slightly.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
A few error paths were closing the device, although it was not opened
yet.
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
Add -Q and --image-seq, remove double -v
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
Both logic (only print when not quiet) and the indentation suggest that
the braces around the block have been forgotten.
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
The offset (which is 64bits when mtd-utils are not compile with
WITHOUT_LARGEFILE) is calculated like that:
offset = nb * size;
But nb and size are int, so on 32bits platforms, there's a possible
overflow.
So, it should be replace with:
offset = (off_t)nb * size;
If WITHOUT_LARGEFILE is defined, there still be an overflow, but it's
what we want, right ?
Cheney Chen tested an ubiformat on a NAND (5.9 GiB mtd part).
Reported-by: Cheney Chen <cheneychencl2012@gmail.com>
Tested-by: Cheney Chen <cheneychencl2012@gmail.com>
Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|
|
If the kernel doesn't know the max_beb_per1024 parameter in the attach
ioctl, but the call still succeeded ubi_attach and ubi_attach_mtd will
return 1 instead of 0.
In this case, the ubiattach command will detach the device and fail with
an error message.
Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
|