Age | Commit message (Collapse) | Author |
|
This one is a bit trickier than adding WITH_ZLIB ifdefs. Some parts
of the code assume that zlib is always present and have complicated
fallback behavior. Particularly the "favor_lzo" compression method
that uses either zlib or lzo, whichever produces the better result.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
The jffsX-utils already have a CONFIG_JFFS2_ZLIB define, but it is
statically defined in a header and not used consistently. This patch
first replaces it with a "WITH_ZLIB" define, provided via automake,
to bring it in line with the already existing "WITH_LZO". Then, the
missing checks and typedefs are added in jffs2reader.c.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
- Simple fixup in autoconf.ac
- Make compilation of jffsX-utils compr_lzo.c optional. Simply
don't compile it if we built without LZO and remove the place
holders. They are not used anyway if we build without LZO.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Don't use super pedantic parsing of the argument and work with the
generated variable instead of assigning it to our own and set it
to "check" if not value is assigned. Then search for a dependency
if the with variable is anything other than "no" and fail if it
was set to "yes".
In addition, the WITHOUT_xxx defines are replaced with WITH_xxx defines.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
After removing libtool, there is no more cross-check for AR. Because
some slightly older versions of autoconf don't have AC_PROG_AR, simply
insert the implementation one-liner.
We already tried bumping the minimum autoconf version once in the past,
but apparently that is an issue for a number of distros.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
mkfs.uibfs can add Selinux xattrs from a labeling file using
libselinux to parse it. The commit that added this feature simply
introduced a separate function, inode_add_selinux_xattr, which is
called instead of inode_add_xattr. If no --selinux argument is
specified for mkfs.ubifs, this is a no-op.
The problem is, that this breaks xattr scanning for any build with
Selinux enabled. The Selinux version is always called and it does
not scan for xattrs on the filesystem, or dispatch to the original.
This commit fixes the xattr scanning behavior. We unconditionally call
both functions (they each have no-op implementations if the feature
is missing) and in the regular xattr scanning code, we skip selinux
attributes, if the --selinux option was given.
Fixes: f1feccec5ad8 ("mkfs.ubifs: Implement selinux labelling support")
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
|
|
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 <chengzhihao1@huawei.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
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 <chengzhihao1@huawei.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
JFFS2 supports buffer mode for ECC'd NOR Flash that cleanmarker size
is rounded up to mtd->writesize, while the '-j' option in flash_erase
utility uses fixed 12 bytes. That makes flash program ops unaligned to
mtd->writesize and causes program error or disables ECC.
The mkfs.jffs2 utility supports '-c' option that allows users to specify
cleanmarker size. This patch implements '-c' option in the flash_erase
that can be used along with '-j' option.
Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
This option is useful for power fail resilient bootloader updates, for
systems that check only the partition header for validity before
attempting to load the bootloader. For example zynq.
Postponing the write of a specified amount of bytes at the beginning of
a bootloader makes sure a written bootloader slot is not considered
valid until all the data is written.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
This no-op was remarked by coverity. According to git-blame, it has
been this way since the initial commit in 2006.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
For the most part, this was straight forward. For the very old
releases, there were lots of changes that are not straight forward
to untangle.
The following two releases posed issues:
- Version 1.4.1 does not have a tag. The release tarball on FTP
is from 2010-10-19 and appears to contain 1.4.0 with commit
b864c387e8f16273aad1453d6457d847e29c3d25 cherry-picked on top
of it (except for one line that was fixed in the release, but
broken in the repo).
- Version 1.4.6 also does not have a tag. The release tarball
is from 2011-08-19. This _presumably_ corresponds with commit
b602ab59b9782003d1179488d8c1580bc8563738 that bumps the version
number.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
The CHANGELOG tries to summarize the change history of the project
and currently contains changes from 2.0.0 onwards that could easily
be extracted from the release mails.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
On error, lseek returns a negative value. We need to check for that
and abort, instead of passing -1 to malloc and later on to read_nocheck.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
In nandflipbits, nandtest and ubiscan, uint64_t integers are printed
to stdout using "%llu" as a format specifier, but on platforms like
x86_64, uint64_t is actually typedef'd as `unsigned long` only.
For compatibillity across platforms, simply use the C99 printfs
macros instead.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
The libubigen.h header relies on external declarations in ubi-media.h.
While not technically needed, it generates warnings in mtdinfo.c if
those are not visible. All other places where libubigen is used include
the header first. This is primarily to silence compiler warnings related
to the missing declrations.
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>
|
|
We do not build any shared libraries, there is no reason to use libtool
or disable static. We do build static libraries, for which we need ranlib.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Running nandtest on devices with sizes of 4Gb or more does not work, as
the size returned in mtd_info_user is reported as 0 for 4Gb devices for
example.
The patch uses sysfs to figure out the size of the nand device (as
recommended in a comment in include/mtd/mtd-abi.h) and changes sizes
and offsets to 64 bit values.
[From: Christian Wendt <cw@brainaid.de>]
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
This introduces a new feature to the MTD command line utilities that
allows MTD devices to be referenced by name instead of device node. For
example this looks like:
> # Display info for the MTD device with name "data"
> mtdinfo mtd:data
> # Copy file to MTD device with name "data"
> flashcp /my/file mtd:data
This follows the syntax supported by the kernel which allows MTD
device's to be mounted by name[1].
Add the function mtd_find_dev_node() that accepts an MTD "identifier"
and returns the MTD's device node. The function accepts a string
starting with "mtd:" which it treats as the MTD's name. It then attempts
to search for the MTD, and if found maps it back to the /dev/mtdX device
node. If the string does not start with "mtd:", then assume it's the old
style and refers directly to a MTD device node.
The function is then hooked into existing tools like flashcp, mtdinfo,
flash_unlock, etc. To load in the new MTD parsing code in a consistent
way across programs.
[1] http://www.linux-mtd.infradead.org/faq/jffs2.html#L_mtdblock
Signed-off-by: Brandon Maier <brandon.maier@collins.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
This is a convenience function for end users. In some situations it's
easier to reference MTD device's by their name then by MTD number, as
the name may be more reliable if device partitioning is dynamic or for
porting between systems.
Signed-off-by: Brandon Maier <brandon.maier@collins.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Below failure happens when mkfs.ubifs --selinux=FILE ...
"Error: bad file context FILE 1"
"No such file or directory (error 2)"
It is fixed by this change.
Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Add correct casting for written to prevent overflow that size_t is
only 32 bits on a 32-bit platform.
Signed-off-by: cchoux <chou.cosmo@gmail.com>
Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
The Read While Write (RWW) feature allows to perform reads from the
flash array into cache while a program (from cache) or an erase
operation happens, provided that the two areas are located on different
banks.
The main benefit is the possible reduced latency when requesting to read
a page while a much longer operation is ongoing, like a write or an
erase.
We can try to compare the positive impact of such a feature by enhancing
the flash_speed test tool with the following test:
- Measure the time taken by an eraseblock write in parallel with an
eraseblock read.
- Measure when the read operation ends.
- Compare the two to get the latency saved with the RWW feature.
To be sure the mtd_write actually starts (and acquires the necessary
locks) before the mtd_read does, we use SCHED_FIFO at rather high
(arbitrary) priorities, respectively 42 and 41.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
In order to be able to have interleaved measures, let's not use the
start and finish global variables from the time helpers directly,
provide parameters for these variables so that we can provide either the
global entries, or more specific ones when relevant.
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
If the partition size passed in to the BLKPG_ADD_PARTITION ioctl is 0,
Linux will make the partition fill to the end of the device[1]. Document
this feature in the help.
[1] https://elixir.bootlin.com/linux/v6.0.6/source/drivers/mtd/mtdpart.c#L254
Signed-off-by: Brandon Maier <brandon.maier@collins.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: Brandon Maier <brandon.maier@collins.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
The --partition mode is not verifying that data is being written
successfully.
Signed-off-by: Brandon Maier <brandon.maier@collins.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
The DIFF_BLOCKS code requires that src and dest buffers be large enough
to hold one MTD erasesize. This is because each loop operates on one
eraseblock so that it can erase and write one whole sector. But the src
and dest buffers are fixed at BUFSIZE, so on platforms where the MTD
erasesize are larger then BUFSIZE it will overflow the buffers.
Instead allocate the buffers dynamically so that they can be sized to
fit the erasesize.
Signed-off-by: Brandon Maier <brandon.maier@collins.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Most of the uses of log_printf fall into two styles
> if (flags & FLAG_VERBOSE)
> log_printf(LOG_NORMAL, ...);
or
> log_printf(LOG_ERROR, ...)
> exit(EXIT_FAILURE);
Replace them with log_verbose and log_failure respectively.
Signed-off-by: Brandon Maier <brandon.maier@collins.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: Brandon Maier <brandon.maier@collins.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Add a safe_lseek wrapper to check for lseek errors.
Signed-off-by: Brandon Maier <brandon.maier@collins.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Share the writing code between the two write implementations.
Signed-off-by: Brandon Maier <brandon.maier@collins.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
gcc 9.3.0-17ubuntu1~20.04 warning on time_t ctime value is :
Fix taking address of packed member of ‘struct jffs2_raw_inode’ may
result in an unaligned pointer value [-Waddress-of-packed-member].
Signed-off-by: Frederic Germain <frederic.germain@gmail.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: Frederic Germain <frederic.germain@gmail.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
This patch replace "free(rfd.sector_map)" with "free(rfd.header)"
to fix memory leak.
Signed-off-by: liaohua <liaohua4@huawei.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
In 54d68799, mtd->eb_cnt was enforced to be '1' if MTD_NO_ERASE is set.
This was done with the aim of preventing divisions by zero.
However, even if MTD_NO_ERASE is set, mtd->eb_size (eraseblock size) can
still be set to a non-zero value which would not cause a division by
zero.
Instead, enforcing an eraseblock count of '1' here even leads to
inconsistent eraseblock counting in mtd-utils and lets for example a
'flash_erase' on an mtdnand device fail:
| # flash_erase /dev/mtd0 0 0
| Erasing 32768 Kibyte @ 0 -- 0 % complete libmtd: error!: bad eraseblock number 255, mtd0 has 1 eraseblocks
| flash_erase: error!: /dev/mtd0: MTD Erase entire chip failureTrying one by one each sector.
| error 22 (Invalid argument)
| Erasing 128 Kibyte @ 0 -- 0 % complete libmtd: error!: bad eraseblock number 1, mtd0 has 1 eraseblocks
| flash_erase: error!: /dev/mtd0: MTD get bad block failed
| error 22 (Invalid argument)
Also mtdinfo would look inconsistent (eraseblock size vs amount):
| # mtdinfo /dev/mtd0
| mtd0
| Name: mtdram test device
| Type: ram
| Eraseblock size: 131072 bytes, 128.0 KiB
| Amount of eraseblocks: 1 (33554432 bytes, 32.0 MiB)
| Minimum input/output unit size: 1 byte
| Sub-page size: 1 byte
| Character device major/minor: 90:0
| Bad blocks are allowed: false
| Device is writable: true
Fix this by enforcing mtd->eb_cnt to be '1' only when mtd->eb_size is
actually zero and would lead to a division by zero otherwise.
Fixes: 54d68799 ("libmtd: avoid divide by zero")
Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Commit 0a5e2fa5c1e4 ("mtd-utils: add optional offset parameter to
flash_otp_dump") introduced an offset parameter. This should have
been optional, but there was a typo. Fix it.
Reported-by: Sergei Antonov <saproj@gmail.com>
Fixes: 0a5e2fa5c1e4 ("mtd-utils: add optional offset parameter to flash_otp_dump")
Signed-off-by: Michael Walle <michael@walle.cc>
Reviewed-by: Sergei Antonov <saproj@gmail.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
--compr-mode is not accepted as an alias of --compression-mode.
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
This header is not needed, moreover it includes linux/mount.h which is
now in conflict[1] with glibc provided sys/mount.h from glibc 2.36 onwards
[1] https://sourceware.org/glibc/wiki/Release/2.36
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
If a bit is flipped in block 1 or higher, the OOB is corrupted with the
OOB of block 0. Mtd_read_oob API has to take into account the block number
to be able to calculate the right offset.
Fixes: 9fc8db29cf62 ("mtd-utils: Add nandflipbits tool")
Signed-off-by: Christophe Kerello <christophe.kerello@foss.st.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
When using --vol_id and that volume is missing, it should return
non-zero like the --name option does.
Signed-off-by: Andrew Mellor <andrew.mellor@casa-systems.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
When writing a full 4GiB NAND to a file end_addr becomes 0x100000000.
With that writing out the first page to the file doesn't happen
because size_left is calculated to 0x100000000 - 0 = 0x100000000
which is then truncated to 32bit and becomes zero. Fix this by
using an appropriate 64bit type for size_left.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Such blocks may be incorrectly treated as empty (even though they may
have non-erase OOB). Warn about it so people may start useing
--skip-all-ffs .
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Using == with `test` is a bashism. POSIX shell only supports =.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|
|
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
|