]> git.infradead.org Git - mtd-utils.git/log
mtd-utils.git
7 years agoRelease mtd-utils-2.0.0 v2.0.0
David Oberhollenzer [Thu, 22 Dec 2016 10:21:37 +0000 (11:21 +0100)]
Release mtd-utils-2.0.0

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
7 years agomtd-utils: Add configure switches to disable jffsX or ubifs tools
David Oberhollenzer [Wed, 21 Dec 2016 14:42:12 +0000 (15:42 +0100)]
mtd-utils: Add configure switches to disable jffsX or ubifs tools

For some applications, like building a root filesystem for an embedded
device, it may be desireable to only build and install a subset of the
mtd-utils. This can be done throught the targets of the generated
Makefile and hand picking executables, however the jffsX and ubifs
utilities have external build dependencies that may not be needed.

This patch adds configure switches to disable building the jffsX and
ubifs utilities. Their respective build dependencies (zlib, lzo, uuid)
are only requested if the tools are being built.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Reviewed-by: Richard Weinberger <richard@nod.at>
7 years agoRelease mtd-utils-2.0.0-rc2 v2.0.0-rc2
David Oberhollenzer [Wed, 14 Dec 2016 16:05:35 +0000 (17:05 +0100)]
Release mtd-utils-2.0.0-rc2

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
7 years agoEnable tests so they are included in the make dist target
David Oberhollenzer [Wed, 14 Dec 2016 16:04:24 +0000 (17:04 +0100)]
Enable tests so they are included in the make dist target

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
7 years agomtd-utils: Correct casting for final status report in flashcp
Jonathan Fether [Wed, 14 Dec 2016 02:00:28 +0000 (18:00 -0800)]
mtd-utils: Correct casting for final status report in flashcp

Add correct casting for filestat.st_size in flashcp.c. While the
interim status updates had correct casting from commit 08b243, the
final update was not.

Signed-off-by: Jonathan Fether <jonf@mds.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
7 years agoFix packaging of unit test files
David Oberhollenzer [Mon, 12 Dec 2016 10:31:59 +0000 (11:31 +0100)]
Fix packaging of unit test files

Previously, the unit test sysfs mock files and headers were not
added to the distribution packag. Not packaging the header leads
to compilation of the unit tests failing. Not packaging the stub
files caueses the unit tests themselves to fail.

This patch explicitly adds the header and sysfs mock files to the
distribution target, allowing the unit tests to be used outside
the git tree.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
7 years agonandwrite: Factor out buffer checking code
Marek Vasut [Fri, 9 Dec 2016 01:47:41 +0000 (02:47 +0100)]
nandwrite: Factor out buffer checking code

Pull the buffer content checking code into separate function and
simplify the code invoking it slightly.

Signed-off-by: Marek Vasut <marex@denx.de>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
7 years agoRelease mtd-utils-2.0.0-rc1 v2.0.0-rc1
David Oberhollenzer [Wed, 7 Dec 2016 14:04:48 +0000 (15:04 +0100)]
Release mtd-utils-2.0.0-rc1

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
7 years agocommon: Fix 'unchecked return code' warnings
Boris Brezillon [Fri, 25 Nov 2016 17:30:41 +0000 (18:30 +0100)]
common: Fix 'unchecked return code' warnings

Several tools are simply not checking return code of functions marked
with 'warn_unused_result'.

Provide wrappers for the read/write functions to avoid patching old
code and providing proper error handling.
Fix the remaining ones (calls to fgets() and system()).

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
7 years agocommon: Fix PRI{x,d}off definitions for x86_64 platform
Boris Brezillon [Fri, 25 Nov 2016 17:30:40 +0000 (18:30 +0100)]
common: Fix PRI{x,d}off definitions for x86_64 platform

Compiling for x86_64 generates a lot of warning because the PRIxoff_t and
PRIdoff_t are not properly defined, which comes from the missing
SIZEOF_LONG definition.

Use the autotools to generate a config.h header, include this header from
common.h and ask autoheader to generate the SIZEOF_LONG and SIZEOF_LOFF_T
definitions.
Use these new definitions to assign the proper descriptors to PRIxoff_t
and PRIdoff_t.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
7 years agonandwrite: add skip-all-ff-pages-option
Kees Trommel [Tue, 6 Dec 2016 08:21:19 +0000 (09:21 +0100)]
nandwrite: add skip-all-ff-pages-option

Signed-off-by: Kees Trommel <ctrommel@linvm302.aimsys.nl>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
7 years agoDefine WITHOUT_XATTR if sys/acl.h or sys/xattr.h is missing
David Oberhollenzer [Tue, 29 Nov 2016 21:31:11 +0000 (22:31 +0100)]
Define WITHOUT_XATTR if sys/acl.h or sys/xattr.h is missing

The programs mkfs.jffs2 and mkfs.ubifs include those two headers if
WITHOUT_XATTR is not defined. Up to now, this macro is only defined
if the configure script is run with --without-xattr. If the headers
are not present on a system and the configure script is run without
special flags set, the build fails.

This patch adds a check for the presence of those headers and disables
the feature if one of the headers is missing.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
7 years agoAllow version string to have a release candidate suffix
David Oberhollenzer [Thu, 17 Nov 2016 14:55:27 +0000 (15:55 +0100)]
Allow version string to have a release candidate suffix

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
7 years agoMove ubi-utils libraries to common library location
David Oberhollenzer [Thu, 1 Sep 2016 13:52:33 +0000 (15:52 +0200)]
Move ubi-utils libraries to common library location

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>
7 years agoMerge rest of ubiutils-common into libmtd common
David Oberhollenzer [Thu, 1 Sep 2016 13:27:38 +0000 (15:27 +0200)]
Merge rest of ubiutils-common into libmtd common

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>
7 years agoRemove unused ubiutils_print_text from ubi-utils common
David Oberhollenzer [Thu, 1 Sep 2016 13:08:06 +0000 (15:08 +0200)]
Remove unused ubiutils_print_text from ubi-utils common

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>
7 years agoAdd ubinize manpage
David Oberhollenzer [Thu, 1 Sep 2016 13:03:14 +0000 (15:03 +0200)]
Add ubinize manpage

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>
7 years agoAdd Makefile for unittests
Daniel Walter [Wed, 31 Aug 2016 08:11:14 +0000 (10:11 +0200)]
Add Makefile for unittests

Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
7 years agoAdd unittests for libubi
Daniel Walter [Wed, 31 Aug 2016 08:09:15 +0000 (10:09 +0200)]
Add unittests for libubi

Add unittests for most functions provided by
libubi

Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
7 years agoAdd unittest for libmtd
Daniel Walter [Wed, 31 Aug 2016 08:08:30 +0000 (10:08 +0200)]
Add unittest for libmtd

unit tests for most functions provided by
libmtd.

Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
7 years agoAdd sysfs tree for unittests
Daniel Walter [Wed, 31 Aug 2016 08:09:37 +0000 (10:09 +0200)]
Add sysfs tree for unittests

add mocked sysfs used by libmtd and libubi
unittests

Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
7 years agoAdd support for sysfs mocking
Daniel Walter [Wed, 31 Aug 2016 08:05:36 +0000 (10:05 +0200)]
Add support for sysfs mocking

In order to use test files, allow sysfs root
to be set during compile time

Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
7 years agoAdd unit test helpers
Daniel Walter [Wed, 31 Aug 2016 08:10:55 +0000 (10:10 +0200)]
Add unit test helpers

Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
7 years agoFix uninitialized buffers
Daniel Walter [Wed, 31 Aug 2016 08:06:28 +0000 (10:06 +0200)]
Fix uninitialized buffers

Uninitialized buffers lead to failing
unittests, since padding was not set to 0.
Additionally this stops valgrind from complaining as well.

Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
7 years agomtd-utils: Add nand sub-page test utility
David Oberhollenzer [Mon, 22 Aug 2016 14:21:57 +0000 (16:21 +0200)]
mtd-utils: Add nand sub-page test utility

Basically a user space port of the mtd sub page test kernel module.
In addition to the module parameters, the utility supports using
only a sub-range of the flash erase blocks with a configurable
stride and can restore the block contents after the test.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
7 years agomtd-utils: Add nand page test utility
David Oberhollenzer [Mon, 22 Aug 2016 14:19:55 +0000 (16:19 +0200)]
mtd-utils: Add nand page test utility

Basically a user space port of the mtd page test kernel module.
In addition to the module parameters, the utility supports using
only a sub-range of the flash erase blocks with a configurable stride.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
7 years agomtd-utils: Add flash read test utility
David Oberhollenzer [Mon, 22 Aug 2016 14:14:37 +0000 (16:14 +0200)]
mtd-utils: Add flash read test utility

Basically a user space port of the mtd read test kernel module.
In addition to the module parameters, the utility can scan only
a sub-range of the flash erase block with a configurable stride.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
7 years agomtd-utils: Add nand flash bit errors test
David Oberhollenzer [Mon, 22 Aug 2016 14:12:20 +0000 (16:12 +0200)]
mtd-utils: Add nand flash bit errors test

Basically a user space port of the mtd speed test kernel module.
In addition to the module parameters, the utility can resture
the block contents after test and allows setting the maxium writes
for the test.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
7 years agomtd-utils: Add flash speed test utility
David Oberhollenzer [Mon, 22 Aug 2016 14:10:16 +0000 (16:10 +0200)]
mtd-utils: Add flash speed test utility

Basically a user space port of the mtd speed test kernel module.
In addition to the block offset and count module parameters, the
utility supports a block stride and can restore the block contents
after test. Furthermore, a flag can be used to disable destructive
tests (i.e. only perform read speed tests).

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
7 years agomtd-utils: Add flash stress test utility
David Oberhollenzer [Mon, 22 Aug 2016 14:08:34 +0000 (16:08 +0200)]
mtd-utils: Add flash stress test utility

Basically a user space port of the mtd stress test kernel module.
In addition to the block offset and count module parameters, the
utility supports a block stride and can restore the block contents
after test.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
7 years agomtd-utils: Add flash torture test utility
David Oberhollenzer [Mon, 22 Aug 2016 14:05:19 +0000 (16:05 +0200)]
mtd-utils: Add flash torture test utility

Basically a user space port of the mtd torture test kernel module. In
addition to the block offset and count module parameters, the utility
supports a block stride and can restore the block contents after test.

In contrast to the kernel module, the torture test is implemented by
the libmtd mtd_toruture function and thus doesn't allow for similarly
fine grained options on diagnostics.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
7 years agomtd-utils: Add multi-block erase function
David Oberhollenzer [Mon, 25 Apr 2016 22:13:23 +0000 (00:13 +0200)]
mtd-utils: Add multi-block erase function

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
7 years agoAdd libmissing
David Oberhollenzer [Thu, 1 Sep 2016 09:20:05 +0000 (11:20 +0200)]
Add libmissing

This patch adds a libmissing library to mtd-utils, containing
implementations of functionality found in glibc but typically
missing from embedded C libraries such as uclibc ot musl.

For now, the library only contains stub implementations of
the backtrace*() family of functions.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
7 years agoAdd -lrt for clock_gettime() in glibc < 2.17.
David Gstir [Thu, 15 Sep 2016 05:20:07 +0000 (07:20 +0200)]
Add -lrt for clock_gettime() in glibc < 2.17.

Some tools use clock_gettime() which requires building with -lrt for
versions of glibc before 2.17.

Signed-off-by: David Gstir <david@sigma-star.at>
7 years agoFix make_a_release script
David Oberhollenzer [Thu, 21 Jul 2016 13:29:12 +0000 (15:29 +0200)]
Fix make_a_release script

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
7 years agoFix paths in .gitignore and add autotools generated files
David Oberhollenzer [Tue, 19 Jul 2016 13:30:53 +0000 (15:30 +0200)]
Fix paths in .gitignore and add autotools generated files

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
7 years agoUnify version string printing
David Oberhollenzer [Tue, 19 Jul 2016 13:06:58 +0000 (15:06 +0200)]
Unify version string printing

When a program does sophisticated enough command line processing
(i.e. getopt), make sure it responds to -V and --version.

When a program prints a version string, make sure it uses the
common_print_version macro to print out its name, that it is part
of mtd-utils and the mtd-utils version from the build system in a
fashion similar to common program packages like the GNU coreutils.

When a program responds to -V/--version or -h/--help, make sure it
reports success exit status.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
7 years agoIntegrate tests into autotools build system
David Oberhollenzer [Wed, 13 Jul 2016 14:10:28 +0000 (16:10 +0200)]
Integrate tests into autotools build system

Add automake files for the test binaries. If configured to do so,
install the test binaries to libexec/mtd-utils and use autoconf to
fix the paths in the test scripts.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
7 years agoChange build system to autotools
Richard Weinberger [Tue, 26 Apr 2016 20:09:08 +0000 (22:09 +0200)]
Change build system to autotools

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>
7 years agoRemove feature-removal-schedule.txt
David Oberhollenzer [Thu, 1 Sep 2016 15:47:48 +0000 (17:47 +0200)]
Remove feature-removal-schedule.txt

This patch removes the old feature-removal-schedule.txt file from
mtd-utils, mostly for reasons similar to the ones that lead to the
decision of removing the feature-removal-schedule.txt from the kernel.

Removing features by itself is rather problematic as there is no
simple way of estimating whether something is being used widley or
not at all. Thus, consensus usually tends towards not removing
features at all.

Even if there is a file anouncing feature removal, users in large
won't read this file _if_ it is even included in distribution
packages. People working on mtd-uils would end up removing features
that _they_ find useless and users would start complaining once
their setups break after they install a new version of mtd-utils.

In conclusion, once introduced, features should not be removed to
begin with and this file is entirely usless.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
7 years agoRemove duplicate copies of GPLv2 license text
David Oberhollenzer [Tue, 23 Aug 2016 13:40:44 +0000 (15:40 +0200)]
Remove duplicate copies of GPLv2 license text

Some of the programs in the mtd-utils used to be seperate packages that
were at some point merged into mtd-utils. As a result, some subdirectories
contain their own README and COPYING files with copies of the GPLv2
license text.

Since those programs are now part of mtd-utils that contains a copy of the
GPLv2 in the file COPYING in the package root directory, those extra files
can be removed, as there is no need for distributing an extra copy of the
license text for each individual program in the bundle.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
7 years agoRemove RPM spec file
David Oberhollenzer [Tue, 23 Aug 2016 10:17:28 +0000 (12:17 +0200)]
Remove RPM spec file

Building packages for distributions is typically something highly
distribution specific. While there are widely used package formats
like RPM, implementing a de-facto standard, the build process,
list of files actually packaged, list of required dependencies,
package grouping, package versioning, etc... is still _very_
distribution specific. In fact, this spec file completely fails to
address some of these points.

Actual RPM based distributions out there currently use their own,
distribution specific, RPM spec files that were possibly _based_ on
this one at some point (judging from similar descriptions).

The spec file _may_ have worked at some point, but it definitely doesn't
work with the new build system and there is no real reason to fix it
(which, by definition, isn't possible for the reasons above) and drag it
along for another decade or two.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
7 years agoRemove unused and broken mtd_write_img function from libmtd
David Oberhollenzer [Thu, 25 Aug 2016 11:41:50 +0000 (13:41 +0200)]
Remove unused and broken mtd_write_img function from libmtd

The function _tries_ to support short reads but doesn't adjust the
pointer into the buffer. If a short read happens, we scrambles the
flash contents. Interrupted reads aren't handled. Short or
interrupted writes aren't handled at all. Either a write succeeds
writing the entire buffer or the function gives up.

During an attempt at fixing it, it was discovered, that no mtd-utils
program uses this function. Furthermore, its highly specific nature
makes it more of a "feature looking for use case".

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
7 years agoRemove unused legacy_libmtd_open internal libmtd function
David Oberhollenzer [Thu, 25 Aug 2016 11:38:20 +0000 (13:38 +0200)]
Remove unused legacy_libmtd_open internal libmtd function

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
7 years agoRemove jffs-dump.c
David Oberhollenzer [Tue, 23 Aug 2016 11:12:06 +0000 (13:12 +0200)]
Remove jffs-dump.c

This _entire_ file is dead code. The download packages on the FTP
server contain it all the way back to mtd-utils 1.0, but it isn't
built in any of them. The git history (which dates back to 2006)
contains no instance where that file was ever used in a build process.
A quick look at various distribution packages didn't reveal any that
contained a jffs-dump utilty. There have been no major changes to this
file since the initial commit. It won't even compile as it doesn't have
a PROGRAM_NAME defined required by common.h at least since 2010.

At this point, it can be safeley assumed that nobody will miss this.
They had at least 10 years to do something about it.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
7 years agoEliminate warnings about implicit non-const casting in libmtd
David Oberhollenzer [Tue, 23 Aug 2016 08:51:21 +0000 (10:51 +0200)]
Eliminate warnings about implicit non-const casting in libmtd

The mtd_get_dev_info1 function reads (among other things) name and type
string into coresponding struct mtd_dev_info fields.

The struct mtd_dev_info has the string fields marked const, requiring
them to be cast to non-const version during initialization.

This cast was previously omitted from the dev_read_data calls,
triggering warnings during compilation.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
7 years agonanddump: check write function result for errors
Rafał Miłecki [Mon, 18 Jul 2016 15:09:45 +0000 (17:09 +0200)]
nanddump: check write function result for errors

Errors may happen, it's e.g. easy on embedded devices to run out of space
when dumping big partitions. This patch adds a helper function for
writing. It deals with partial writes and just returns 0 on success or
error number.

The old code didn't check for errors at all which could result in
incomplete dumps without exiting with an error.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
8 years agomtd-utils: mkfs.jffs2: initialize lzo decompression buffer size
David Oberhollenzer [Mon, 11 Jul 2016 13:42:20 +0000 (15:42 +0200)]
mtd-utils: mkfs.jffs2: initialize lzo decompression buffer size

This fix was initialially part of a patch submitted by Carsten Schlote
in January 2009. It didn't get merged back then because of coding style
issues and a proposed buffer size change guessed by shotgun debugging.

I was unable to reproduce the claimed segfaults in the compression
function that lead to the proposed buffer size change. Valgrind did
not issue any errors or warnings about the code in question either,
so I didn't include the proposed buffer size change.

The original patch also added a call to lzo_init(), which (according
to LZO documentation & source code) does not actually perform any
initialization, but only checks at runtime that the data type sizes and
endianness of the library code match those in the caller code and
should be unnecessary.

Other fixes from the original patch have already been added over
the years.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
8 years agofs-tests: integrity: don't include header <bits/stdio_lim.h>
Rahul Bedarkar [Thu, 18 Aug 2016 17:41:30 +0000 (23:11 +0530)]
fs-tests: integrity: don't include header <bits/stdio_lim.h>

In commit ca7a5eda221d("integck.c: Fix buffer overflow in save_file")
we started including header <bits/stdio_lim.h>.

But with musl C library, we get following build error

  integck.c:37:28: fatal error: bits/stdio_lim.h: No such file or directory
   #include <bits/stdio_lim.h>
                              ^
  compilation terminated.
  make[2]: *** [integck] Error 1

Header <bits/stdio_lim.h> is not available in musl C library. However
<stdio.h> has all definition that <bits/stdio_lim.h> supposed to be
providing. Moreover <bits/stdio_lim.h> shouldn't be included directly
instead we should be using <stdio.h>.

Since we already include <stdio.h> and in case of uClibc or glibc
<bits/stdio_lim.h> gets included internally, we can safely remove it.

This build issue is found by Buildroot autobuilder
http://autobuild.buildroot.net/results/175/1754861457af520480cc34d7d2d0edff2868ff66/

Fixes: ca7a5eda221d("integck.c: Fix buffer overflow in save_file")
Signed-off-by: Rahul Bedarkar <rahul.bedarkar@imgtec.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
8 years agomtd-utils: fix wrong format specifiers on mips32
Mathias Kresin [Sun, 12 Jun 2016 10:05:45 +0000 (12:05 +0200)]
mtd-utils: fix wrong format specifiers on mips32

This patch fixes the follwing compiler warnings:

flash_erase.c: In function 'show_progress':
flash_erase.c:56:22: warning: format '%lx' expects argument of type 'long unsigned int', but argument 3 has type 'off_t {aka long long int}' [-Wformat=]
  bareverbose(!quiet, "\rErasing %d Kibyte @ %"PRIxoff_t" -- %2i %% complete ",
                      ^
./include/common.h:81:10: note: in definition of macro 'bareverbose'
   printf(fmt, ##__VA_ARGS__);

which are linked to the following buggy numerical output:

Erasing 128 Kibyte @ 0 -- 917504 % complete flash_erase:  Cleanmarker written at 0
Erasing 128 Kibyte @ 0 -- 1048576 % complete flash_erase:  Cleanmarker written at 0

Signed-off-by: Mathias Kresin <dev@kresin.me>
Signed-off-by: Richard Weinberger <richard@nod.at>
8 years agomtd-utils: mtd_debug: check amount of data read.
Michal Suchanek [Mon, 27 Jul 2015 13:47:10 +0000 (15:47 +0200)]
mtd-utils: mtd_debug: check amount of data read.

The kernel refuses to read more data from a MTD device than the device
size. However, mtd_debug does not check the amount of data read as
returned by read(2) and assumes the requested amount is always read when
there is no error. Reading 8M data from a 4M flash chip results in 8M
file containing the flash data at the start.

Signed-off-by: Michal Suchanek <hramrach@gmail.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
8 years agomtd-utils: nanddump: write requested length only
Gary Bisson [Wed, 18 Dec 2013 01:03:06 +0000 (17:03 -0800)]
mtd-utils: nanddump: write requested length only

nanddump was always writing a whole page of data into the output
discarding the length actually requested. This patch allows to
write only the remaining length if oob is omitted. In case oob
is needed, it makes sense to copy the entire page.

Signed-off-by: Richard Weinberger <richard@nod.at>
8 years agolibmtd: Fix return status in mtd_torture test function
David Oberhollenzer [Mon, 25 Apr 2016 22:13:22 +0000 (00:13 +0200)]
libmtd: Fix return status in mtd_torture test function

This patch fixes the return status of the mtd_torture function
in libmtd.

The torture test function is currently only used by the ubiformat
utility to check if a block is bad after a write fails (blocks are
marked bad if the function returns an error status). However, the
way the function was written, it ALWAYS returns an error value
regardless of whether it failed or not.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agofix build warnings w/newer glibc & _BSD_SOURCE
Mike Frysinger [Sun, 17 Apr 2016 02:11:51 +0000 (22:11 -0400)]
fix build warnings w/newer glibc & _BSD_SOURCE

The _BSD_SOURCE define has been deprecated for a while now.  Instead,
code should be defining _DEFAULT_SOURCE.  By defining both, it'll work
with both new & old versions warning-free.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agoinclude sys/sysmacros.h for major/minor/makedev
Mike Frysinger [Sun, 17 Apr 2016 02:30:45 +0000 (22:30 -0400)]
include sys/sysmacros.h for major/minor/makedev

These functions have always been defined in sys/sysmacros.h under
Linux C libraries.  For some, including sys/types.h implicitly
includes that as well, but glibc wants to deprecate that, and some
others already have.  Include the header explicitly for the funcs.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agoMakefile: install: don't look for scripts in BUILDDIR
Brian Norris [Tue, 26 Jan 2016 21:36:56 +0000 (13:36 -0800)]
Makefile: install: don't look for scripts in BUILDDIR

Our ${SCRIPTS} (e.g., flash_eraseall) are not found in the build
directory; they should be found in their original location.

This fixes a typo in the Makefile refactoring, which caused 'make
install' to fail with messages like:

  make: *** No rule to make target '[...my source-build directory...]/armv7a-cros-linux-gnueabi/misc-utils/flash_eraseall'. Stop.

because the install target is looking in the wrong place for
flash_eraseall.

Fixes: 7d81790ced34 ("mtd-utils: Restructure the mtd-utils source.")
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Reviewed-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
8 years agomkfs.ubifs: <sys/xattr.h>, not <attr/xattr.h>
Brian Norris [Sat, 23 Jan 2016 21:31:50 +0000 (13:31 -0800)]
mkfs.ubifs: <sys/xattr.h>, not <attr/xattr.h>

To be consistent with mkfs.jffs2, and to get this to build on my
machine, it looks like we should use <sys/xattr.h>, not <attr/xattr.h>.

Fixes this error, seen on an Ubuntu 14.04 build system:

  ubifs-utils/mkfs.ubifs/mkfs.ubifs.c:30:24: fatal error: attr/xattr.h: No such file or directory
   #include <attr/xattr.h>
                          ^

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Cc: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Reviewed-by: Richard Weinberger <richard@nod.at>
8 years agomkfs.ubifs: use gid from table instead 2x uid
Sebastian Andrzej Siewior [Fri, 22 Aug 2014 16:49:01 +0000 (18:49 +0200)]
mkfs.ubifs: use gid from table instead 2x uid

If the devtable is used then the tool uses uid twice and doesn't
consider gid at all. This changes it to use gid & uid.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agolibmtd: mtd_read: Take the buffer offset into account when reading
Marcus Prebble [Tue, 6 Oct 2015 12:13:23 +0000 (14:13 +0200)]
libmtd: mtd_read: Take the buffer offset into account when reading

Assuming the read() call does not return zero and the result is less
than len, the current implementation will overwrite the data already
read in buf which doesn't seem correct.

With this patch, subsequent calls to read() within the loop will now no
longer overwrite the existing contents of buf.

Signed-off-by: Marcus Prebble <marcus.prebble@axis.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agoflashcp: Use %llu to print filestat.st_size
Fabien Proriol [Fri, 7 Nov 2014 13:46:28 +0000 (13:46 +0000)]
flashcp: Use %llu to print filestat.st_size

filestat.st_size type is off_t.
For some paltforms, off_t can be 32 or 64bit but there is no C99 format specifier for off_t.
The best way to print it with printf is to cast it to long long and print with %llu

Signed-off-by: Fabien Proriol <fabien.proriol@jdsu.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agomkfs.ubifs: fix compiler warning for WITHOUT_LZO
Daniel Walter [Thu, 12 Nov 2015 11:52:09 +0000 (12:52 +0100)]
mkfs.ubifs: fix compiler warning for WITHOUT_LZO

Fix compiler warning about an unused variable.

ubifs-utils/mkfs.ubifs/compr.c:41:27: warning: ‘c’ defined but not used [-Wunused-variable]
 static struct ubifs_info *c = &info_;

Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agoFix scanf() formatstring for modern C version
Daniel Walter [Tue, 3 Nov 2015 13:50:02 +0000 (14:50 +0100)]
Fix scanf() formatstring for modern C version

mkfs.jffs2 is using an old assignment-allocation
modifier for scanf(). Add a check so this modifier
does not get confused with a float formatstring
on newer C standard (C99 onwards).

Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
8 years agofix build when WITHOUT_LZO is set
Rolf Eike Beer [Tue, 10 Mar 2015 14:20:52 +0000 (15:20 +0100)]
fix build when WITHOUT_LZO is set

Make mkfs.ubifs honor the WITHOUT_LZO flag, too.

Fixes this build error:
  mkfs.ubifs/compr.c:27:23: lzo/lzo1x.h: No such file or directory
  mkfs.ubifs/compr.c: In function `lzo_compress':
  mkfs.ubifs/compr.c:92: error: `lzo_uint' undeclared (first use in this function)
  mkfs.ubifs/compr.c:92: error: (Each undeclared identifier is reported only once
  mkfs.ubifs/compr.c:92: error: for each function it appears in.)
  mkfs.ubifs/compr.c:92: error: syntax error before "len"
  mkfs.ubifs/compr.c:95: error: `len' undeclared (first use in this function)
  mkfs.ubifs/compr.c:96: warning: implicit declaration of function `lzo1x_999_compress'
  mkfs.ubifs/compr.c:99: error: `LZO_E_OK' undeclared (first use in this function)
  mkfs.ubifs/compr.c: In function `init_compression':
  mkfs.ubifs/compr.c:201: error: `LZO1X_999_MEM_COMPRESS' undeclared (first use in this function)

Signed-off-by: Rolf Eike Beer <eb@emlix.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
8 years agomkfs.ubifs: Optionally create extended attribute with inode number
Sascha Hauer [Thu, 12 Nov 2015 09:31:28 +0000 (10:31 +0100)]
mkfs.ubifs: Optionally create extended attribute with inode number

This is done to allow creating images suitable for IMA directory
appraisal. IMA creates a hash for directories and attaches this
hash to the directory itself as an extended attribute. Among other
things the inode numbers of the files are hashed. So, to create
a valid hash in the UBIFS image the evmctl tool needs to know
the inode numbers which the files in the UBIFS image will have.
evmctl will read the inode numbers from the user.image-inode-number
extended attribute. Since extended attributes are inodes themselves
the inode numbers for the generated image will change when the
extended attributes change, so to generate a correctly hashed
UBIFS image, both evmctl and mkfs.ubifs must be run twice:

1) execute evmctl to iterate over the directory tree. This will
   create the security.ima and security.evm extended attributes.
   The existence of the attributes makes sure that subsequent
   calls to mkfs.ubifs will use the same inode numbers. evmctl
   will use the inode numbers from the host filesystem in this
   step which makes the resulting image unusable
2) execute mkfs.ubifs -a. This will create the user.image-inode-number
   extended attributes on files/directories added to the image.
3) execture evmctl again. This time evmctl will pick the inode
   numbers from the user.image-inode-number extended attribute
   instead of the ones from the host filesystem
4) execute mkfs.ubifs again. This will create the correct image.
   The now existing user.image-inode-number extended attributes
   are ignored and not added to the image.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Richard Weinberger <richard@nod.at>
8 years agomkfs.ubifs: Add extended attribute support
Sascha Hauer [Thu, 12 Nov 2015 09:31:27 +0000 (10:31 +0100)]
mkfs.ubifs: Add extended attribute support

This adds extended attribute support to mkfs.ubifs. When creating
an image from a directory tree the existing extended attributes are
added to the UBIFS image.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Richard Weinberger <richard@nod.at>
8 years agomkfs.ubifs: simplify make_path with xasprintf
Sascha Hauer [Thu, 12 Nov 2015 09:31:26 +0000 (10:31 +0100)]
mkfs.ubifs: simplify make_path with xasprintf

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reviewed-by: Daniel Walter <dwalter@sigma-star.at>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Richard Weinberger <richard@nod.at>
8 years agomkfs.ubifs: use xmalloc/xzalloc for allocating memory
Sascha Hauer [Thu, 12 Nov 2015 09:31:25 +0000 (10:31 +0100)]
mkfs.ubifs: use xmalloc/xzalloc for allocating memory

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reviewed-by: Daniel Walter <dwalter@sigma-star.at>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Richard Weinberger <richard@nod.at>
8 years agomkfs.ubifs: change add_directory argument to 'existing'
Sascha Hauer [Thu, 12 Nov 2015 09:31:24 +0000 (10:31 +0100)]
mkfs.ubifs: change add_directory argument to 'existing'

A 'non_existing' argument which is only used with !non_existing
is just too confusing. Change this to positive logic.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reviewed-by: Daniel Walter <dwalter@sigma-star.at>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Richard Weinberger <richard@nod.at>
8 years agomtd-utils: Restructure the mtd-utils source.
Dongsheng Yang [Sat, 31 Oct 2015 03:12:01 +0000 (11:12 +0800)]
mtd-utils: Restructure the mtd-utils source.

* There is no code modification in this commit, only moving
* the files to proper place.

The user tools looks a little messy as we place almost
the all tools in the root directory of mtd-utils. To make
it more clear, I propose to introduce the following structure
for our source code.

mtd-utils/
|-- lib
|-- include
|-- misc-utils
|-- jffsX-utils
|-- nand-utils
|-- nor-utils
|-- ubi-utils
|-- ubifs-utils
`-- tests

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agoflash_{un,}lock: document block count == -1
Brian Norris [Mon, 31 Aug 2015 21:39:47 +0000 (14:39 -0700)]
flash_{un,}lock: document block count == -1

These utilities have accepted -1 as a block count to mean "all blocks."
Let's document that.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agoflash_{un,}lock: don't allow "last byte + 1"
Brian Norris [Mon, 31 Aug 2015 21:34:55 +0000 (14:34 -0700)]
flash_{un,}lock: don't allow "last byte + 1"

A lock/unlock/islocked ioctl() should be prevented from anything past
the last byte, inclusive. But we were doing an exclusive check.

This isn't a big deal, as the kernel MTD APIs would be guarding this
anyway, but let's do this for completeness.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agoflash_{un,}lock: improve strtol() error handling
Brian Norris [Mon, 31 Aug 2015 21:34:02 +0000 (14:34 -0700)]
flash_{un,}lock: improve strtol() error handling

Use the simple_* helpers to improve error checking.

Also fixup brace style at the same time.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agoflash_{un,}lock: add MEMISLOCKED support
Brian Norris [Thu, 27 Aug 2015 22:17:58 +0000 (15:17 -0700)]
flash_{un,}lock: add MEMISLOCKED support

With the -i / --islocked flags.

Sample output:

  # flash_lock --islocked /dev/mtd0
  Device: /dev/mtd0
  Start: 0
  Len: 0x400000
  Lock status: unlocked
  Return code: 0

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agoflash_{un,}lock: support both lock/unlock in the same binary
Brian Norris [Thu, 27 Aug 2015 22:03:21 +0000 (15:03 -0700)]
flash_{un,}lock: support both lock/unlock in the same binary

Add new --lock/--unlock flags, so we can do either with the same binary.
This will prepare for the addition of other features, so we don't have
to keep duplicating the same binary via #include "flash_unlock.c".

The defaults still work as expected: flash_unlock will default to
REQUEST_UNLOCK, and flash_lock will default to REQUEST_LOCK.

Eventually, we might deprecate one of the two (flash_unlock, probably),
so we only have to ship one flash_{un,}lock binary.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agoflash_{un,}lock: move args processing to its own function
Brian Norris [Thu, 27 Aug 2015 21:57:58 +0000 (14:57 -0700)]
flash_{un,}lock: move args processing to its own function

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agoflash_{un,}lock: abstract the argument positions
Brian Norris [Thu, 27 Aug 2015 21:45:48 +0000 (14:45 -0700)]
flash_{un,}lock: abstract the argument positions

Previously, there were no options (besides stand-alone --help and
--version), so we just used fixed-position argv indexes. Let's change
that.

Also clean up the sanity checks a bit to make them more verbose and
specific.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agoflash_{un,}lock: document option flags
Brian Norris [Thu, 27 Aug 2015 21:04:18 +0000 (14:04 -0700)]
flash_{un,}lock: document option flags

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agoflash_{un,}lock: support --version flag
Brian Norris [Thu, 27 Aug 2015 20:32:25 +0000 (13:32 -0700)]
flash_{un,}lock: support --version flag

Just use the common helper macro.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agoflash_{un,}lock: switch to getopt library
Brian Norris [Thu, 27 Aug 2015 18:00:31 +0000 (11:00 -0700)]
flash_{un,}lock: switch to getopt library

We will be adding some more flags, so the getopt library can help.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agoflash_{un,}lock: nest optional parameters in help message
Brian Norris [Thu, 27 Aug 2015 17:58:53 +0000 (10:58 -0700)]
flash_{un,}lock: nest optional parameters in help message

block count should be nested within the optional offset listing. That
is, we require offset before we accept a block count.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
8 years agonandtest: support hex/dec/oct for --offset and --length
Brian Norris [Fri, 30 Oct 2015 00:12:01 +0000 (17:12 -0700)]
nandtest: support hex/dec/oct for --offset and --length

These two options are handled inconsistently, which caused an
unnecessary amount of head scratching. Let's just use the simple helpers
too, so we get the error handling right.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
9 years agomtd-utils: serve_image: use proper POSIX_C_SOURCE value
Kirill Smirnov [Thu, 1 Oct 2015 01:19:35 +0000 (04:19 +0300)]
mtd-utils: serve_image: use proper POSIX_C_SOURCE value

struct addrinfo and friends conform to POSIX.1-2001, not earlier.
This patch fixes linking against latest glibc 2.22

Signed-off-by: Kirill Smirnov <kirill.k.smirnov@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
9 years agomtd: tests: Fix endian issue with CRC generation algorithm
Paul McGougan [Thu, 17 Apr 2014 05:09:26 +0000 (05:09 +0000)]
mtd: tests: Fix endian issue with CRC generation algorithm

The calculation of the CRC in /tests/checkfs/makefiles.c was writing the CRC
Into the produced files in host byte-order which would cause CRC validation
to fail on big-endian systems as the validation is performed bytewise.

Signed-off-by: Paul McGougan <pmcgougan AT topcon.com>
[Brian: add endian.h]
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
9 years agomtd-utils: ubinize: Always return error code (at least -1) in case of an error
Enrico Jorns [Fri, 11 Sep 2015 13:28:13 +0000 (15:28 +0200)]
mtd-utils: ubinize: Always return error code (at least -1) in case of an error

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>
9 years agodon't include system headers in dependency files
Brian Norris [Fri, 28 Aug 2015 16:05:43 +0000 (09:05 -0700)]
don't include system headers in dependency files

System library headers are not strictly part of our build. If they are
changing beneath our feet, then we probably have bigger problems.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Suggested-by: Mike Frysinger <vapier@gentoo.org>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
9 years agoautogenerated dependency files are not being utilized properly
Brian Norris [Thu, 27 Aug 2015 22:48:22 +0000 (15:48 -0700)]
autogenerated dependency files are not being utilized properly

TL;DR
Acked-by: Mike Frysinger <vapier@gentoo.org>
=====

Auto-generated dependency rules are not being written correctly, so
changes to dependent files (e.g., headers) do not actually trigger
rebuilds.

The problem
===========

It appears that when a dependency generation flag is passed directly to
the preprocessor (with '-Wp,...'), it loses information about the output
path. So, it just makes up the output name as $(basename).o, with no
path information. This yields .*.c.dep files that look like this:

  flash_lock.o: flash_lock.c /usr/include/stdc-predef.h flash_unlock.c \
   (...)

and

  nanddump.o: nanddump.c /usr/include/stdc-predef.h /usr/include/ctype.h \
   (...)
   include/libmtd.h

This is the case for both in-tree *and* out-of-tree builds. Naturally,
this is a problem for out-of-tree builds. But it is also a problem for
in-tree builds, because we use rules like this for builds:

  $(BUILDDIR)/%.o: %.c

and make doesn't recognize $(BUILDDIR)/%.o as the same as %.o even when
$(BUILDDIR) == $(PWD).

Example failures
================

  ## Rebuilding after touching common header doesn't recompile anything
  $ make
  (...)
  $ touch include/libmtd.h
  $ make
    CHK     include/version.h

  ## Same for out-of-tree builds
  $ BUILDDIR=test make
  (...)
  $ touch include/libmtd.h
  $ BUILDDIR=test make
    CHK     include/version.h

I noticed this when seeing that flash_lock would not get rebuilt when
modifying flash_unlock.c (where 99% of the source code lies):

  $ make
  (...)
  $ touch flash_unlock.c
  $ make
    CHK     include/version.h
    CC      flash_unlock.o
    LD      flash_unlock

The fix
=======

Just pass -MD straight to the compiler, and make sure to specify the
output file for the dependency info with -MF.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
9 years agoubifs: correct the size of nnode in memset
Dongsheng Yang [Wed, 19 Aug 2015 08:28:52 +0000 (16:28 +0800)]
ubifs: correct the size of nnode in memset

There is a typo in lpt to memset nnode by the
size in sizeof(stuct ubifs_pnode).

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
9 years agomake_a_release.sh: fix MTD spelling
Brian Norris [Mon, 3 Aug 2015 18:08:08 +0000 (11:08 -0700)]
make_a_release.sh: fix MTD spelling

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
9 years agoRelease mtd-utils-1.5.2 v1.5.2
Brian Norris [Sat, 25 Jul 2015 01:18:53 +0000 (18:18 -0700)]
Release mtd-utils-1.5.2

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
9 years ago.gitignore: add new mtdpart utility
Brian Norris [Sat, 25 Jul 2015 01:18:14 +0000 (18:18 -0700)]
.gitignore: add new mtdpart utility

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
9 years agomtd-utils: fix 'new blank line at EOF' problems
Dongsheng Yang [Wed, 1 Jul 2015 03:44:16 +0000 (11:44 +0800)]
mtd-utils: fix 'new blank line at EOF' problems

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
9 years agomtd-utils: fix 'space before tab in indent' problem
Dongsheng Yang [Wed, 1 Jul 2015 03:44:15 +0000 (11:44 +0800)]
mtd-utils: fix 'space before tab in indent' problem

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
9 years agomtd-utils: fix the trailing whitespace problems
Dongsheng Yang [Wed, 1 Jul 2015 03:44:14 +0000 (11:44 +0800)]
mtd-utils: fix the trailing whitespace problems

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
9 years agomtd-utils: ubi-tests: fix a some overflows
Dongsheng Yang [Mon, 29 Jun 2015 08:49:19 +0000 (16:49 +0800)]
mtd-utils: ubi-tests: fix a some overflows

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Reviewed-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
9 years agomtd-utils: fs-tests: pass TEST_DIR to integck in run_all.sh
Dongsheng Yang [Mon, 29 Jun 2015 08:49:18 +0000 (16:49 +0800)]
mtd-utils: fs-tests: pass TEST_DIR to integck in run_all.sh

Test integck requires a parameter but run_all.sh did no pass any to it.
Then:
integck: error!: test file-system was not specified (use -h for help)

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Reviewed-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
9 years agomtd-utils: Add mtdpart to add/delete partition
Nam T. Nguyen [Tue, 28 Apr 2015 15:12:12 +0000 (08:12 -0700)]
mtd-utils: Add mtdpart to add/delete partition

Add a simple utility to exercise BLKPG ioctl.

Signed-off-by: Nam T. Nguyen <namnguyen@chromium.org>
Acked-by: Mike Frysinger <vapier@chromium.org>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
9 years agoinclude/common.h: fix build against musl
Jörg Krause [Thu, 23 Apr 2015 22:12:51 +0000 (00:12 +0200)]
include/common.h: fix build against musl

Like uClibc version older than (not yet released) 0.9.34 musl does not have
a rpmatch() implementation.

uClibc defines both __UCLIBC__ and __GLIBC__. So first check for uCibc and its
version and then for a non glibc implementation (like musl). Note, musl does
not define __MUSL__.

Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
9 years agorecv_image: do not include error.h
Jörg Krause [Fri, 24 Apr 2015 20:51:47 +0000 (22:51 +0200)]
recv_image: do not include error.h

recv_image does not use anything from it and it is not available with all
C libraries, e.g. musl.

Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
9 years agoserve_image: do not include error.h
Jörg Krause [Fri, 24 Apr 2015 20:51:46 +0000 (22:51 +0200)]
serve_image: do not include error.h

serve_image does not use anything from it and it is not available with all
C libraries, e.g. musl.

Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
9 years agolibmtd: fix comment typo
Baruch Siach [Wed, 29 Apr 2015 08:28:43 +0000 (11:28 +0300)]
libmtd: fix comment typo

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>