Age | Commit message (Collapse) | Author |
|
This implements/adds selinux labelling support to mkfs.ubifs
utility. It adds an extra option in configure to enable
selinux labelling support and then finally in mkfs.ubifs adds
an extra option to pass the file_contexts which is looked up
for filesystem file labels.
- Default behavior is kept without selinux so as to not break existing
support where selinux library/headers may not be present.
- If this is configured with --with-selinux then XATTR from the
file_contexts(passed with --selinux option while mkfs.ubifs)
will be taken and not from the host file's xattr.
This is done to avoid the problem where the host OS may have
selinux enabled and hence same xattr names will be present in both
host filesystem files and from the --selinux=file passed.
So the existing behavior is kept mutually exclusive and preference
is given to selinux xattrs (if configured with --with-selinux).
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
add_xattr adds the xattr to the ubifs image and has nothing
to do with host XATTR support.
Now that we are adding support where selinux interfaces
may use this API even when host OS(where ubi/ubifs image
is being created) does not support XATTR -so remove it
from WITHOUT_XATTR #ifdef.
Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
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>
|
|
This patch adds a check to configure.ac that tests if pkg-config
is available on the system.
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>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
If we build mtd-utils outside the source path, we cannot use relative
paths to refere to headers in the source tree. We have to specify
absoulte paths using the top_srcdir variable.
This was done right for the utility binaries, but overlooked for the
unit test porgrams.
This patch fixes the header paths and SYSROOT variable for the unit
tests, so they build and run propperly outside the source tree.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Currently, Jffs2 clean marker is not written actually, because the oob
write length is set to 0 when do mtd_write().
So, get OOB available size at first, and set the correct clean marker
length, then program clean marker to free OOB area.
Fixes: d7e86124d55b ("mtd-utils: Support jffs2 flash-erase for large OOB (>32b)")
Signed-off-by: Xiaolei Li <xiaolei.li@mediatek.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: Xiaolei Li <xiaolei.li@mediatek.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
This patch exposes OOB available size to user. Then user can use
OOB free area according to OOB available size.
Steps to get OOB available size:
First, access /sys/class/mtd/mtdX/oobavail. If not exist, then
try to get ecc layout by ioctl "ECCGETLAYOUT". If none of them
work, set OOB available size to 0.
Signed-off-by: Xiaolei Li <xiaolei.li@mediatek.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Fixes: 1d04b4d5361a ("fix build when WITHOUT_LZO is set")
Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
When using a local root folder the permissions, user and group settings
are taken from the local folder. These permissions might be incorrect if
the folder has been created for the local user. Creating an UBIFS image
on my local system resulted in the following output on the target:
drwx------ 17 1000 1000 1264 Jan 1 00:00 .
drwx------ 17 1000 1000 1264 Jan 1 00:00 ..
drwxr-xr-x 2 root root 9104 May 30 2017 bin
drwxr-xr-x 7 root root 2760 Jan 1 00:00 dev
...
mkfs.ubifs aborts with an error message when the device table contains
a root entry. This patch allows setting the root folder permissions,
user and group to overwrite local configurations.
Signed-off-by: David Engraf <david.engraf@sysgo.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
When there is only a single erase block, the cross erase test
does not report sensible errors. Warn in case there is only
a single erase block instead of executing the test.
Signed-off-by: Stefan Agner <stefan@agner.ch>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Sometimes __xstat is called instead that makes tests fragile.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: Balint Reczey <balint.reczey@canonical.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
This fixes tests on s390x
Signed-off-by: Balint Reczey <balint.reczey@canonical.com>
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>
|
|
We use floating point just to print out KiB, MiB, GiB.
Avoid that to be klibc friendly.
Fixes compilation for aarch64 against klibc:
error: '-mgeneral-regs-only' is incompatible with floating-point argument
| printf("%s%.1f GiB", p, (double)bytes / (1024 * 1024 * 1024));
etc.
Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
If the number of erase blocks to use is not specified, ebcnt originally
set to -1 leads the program to exit with:
"Cannot run with less than two blocks."
If the number of erase blocks to use is not specified and thus ebcnt is
equal to -1, the expected behaviour is to perform the test on all the
erase blocks of the mtd partition.
This fixes the change introduced in
4458ad6481f60d9884925d5bc62a7954880d181b.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: Rock Lee <rockdotlee@gmail.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: Rock Lee <rockdotlee@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>
|
|
When porting some of the mtd-tests to user space, some code was
simplified. Among others, a while loop that iterates of page contents
was replaced with a for loop, but the old increment was left in place,
so every second byte was skipped.
This patch removes the erroneous second increment.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
mtd_debug: Remove a duplicate if case. MTD_CAP_NANDFLASH has only one
flag set (MTD_WRITEABLE). Directly below, we had a check for
MTD_WRITEABLE in the else branch which can't possible ever have
triggered. Checking for MTD_WRITEABLE in addition to the CAP constants
was probably not intended anyway, given the check for the individual
flags if all else fails.
integck: We already established that "r" is less than the number of
elements in the list, so the loop condition doesn't need to check
if w is NULL in addition. At least this way, the compiler "gets"
that w cannot be NULL below and doesn't issue warnings.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
When passing a long argument, actually use labs().
The other case of passing a float to "int abs(int)" and
casting the result to an int doesn't really make sense.
Pull the cast inside the abs().
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>
|
|
A common pattern in command line processing is having a usage()
function that prints out how to use the command line options and
then terminates.
The function is typically used inside a switch block for command
line options like `-h' or unknown options. In a lot of places, the
break keyword is omitted, because the function exits anyway. However,
this triggers gcc warnings about implicit fall-through.
Rather than adding a phony "/* fall-through */" this patch flags the
usage() style function with a gcc attribute, indicating that they do
not return and removes further superfluous break statements.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Use casts to void instead. Clang generates warnings about that by
default.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Systems that don't support extended attributes should still be able to
create ubifs images.
Signed-off-by: Pavel Roskin <plroskin@gmail.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
The file comm.c was erroneously compiled into makefiles. This patch
fixes that in the Automake file.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Technically it is initializied in the for loop right before being
used. From the conditional above, we know that the for loop is
executed at least once and the variable is always initialized, but
gcc doesn't appear to perform the same reasoning.
This patch adds an initialization of the variable for the sake of
making the compiler happy.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
The root node of the file system needs to be handled as a special case
when removing the owner information from the input.
Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Forbid the use of less than 2 eraseblocks in nandpagetest. It is obvious
that the test cannot run on zero block, but it cannot run on only one
block neither. The reason is: get_first_and_last_block() will return the
same id for both the first and the last blocks. In erasecrosstest(),
the logic is:
- erase/write/read/verify first block
- erase/write again first block
- erase *last* block
- read/verify first block
When using only one block, 'first' refers to the same block as 'last',
leading to erasing the block before reading it. Hence, the test would
fail with no actual reason.
Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com>
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 include directory exported by uuid.pc is */include/uuid, so uuid.h
must be included without any directory in the path. This usually works
out because uuid is installed in the normal prefix, so the parent
directory of what uuid has as include dir ends up in the include path
anyway. In case one uses a custom uuid outside of the regular include
path this breaks.
Signed-off-by: Rolf Eike Beer <eb@emlix.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Bit flip detection for written and erased pages tend to have different
implementations. Where written pages are detected and corrected using
ECC, erased pages are typically detected by ensuring that the number of
zeros is less than a specified threshold.
As such, it's necessary to have the 'nandbiterrs' test support the
testing of written and erased pages. Bit flips in erased pages are
emulated by rewriting the page in raw mode, to prevent the use of ECC.
Signed-off-by: Harpreet Eli Sangha <harpreet@nestlabs.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
This patch eliminates warnings generated by the -Wmissing-prototypes
option. With this flag set, we are now forced to have prototypes for
all global, exported functions, that have to be made visible to the
definitions and we are forced to mark all local functions as static.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
This patch borrows the compiler.m4 script from util-linux to check
for compiler support of a number of warning flags and sets them if
they are supported.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
AC_CHECK_HEADERS already makes sure our config header contains a
HAVE_$FOO_H macro if a header was found. There is no need to
awkwardly set our own Automake conditionals and check for it all
over the place in the Automake files.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
This patch attempts to cleanly seperate configure switches,
dependency checking and generating of output files inside
the autoconf configure.ac file.
Also, instead of aborting immediately if a dependency is missing,
the configure script now completes dependency checking and then
lists ALL dependencies that are missing for the selected build
options. In addtion, suggestions on how to disable some features
that require the missing dependencies are printed out.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|