]> www.infradead.org Git - mtd-utils.git/log
mtd-utils.git
6 years agoRelease mtd-utils-2.1.0 v2.1.0
David Oberhollenzer [Wed, 13 Mar 2019 16:42:12 +0000 (17:42 +0100)]
Release mtd-utils-2.1.0

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomtd-utils: fixes verification percent display in flashcp
Andrij Abyzov [Mon, 11 Feb 2019 16:13:40 +0000 (17:13 +0100)]
mtd-utils: fixes verification percent display in flashcp

flashcp was always showing 0% progress due to incorrect
printf format specifier.

Signed-off-by: Andrij Abyzov <drolevar@gmail.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomtd-utils: fixes double free in mkfs.ubifs
Yufen Yu [Thu, 24 Jan 2019 09:06:29 +0000 (17:06 +0800)]
mtd-utils: fixes double free in mkfs.ubifs

In inode_add_xattr(), it malloc a buffer for name, and then passes
the bufffer ptr to add_xattr(). The ptr will be used to create a new
idx_entry in add_to_index().

However, inode_add_xattr() will free the buffer before return.
which can cause double free in write_index(): free(idx_ptr[i]->name)

*** Error in `./mkfs.ubifs': double free or corruption (fasttop): 0x0000000000aae220 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x7cbac)[0x7f4881ff5bac]
/lib64/libc.so.6(+0x87a59)[0x7f4882000a59]
/lib64/libc.so.6(cfree+0x16e)[0x7f48820063be]
./mkfs.ubifs[0x402fbf]
/lib64/libc.so.6(__libc_start_main+0xea)[0x7f4881f9988a]
./mkfs.ubifs[0x40356a]

Signed-off-by: Yufen Yu <yuyufen@huawei.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomtd-utils: avoid to create two UBI_LAYOUT_VOLUME_ID volume
Yufen Yu [Fri, 25 Jan 2019 07:01:24 +0000 (15:01 +0800)]
mtd-utils: avoid to create two UBI_LAYOUT_VOLUME_ID volume

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>
6 years agomkfs.ubifs: fix default cipher in help output
David Gstir [Mon, 3 Dec 2018 13:40:46 +0000 (14:40 +0100)]
mkfs.ubifs: fix default cipher in help output

AES-256-XTS is the default since dd0d9c623e22 ("mkfs.ubifs: Use AES-256-XTS as default"),
we want that to be correctly reflected in the help output as well.

Signed-off-by: David Gstir <david@sigma-star.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Don't compress by default if filesystem is encrypted
Richard Weinberger [Wed, 7 Nov 2018 20:56:35 +0000 (21:56 +0100)]
mkfs.ubifs: Don't compress by default if filesystem is encrypted

Encryption and compression are not friends.
Enable compression in encryption mode only if the user explicitly
sets a compressor.

Signed-off-by: Richard Weinberger <richard@nod.at>
Tested-by: Heiko Schocher <hsdenx.de>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Store compr_size in correct endianness.
Richard Weinberger [Wed, 7 Nov 2018 20:21:08 +0000 (21:21 +0100)]
mkfs.ubifs: Store compr_size in correct endianness.

compr_size has to be in LE16.

Signed-off-by: Richard Weinberger <richard@nod.at>
Tested-by: Heiko Schocher <hsdenx.de>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Fix IV selection
Richard Weinberger [Wed, 7 Nov 2018 20:21:07 +0000 (21:21 +0100)]
mkfs.ubifs: Fix IV selection

We need to check for AES being in 128-cbc mode and not 256-cbc.
fscrypt supports only 128-cbc and 256-xts so far.

Signed-off-by: Richard Weinberger <richard@nod.at>
Tested-by: Heiko Schocher <hsdenx.de>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Use AES-256-XTS as default
Richard Weinberger [Thu, 18 Oct 2018 14:37:18 +0000 (16:37 +0200)]
mkfs.ubifs: Use AES-256-XTS as default

AES-128-CBC should only being used when 256-XTS is too slow
on low end hardware.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Print key descriptor only when generated
Richard Weinberger [Thu, 18 Oct 2018 14:37:17 +0000 (16:37 +0200)]
mkfs.ubifs: Print key descriptor only when generated

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Enable support for building without crypto
Richard Weinberger [Thu, 18 Oct 2018 14:37:16 +0000 (16:37 +0200)]
mkfs.ubifs: Enable support for building without crypto

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Move RAND_poll to crypto.c
Richard Weinberger [Thu, 18 Oct 2018 14:37:15 +0000 (16:37 +0200)]
mkfs.ubifs: Move RAND_poll to crypto.c

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: More fscryptctl compatibility
Richard Weinberger [Thu, 18 Oct 2018 14:37:14 +0000 (16:37 +0200)]
mkfs.ubifs: More fscryptctl compatibility

fscryptctl reads up to FS_MAX_KEY_SIZE bytes from the source key
to compute the descriptor.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Fix key descriptor printing
Richard Weinberger [Thu, 18 Oct 2018 14:37:13 +0000 (16:37 +0200)]
mkfs.ubifs: Fix key descriptor printing

normsg() sucks.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Compute encryption key descriptor automatically
Richard Weinberger [Thu, 18 Oct 2018 14:37:12 +0000 (16:37 +0200)]
mkfs.ubifs: Compute encryption key descriptor automatically

...if none is given. To be compatible with fscryptctl.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Fixup AES-XTS mode
Richard Weinberger [Thu, 18 Oct 2018 14:37:11 +0000 (16:37 +0200)]
mkfs.ubifs: Fixup AES-XTS mode

In XTS mode we don't need ESSIV, just use the block number
as tweak.
Also apply EVP_EncryptFinal().

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Use correct sizes for keys and hash lengths
Richard Weinberger [Thu, 18 Oct 2018 14:37:10 +0000 (16:37 +0200)]
mkfs.ubifs: Use correct sizes for keys and hash lengths

This works currently by chance since the sizes match, but
that might change with different cipher setups.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Enable Cipher selection
Richard Weinberger [Thu, 18 Oct 2018 14:37:09 +0000 (16:37 +0200)]
mkfs.ubifs: Enable Cipher selection

No longer hard code AES-128-CBC, we support AES-256-XTS too.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Correctly use iv lengths in aes-cts mode
Richard Weinberger [Thu, 18 Oct 2018 14:37:08 +0000 (16:37 +0200)]
mkfs.ubifs: Correctly use iv lengths in aes-cts mode

The key length can be very long, for example in xts mode.
So we have to use the right sizes for block and iv lengths.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Accept 0x prefix for key descriptor
David Oberhollenzer [Thu, 18 Oct 2018 14:37:07 +0000 (16:37 +0200)]
mkfs.ubifs: Accept 0x prefix for key descriptor

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
6 years agomkfs.ubifs: Check length of master key
David Oberhollenzer [Thu, 18 Oct 2018 14:37:06 +0000 (16:37 +0200)]
mkfs.ubifs: Check length of master key

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
6 years agomkfs.ubifs: Cleanup over-long lines
David Oberhollenzer [Thu, 18 Oct 2018 14:37:05 +0000 (16:37 +0200)]
mkfs.ubifs: Cleanup over-long lines

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
6 years agomkfs.ubifs: Move fscrypt definitions and functions out of mkfs.ubifs.c
David Oberhollenzer [Thu, 18 Oct 2018 14:37:04 +0000 (16:37 +0200)]
mkfs.ubifs: Move fscrypt definitions and functions out of mkfs.ubifs.c

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
6 years agomkfs.ubifs: Remove cipher implementations from public header
David Oberhollenzer [Thu, 18 Oct 2018 14:37:03 +0000 (16:37 +0200)]
mkfs.ubifs: Remove cipher implementations from public header

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
6 years agomkfs.ubifs: Initial support for encryption command lines
David Oberhollenzer [Thu, 18 Oct 2018 14:37:02 +0000 (16:37 +0200)]
mkfs.ubifs: Initial support for encryption command lines

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
6 years agomkfs.ubifs: Specify padding policy via command line
David Oberhollenzer [Thu, 18 Oct 2018 14:37:01 +0000 (16:37 +0200)]
mkfs.ubifs: Specify padding policy via command line

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
6 years agomkfs.ubifs: Get key descriptor from command line and master key from file
David Oberhollenzer [Thu, 18 Oct 2018 14:37:00 +0000 (16:37 +0200)]
mkfs.ubifs: Get key descriptor from command line and master key from file

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
6 years agomkfs.ubifs: Make encryption dependend on (not-yet-existant) command line options
David Oberhollenzer [Thu, 18 Oct 2018 14:36:59 +0000 (16:36 +0200)]
mkfs.ubifs: Make encryption dependend on (not-yet-existant) command line options

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
6 years agomkfs.ubifs: Replace constant values with parameters in init_fscrypt_context
David Oberhollenzer [Thu, 18 Oct 2018 14:36:58 +0000 (16:36 +0200)]
mkfs.ubifs: Replace constant values with parameters in init_fscrypt_context

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
6 years agomkfs.ubifs: Cleanup add_dent_node, user path encryption helper
David Oberhollenzer [Thu, 18 Oct 2018 14:36:57 +0000 (16:36 +0200)]
mkfs.ubifs: Cleanup add_dent_node, user path encryption helper

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
6 years agomkfs.ubifs: Seperate path encryption from symlink encryption helper
David Oberhollenzer [Thu, 18 Oct 2018 14:36:56 +0000 (16:36 +0200)]
mkfs.ubifs: Seperate path encryption from symlink encryption helper

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
6 years agomkfs.ubifs: Free all index entry names
Richard Weinberger [Thu, 18 Oct 2018 14:36:55 +0000 (16:36 +0200)]
mkfs.ubifs: Free all index entry names

...and make valgrind memcheck happy

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Make sure we catch nodes that should or should not have name
Richard Weinberger [Thu, 18 Oct 2018 14:36:54 +0000 (16:36 +0200)]
mkfs.ubifs: Make sure we catch nodes that should or should not have name

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Move symlink data encryption to helper function
David Oberhollenzer [Thu, 18 Oct 2018 14:36:53 +0000 (16:36 +0200)]
mkfs.ubifs: Move symlink data encryption to helper function

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
6 years agomkfs.ubifs: Implement file contents encryption
Richard Weinberger [Thu, 18 Oct 2018 14:36:52 +0000 (16:36 +0200)]
mkfs.ubifs: Implement file contents encryption

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Add encrypted symlink support
Richard Weinberger [Thu, 18 Oct 2018 14:36:51 +0000 (16:36 +0200)]
mkfs.ubifs: Add encrypted symlink support

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Pass source/dest key len to key derive function
Richard Weinberger [Thu, 18 Oct 2018 14:36:50 +0000 (16:36 +0200)]
mkfs.ubifs: Pass source/dest key len to key derive function

fscrypto is using the max key lenth (64), so we cannot use the
AES-128-ECB len.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Add dummy setup for crypto
Richard Weinberger [Thu, 18 Oct 2018 14:36:49 +0000 (16:36 +0200)]
mkfs.ubifs: Add dummy setup for crypto

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Implement filename encryption
Richard Weinberger [Thu, 18 Oct 2018 14:36:48 +0000 (16:36 +0200)]
mkfs.ubifs: Implement filename encryption

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Store directory name len in the temporary index
Richard Weinberger [Thu, 18 Oct 2018 14:36:47 +0000 (16:36 +0200)]
mkfs.ubifs: Store directory name len in the temporary index

since names are no longer strings, we need to know the length.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Implement fscrypto context store as xattr
Richard Weinberger [Thu, 18 Oct 2018 14:36:46 +0000 (16:36 +0200)]
mkfs.ubifs: Implement fscrypto context store as xattr

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Implement basic fscrypto context passing
Richard Weinberger [Thu, 18 Oct 2018 14:36:45 +0000 (16:36 +0200)]
mkfs.ubifs: Implement basic fscrypto context passing

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Implement UBIFS_FLG_ENCRYPTION
Richard Weinberger [Thu, 18 Oct 2018 14:36:44 +0000 (16:36 +0200)]
mkfs.ubifs: Implement UBIFS_FLG_ENCRYPTION

...and set UBIFS format version

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Add basic fscrypto functions
Richard Weinberger [Thu, 18 Oct 2018 14:36:43 +0000 (16:36 +0200)]
mkfs.ubifs: Add basic fscrypto functions

...maybe we should add them to crypto.c?

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Add fscrypto defines
Richard Weinberger [Thu, 18 Oct 2018 14:36:42 +0000 (16:36 +0200)]
mkfs.ubifs: Add fscrypto defines

most of them should be UAPI, therefore check using #ifndef

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Make r5 hash binary string aware
Richard Weinberger [Thu, 18 Oct 2018 14:36:41 +0000 (16:36 +0200)]
mkfs.ubifs: Make r5 hash binary string aware

As of now all filenames known by UBIFS are strings with a NUL
terminator. With encrypted filenames a filename can be any binary
string and the r5 function cannot search for the NUL terminator.
UBIFS always knows how long a filename is, therefore we can change
the hash function to iterate over the filename length to work
correctly with binary strings.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Implement UBIFS_FLG_DOUBLE_HASH
David Oberhollenzer [Thu, 18 Oct 2018 14:36:40 +0000 (16:36 +0200)]
mkfs.ubifs: Implement UBIFS_FLG_DOUBLE_HASH

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Add crypto helper functions
David Oberhollenzer [Thu, 18 Oct 2018 14:36:39 +0000 (16:36 +0200)]
mkfs.ubifs: Add crypto helper functions

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Signed-off-by: Richard Weinberger <richard@nod.at>
6 years agocommon: Add round functions
Richard Weinberger [Thu, 18 Oct 2018 14:36:38 +0000 (16:36 +0200)]
common: Add round functions

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agoImport latest ubifs-media.h
Richard Weinberger [Thu, 18 Oct 2018 14:36:37 +0000 (16:36 +0200)]
Import latest ubifs-media.h

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Fix xattr nlink value
Sascha Hauer [Thu, 27 Sep 2018 09:36:43 +0000 (11:36 +0200)]
mkfs.ubifs: Fix xattr nlink value

The nlink value of a xattr node must always be one, it has nothing to do
with the nlink value of the inode the attribute belongs to.

The bug can be observed when mounting a mkfs.ubifs generated image which
contains xattrs on directories or files with hardlinks to them. When
mounting such an image with chk_fs = 1 it fails with:

UBIFS error (ubi0:0 pid 1833): dbg_check_filesystem: inode 3308 nlink is 3, but calculated nlink is 1

Another bug that can be triggered is an assertion in
ubifs_xattr_remove() which assures that the xattr i_nlink count should
be one when the xattr is removed.

Fixes: 50044ef ("mkfs.ubifs: Add extended attribute support")
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomtd-utils: Instead of doing preprocessor magic, just output off_t as long long
Thorsten Glaser [Thu, 20 Sep 2018 23:22:11 +0000 (01:22 +0200)]
mtd-utils: Instead of doing preprocessor magic, just output off_t as long long

Fix warnings abot PRIdoff_t in libmtd.c, in mtd_read (and mtd_write):

In file included from ../git/lib/libmtd.c:40:0:
../git/lib/libmtd.c: In function 'mtd_read':
../git/include/common.h:110:18: warning: format '%ld' expects argument of
 type 'long int', but argument 5 has type 'off_t {aka long long int}'
 [-Wformat=]

../git/include/common.h:120:2: note: in expansion of macro 'errmsg'
  errmsg(fmt, ##__VA_ARGS__);                                         \
  ^~~~~~
../git/lib/libmtd.c:1082:10: note: in expansion of macro 'sys_errmsg'
   return sys_errmsg("cannot seek mtd%d to offset %"PRIdoff_t,
          ^~~~~~~~~~

/usr/lib/klibc/include/inttypes.h:28:17: note: format string is defined here
 #define PRId32 "d"

Signed-off-by: Thorsten Glaser <tg@mirbsd.org>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomtd-utils: common.h: fix prompt function
David Oberhollenzer [Wed, 19 Sep 2018 08:57:34 +0000 (10:57 +0200)]
mtd-utils: common.h: fix prompt function

The prompt() function is intended to query a yes/no reply from a command
line user by reading in an entire line of text using getline() and checking
the first character. If the line is empty, a default value is returned.

First of all, this patch replaces the usage of getline() with fgets() to
avoid compilation problems on some smaller C libraries, like klibc, that
do not have a getline() implementation. Since we now have a static line
length, this may break some build setups that input lengthy giberish
instead of 'y' or 'n'.

Second, this patch fixes a more severe bug in prompt(), replacing a 'while'
keyword with the 'if' that was most likely intended. In the old version, if
getline() reported an error, it would print an error message inside a while
loop, immediately followed by a break and then march on and process the
erroneous input instead of using the default value as printed to stdout.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agolibmtd: don't print an error message for devices without ecc support
David Oberhollenzer [Wed, 12 Sep 2018 07:40:34 +0000 (09:40 +0200)]
libmtd: don't print an error message for devices without ecc support

The libmtd library tries to obtain the available OOB size via the sysfs
with a fallback to the ECCGETLAYOUT ioctl. For some devices (e.g. plat-ram),
the fallback path is always taken and prints an error message to stderr
since the ioctl fails.

This patch fixes the fallback path by suppressing the error message if
errno is set to EOPNOTSUPP (i.e. the device simply doesn't support that).

Fixes: a10353584f93 ("libmtd: Add support to access OOB available size")
Reported-by: Chris Packham <Chris.Packham@alliedtelesis.co.nz>
Reviewed-by: Xiaolei Li <xiaolei.li@mediatek.com>
Tested-by: Chris Packham <Chris.Packham@alliedtelesis.co.nz>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agoubi-tests: io_paral: Fix error handling of update_volume()
Martin Lund [Wed, 5 Sep 2018 13:47:38 +0000 (15:47 +0200)]
ubi-tests: io_paral: Fix error handling of update_volume()

The io_paral test returns success even in case it throws e.g. the
following error message:

[io_paral] update_volume():125: written and read data are different

This patch fixes so that the io_paral application returns a non-zero
error code when an error is detected.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agoubi-utils: ubimkvol: Initialize req to zero to make sure no flags are set by default
Boris Brezillon [Thu, 26 Jul 2018 14:05:29 +0000 (16:05 +0200)]
ubi-utils: ubimkvol: Initialize req to zero to make sure no flags are set by 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>
6 years agoubi-utils: ubinize: add support for skipping CRC check of a static volume when opening
Quentin Schulz [Thu, 28 Jun 2018 07:43:44 +0000 (09:43 +0200)]
ubi-utils: ubinize: add support for skipping CRC check of a static volume 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>
6 years agoubi-utils: ubimkvol: add support for skipping CRC check of a static volume when opening
Quentin Schulz [Thu, 28 Jun 2018 07:43:43 +0000 (09:43 +0200)]
ubi-utils: ubimkvol: add support for skipping CRC check of a static volume 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>
6 years agolibubi: add volume flags to ubi_mkvol_request
Quentin Schulz [Thu, 28 Jun 2018 07:43:42 +0000 (09:43 +0200)]
libubi: add volume flags to ubi_mkvol_request

Now that we have per-UBI volume flags (for instance for skipping CRC
check when opening it) from the Linux header, let's add it to the
ubi_mkvol_request in libubi and assign the flags to ubi_mkvol_req from
the Linux header from ubi_mkvol.

Suggested-by: Boris Brezillon <boris.brezillon@bootlin.com>
Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agoUBI: update ubi-user.h and ubi-media.h
Quentin Schulz [Thu, 28 Jun 2018 07:43:41 +0000 (09:43 +0200)]
UBI: update ubi-user.h and ubi-media.h

Update both header files to add support for flag specifying whether to
skip the CRC check for static UBI volumes.

Taken from the kernel headers.

Some users of static UBI volumes implement their own integrity check,
thus making the volume CRC check done at open time useless. For
instance, this is the case when one use the ubiblock + dm-verity +
squashfs combination, where dm-verity already checks integrity of the
block device but this time at the block granularity instead of verifying
the whole volume.

Skipping this test drastically improves the boot-time.

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>
6 years agoAdd configure switch to disable compiling/installing lsmtd
David Oberhollenzer [Mon, 18 Jun 2018 09:35:59 +0000 (11:35 +0200)]
Add configure switch to disable compiling/installing lsmtd

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agoAdd manpage for lsmtd
David Oberhollenzer [Wed, 19 Apr 2017 13:45:15 +0000 (15:45 +0200)]
Add manpage for lsmtd

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agoAdd lsmtd program
David Oberhollenzer [Wed, 15 Mar 2017 11:12:12 +0000 (12:12 +0100)]
Add lsmtd program

This patch adds a program called "lsmtd". The program produces a pretty
printed list of the hierarchy of UBI and MTD devices on a system. It
tries to imitate the lsblk program from util-linux as closely as
possible.

A number of command line switches are available to fine tune what information
should be exposed and in what output format.

The goal is to have a simple way of displaying the complete MTD stack on
a system in a human readable form instead of piecing details together
from proc files and various UBI utilities.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
6 years agomkfs.ubifs: Implement selinux labelling support in mkfs.ubifs.
Ritesh Harjani [Wed, 6 Jun 2018 09:39:00 +0000 (15:09 +0530)]
mkfs.ubifs: Implement selinux labelling support in mkfs.ubifs.

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>
6 years agomkfs.ubifs: add_xattr is not depending on host XATTR support
Ritesh Harjani [Wed, 6 Jun 2018 09:38:59 +0000 (15:08 +0530)]
mkfs.ubifs: add_xattr is not depending on host XATTR support

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>
6 years agoRevert "Return correct error number in ubi_get_vol_info1"
David Oberhollenzer [Sat, 9 Jun 2018 14:45:22 +0000 (16:45 +0200)]
Revert "Return correct error number in ubi_get_vol_info1"

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>
6 years agomtd-utils: make sure pkg-config is installed in configure script
David Oberhollenzer [Sat, 12 May 2018 21:28:13 +0000 (23:28 +0200)]
mtd-utils: make sure pkg-config is installed in configure script

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>
6 years agoubiformat: remove no-volume-table option
David Oberhollenzer [Sat, 12 May 2018 20:17:16 +0000 (22:17 +0200)]
ubiformat: remove no-volume-table option

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>
6 years agoubiformat: process command line arguments first
David Oberhollenzer [Sat, 12 May 2018 19:51:56 +0000 (21:51 +0200)]
ubiformat: process command line arguments first

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>
7 years agoRelease mtd-utils-2.0.2 v2.0.2
David Oberhollenzer [Mon, 16 Apr 2018 15:54:33 +0000 (17:54 +0200)]
Release mtd-utils-2.0.2

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
7 years agoFix unit-test header and file paths for out of tree builds
David Oberhollenzer [Mon, 16 Apr 2018 15:41:52 +0000 (17:41 +0200)]
Fix unit-test header and file paths for out of tree builds

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>
7 years agoFix unit test mockup for oobavail sysfs file
David Oberhollenzer [Mon, 16 Apr 2018 15:37:00 +0000 (17:37 +0200)]
Fix unit test mockup for oobavail sysfs file

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
7 years agomisc-utils: flash_erase: Fix Jffs2 type flash erase problem
Xiaolei Li [Tue, 10 Apr 2018 07:36:57 +0000 (15:36 +0800)]
misc-utils: flash_erase: Fix Jffs2 type flash erase problem

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>
7 years agolibmtd_legacy: Fix some function description mismatches
Xiaolei Li [Tue, 10 Apr 2018 07:36:56 +0000 (15:36 +0800)]
libmtd_legacy: Fix some function description mismatches

Signed-off-by: Xiaolei Li <xiaolei.li@mediatek.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
7 years agolibmtd: Add support to access OOB available size
Xiaolei Li [Tue, 10 Apr 2018 07:36:55 +0000 (15:36 +0800)]
libmtd: Add support to access OOB available size

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>
7 years agomtd-utils: ubifs: fix typo in without_lzo definition
Koen Vandeputte [Thu, 5 Apr 2018 07:51:43 +0000 (09:51 +0200)]
mtd-utils: ubifs: fix typo in without_lzo definition

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>
7 years agomkfs.ubifs: Allow root entry in device table
David Engraf [Tue, 6 Mar 2018 08:13:42 +0000 (09:13 +0100)]
mkfs.ubifs: Allow root entry in device table

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>
7 years agomtd: tests: check erase block count in page test
Stefan Agner [Sat, 3 Mar 2018 22:39:46 +0000 (23:39 +0100)]
mtd: tests: check erase block count in page test

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>
7 years agomtd: unittests: Stop testing stat() calls
Balint Reczey [Mon, 5 Feb 2018 22:31:32 +0000 (05:31 +0700)]
mtd: unittests: Stop testing stat() calls

Sometimes __xstat is called instead that makes tests fragile.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
7 years agomtd: unittests: Decode arg size from ioctl request
Balint Reczey [Tue, 6 Feb 2018 22:58:21 +0000 (05:58 +0700)]
mtd: unittests: Decode arg size from ioctl request

Signed-off-by: Balint Reczey <balint.reczey@canonical.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
7 years agomtd: unittests: Use proper unsigned long type for ioctl requests
Balint Reczey [Tue, 6 Feb 2018 20:49:14 +0000 (03:49 +0700)]
mtd: unittests: Use proper unsigned long type for ioctl requests

This fixes tests on s390x

Signed-off-by: Balint Reczey <balint.reczey@canonical.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
7 years agoubi-utils: ubiformat.c: convert to integer arithmetic
Andrea Adami [Mon, 29 Jan 2018 22:07:12 +0000 (23:07 +0100)]
ubi-utils: ubiformat.c: convert to integer arithmetic

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>
7 years agomtd-utils: common.c: convert to integer arithmetic
Andrea Adami [Mon, 29 Jan 2018 22:07:11 +0000 (23:07 +0100)]
mtd-utils: common.c: convert to integer arithmetic

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>
7 years agoRun unit test programs through "make check"
David Oberhollenzer [Tue, 5 Dec 2017 12:20:54 +0000 (13:20 +0100)]
Run unit test programs through "make check"

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
7 years agomtd: tests: Fix check on ebcnt in nandpagetest
Paul HENRYS [Wed, 22 Nov 2017 08:11:43 +0000 (09:11 +0100)]
mtd: tests: Fix check on ebcnt in nandpagetest

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>
7 years agolibscan: fix a comment typo in libscan.h
Rock Lee [Thu, 16 Nov 2017 09:00:23 +0000 (17:00 +0800)]
libscan: fix a comment typo in libscan.h

Signed-off-by: Rock Lee <rockdotlee@gmail.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
7 years agolibmtd: fix a comment typo in dev_node2num
Rock Lee [Mon, 13 Nov 2017 07:05:34 +0000 (15:05 +0800)]
libmtd: fix a comment typo in dev_node2num

Signed-off-by: Rock Lee <rockdotlee@gmail.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
7 years agoubi-utils: ubicrc32: process command line arguments first
David Oberhollenzer [Thu, 21 Sep 2017 12:18:04 +0000 (14:18 +0200)]
ubi-utils: ubicrc32: process command line arguments first

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>
7 years agonandbiterrs: Fix copy & paste fail
David Oberhollenzer [Thu, 2 Nov 2017 00:01:02 +0000 (01:01 +0100)]
nandbiterrs: Fix copy & paste fail

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>
7 years agoEnable further warning flags, address new warnings
David Oberhollenzer [Wed, 1 Nov 2017 22:08:45 +0000 (23:08 +0100)]
Enable further warning flags, address new warnings

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>
7 years agojittertest: Use the appropriate versions of abs()
David Oberhollenzer [Thu, 2 Nov 2017 00:10:11 +0000 (01:10 +0100)]
jittertest: Use the appropriate versions of abs()

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>
7 years agoMark or fix switch cases that fall through
David Oberhollenzer [Thu, 21 Sep 2017 09:15:32 +0000 (11:15 +0200)]
Mark or fix switch cases that fall through

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>
7 years agoAdd no-return attribute to usage() style functions
David Oberhollenzer [Thu, 21 Sep 2017 11:36:42 +0000 (13:36 +0200)]
Add no-return attribute to usage() style functions

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>
7 years agoRemove self-assignments of unused paramters
David Oberhollenzer [Wed, 1 Nov 2017 23:50:27 +0000 (00:50 +0100)]
Remove self-assignments of unused paramters

Use casts to void instead. Clang generates warnings about that by
default.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
7 years agomkfs.ubifs: ignore EOPNOTSUPP when listing extended attributes
Pavel Roskin [Tue, 24 Oct 2017 15:07:30 +0000 (08:07 -0700)]
mkfs.ubifs: ignore EOPNOTSUPP when listing extended attributes

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>
7 years agotests: checkfs: Remove unused source file from makefiles
David Oberhollenzer [Thu, 21 Sep 2017 14:19:08 +0000 (16:19 +0200)]
tests: checkfs: Remove unused source file from makefiles

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>
7 years agomisc-utils: initialize "ip" in docfdisk to NULL
David Oberhollenzer [Thu, 21 Sep 2017 14:16:22 +0000 (16:16 +0200)]
misc-utils: initialize "ip" in docfdisk to NULL

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>
7 years agoubi-tests: io_update: fix missleading indentation
David Oberhollenzer [Thu, 21 Sep 2017 12:12:39 +0000 (14:12 +0200)]
ubi-tests: io_update: fix missleading indentation

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
7 years agomkfs.ubifs: Apply squash-uids to the root node
Romain Izard [Tue, 3 Oct 2017 08:50:28 +0000 (10:50 +0200)]
mkfs.ubifs: Apply squash-uids to the root node

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>
7 years agoAdd ctags files to .gitignore
Uwe Kleine-König [Thu, 24 Aug 2017 15:22:38 +0000 (17:22 +0200)]
Add ctags files to .gitignore

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>