]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
4 years agolsblk: check stat() return code [coverity scan]
Karel Zak [Thu, 23 May 2019 10:28:13 +0000 (12:28 +0200)] 
lsblk: check stat() return code [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agologger: make code more robust for static analyzer [clang scan]
Karel Zak [Thu, 23 May 2019 10:14:10 +0000 (12:14 +0200)] 
logger: make code more robust for static analyzer [clang scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agohardlink: avoid uninitialized variables [clang scan]
Karel Zak [Thu, 23 May 2019 10:12:07 +0000 (12:12 +0200)] 
hardlink: avoid uninitialized variables [clang scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibfdisk: assert if self_pte() returns NULL
Sami Kerola [Wed, 22 May 2019 18:45:54 +0000 (19:45 +0100)] 
libfdisk: assert if self_pte() returns NULL

The self_pte() can return NULL if partitions array is not large enough,
but that should also be impossible and definitely a bug.

libfdisk/src/dos.c:984:8: warning: potential null pointer dereference [-Wnull-dereference]
libfdisk/src/dos.c:1031:8: warning: potential null pointer dereference [-Wnull-dereference]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agolibfdisk: (bsd) improve checksum calculation [-Waddress-of-packed-member]
Karel Zak [Wed, 22 May 2019 15:42:48 +0000 (17:42 +0200)] 
libfdisk: (bsd) improve checksum calculation [-Waddress-of-packed-member]

Let's keep compilers and static analyzers happy. The idea is to use
memcpy() to copy from buffer to variable and use all label as unsigned
char rather than vectorize by unsigned short.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibblkid: (silicon raid) improve checksum calculation [-Waddress-of-packed-member]
Karel Zak [Wed, 22 May 2019 15:42:48 +0000 (17:42 +0200)] 
libblkid: (silicon raid) improve checksum calculation [-Waddress-of-packed-member]

Let's keep compilers and static analyzers happy. The idea is to use
memcpy() to copy from buffer to variable and use all label as unsigned
char rather than vectorize by uint16_t.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibfdisk: (sgi) improve checksum calculation [-Waddress-of-packed-member]
Karel Zak [Wed, 22 May 2019 15:42:48 +0000 (17:42 +0200)] 
libfdisk: (sgi) improve checksum calculation [-Waddress-of-packed-member]

Let's keep compilers and static analyzers happy. The idea is to use
memcpy() to copy from buffer to variable and use all label as unsigned
char rather than vectorize by uint32_t.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoinclude/c: use __has_attribute
Karel Zak [Tue, 21 May 2019 14:27:17 +0000 (16:27 +0200)] 
include/c: use __has_attribute

The __has macros are more portable (supported by gcc as well as
clang).

The old __GNUC_PREREQ is deprecated and it should be removed in
future. (Well, the __has macros are supported since gcc 5, so we
should be patient as some old stable distros (e.g. RHEL 7) use gcc
4.x).

This patch helps clang to correctly analyze our xalloc.h stuff.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agobash-completion: add hardlink completion
Sami Kerola [Mon, 20 May 2019 18:56:19 +0000 (19:56 +0100)] 
bash-completion: add hardlink completion

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agobash-completion: update options before release
Sami Kerola [Mon, 20 May 2019 18:34:10 +0000 (19:34 +0100)] 
bash-completion: update options before release

blkid: 5e91d5dd716ebc6144bcb0cabb0ec847a678be9e --no-part-details
lsblk: dc4662f0e755929de9cbe98b1b343b492fd620f4 --dedup
lsblk: 0bd05f5ee4876ffd13c98acd56c2bff9971f28f1 --merge
lscpu: 0e86bc8406959d0d56194d4f404b780e6b70caa4 --caches
lscpu: 2011528bce58dd31d5ee0287f2367da1f2d6cfa9 --bytes

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agolib/ismounted: use xstrncpy()
Karel Zak [Mon, 20 May 2019 11:03:58 +0000 (13:03 +0200)] 
lib/ismounted: use xstrncpy()

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agozramctl: use xstrncpy()
Karel Zak [Mon, 20 May 2019 10:59:40 +0000 (12:59 +0200)] 
zramctl: use xstrncpy()

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agowhereis: use xstrncpy()
Karel Zak [Mon, 20 May 2019 10:59:02 +0000 (12:59 +0200)] 
whereis: use xstrncpy()

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agovipw: use xstrncpy()
Karel Zak [Mon, 20 May 2019 10:57:39 +0000 (12:57 +0200)] 
vipw: use xstrncpy()

It's already used by vipw, so use it everywhere.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/path: use xstrncpy()
Karel Zak [Mon, 20 May 2019 10:57:16 +0000 (12:57 +0200)] 
lib/path: use xstrncpy()

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/sysfs: use xstrncpy()
Karel Zak [Mon, 20 May 2019 10:57:07 +0000 (12:57 +0200)] 
lib/sysfs: use xstrncpy()

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolosetup: use xstrncpy()
Karel Zak [Mon, 20 May 2019 10:46:39 +0000 (12:46 +0200)] 
losetup: use xstrncpy()

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agosfdisk: use xstrcpy()
Karel Zak [Mon, 20 May 2019 10:42:43 +0000 (12:42 +0200)] 
sfdisk: use xstrcpy()

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/colors: remove unnecessary goto
Karel Zak [Mon, 20 May 2019 10:41:12 +0000 (12:41 +0200)] 
lib/colors: remove unnecessary goto

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch '2019wk19' of https://github.com/kerolasa/util-linux
Karel Zak [Mon, 20 May 2019 10:35:38 +0000 (12:35 +0200)] 
Merge branch '2019wk19' of https://github.com/kerolasa/util-linux

* '2019wk19' of https://github.com/kerolasa/util-linux:
  lib/colors: remove redundant if statement
  wipefs: fix variable / function shadowing [cppcheck]
  sulogin: fix variable / function shadowing [cppcheck]
  lscpu: remove redundant condition check [cppcheck]
  libmount: avoid possible null pointer dereference [cppcheck]
  lib/mangle: fix possible null pointer dereference [cppcheck]
  sfdisk: remove unnecessary size check [cppcheck]

4 years agoMerge branch 'lscpu_midr_updates' of https://github.com/jlinton/util-linux
Karel Zak [Mon, 20 May 2019 10:35:09 +0000 (12:35 +0200)] 
Merge branch 'lscpu_midr_updates' of https://github.com/jlinton/util-linux

* 'lscpu_midr_updates' of https://github.com/jlinton/util-linux:
  lscpu: Add additional aarch64 models

4 years agoMerge branch 'lscpu-another' of https://github.com/kerolasa/util-linux
Karel Zak [Mon, 20 May 2019 10:34:45 +0000 (12:34 +0200)] 
Merge branch 'lscpu-another' of https://github.com/kerolasa/util-linux

* 'lscpu-another' of https://github.com/kerolasa/util-linux:
  lscpu: fix floating point exception
  include/strutils: fix potential null pointer dereference
  lscpu: remove extra space from field key name

4 years agolib/colors: remove redundant if statement
Sami Kerola [Sat, 18 May 2019 21:56:15 +0000 (22:56 +0100)] 
lib/colors: remove redundant if statement

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agowipefs: fix variable / function shadowing [cppcheck]
Sami Kerola [Sat, 18 May 2019 21:39:58 +0000 (22:39 +0100)] 
wipefs: fix variable / function shadowing [cppcheck]

[misc-utils/wipefs.c:636] -> [misc-utils/wipefs.c:310]: (style) Local
variable usage shadows outer function

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agosulogin: fix variable / function shadowing [cppcheck]
Sami Kerola [Sat, 18 May 2019 21:36:44 +0000 (22:36 +0100)] 
sulogin: fix variable / function shadowing [cppcheck]

[login-utils/sulogin.c:398] -> [login-utils/sulogin.c:171]: (style) Local
variable set shadows outer function
[login-utils/sulogin.c:398] -> [login-utils/sulogin.c:830]: (style) Local
variable set shadows outer function

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agolscpu: remove redundant condition check [cppcheck]
Sami Kerola [Sat, 18 May 2019 21:25:11 +0000 (22:25 +0100)] 
lscpu: remove redundant condition check [cppcheck]

[sys-utils/lscpu.c:1783] -> [sys-utils/lscpu.c:1785]: (warning) Either the
condition 'desc' is redundant or there is possible null pointer dereference: desc.
[sys-utils/lscpu.c:1840] -> [sys-utils/lscpu.c:1842]: (warning) Either the
condition 'desc' is redundant or there is possible null pointer dereference: desc.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agolibmount: avoid possible null pointer dereference [cppcheck]
Sami Kerola [Sat, 18 May 2019 21:14:20 +0000 (22:14 +0100)] 
libmount: avoid possible null pointer dereference [cppcheck]

[libmount/src/monitor.c:797]: (warning) Possible null pointer dereference: me

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agolib/mangle: fix possible null pointer dereference [cppcheck]
Sami Kerola [Sat, 18 May 2019 21:09:25 +0000 (22:09 +0100)] 
lib/mangle: fix possible null pointer dereference [cppcheck]

Fix effects code that is used when testing util-linux, so quite low impact.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agosfdisk: remove unnecessary size check [cppcheck]
Sami Kerola [Sat, 18 May 2019 20:46:08 +0000 (21:46 +0100)] 
sfdisk: remove unnecessary size check [cppcheck]

Following warning is false positive.  Size of the buffer is defined using
BUFSIZ, and so the strncpy() will never overwrite the last byte that is
initialized to zero in get_user_reply().

[disk-utils/sfdisk.c:137] -> [disk-utils/sfdisk.c:136]: (warning) Either the
condition 'bufsz!=0' is redundant or strncpy() argument nr 3 can have
invalid value.  The value is -1 but the valid values are '0:'.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agolscpu: fix floating point exception
Sami Kerola [Sat, 18 May 2019 17:43:08 +0000 (18:43 +0100)] 
lscpu: fix floating point exception

As the title tells this change indeed fixes floating point exception, but
post processing as value overwrite feels a wrong.  Possibly something in
input is making cpu set count to go wrong, but I could not get my head
around what could it be.  Anyway avoiding division by zero seems better than
crashing so lets do this atleast for now.

Caused-by: e5f721132ec8b8c933a396d8dcb3efcb67854f13
Addresses: https://github.com/karelzak/util-linux/issues/788
Reported-by: Lars Wendler <polynomial-c@gentoo.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agoinclude/strutils: fix potential null pointer dereference
Sami Kerola [Thu, 16 May 2019 20:56:57 +0000 (21:56 +0100)] 
include/strutils: fix potential null pointer dereference

Recent lscpu fix caused gcc -Wnull-dereference to go off that this change
addresses.

Reference: b94acada9ed0e11a7e82f8f60280c5b6058e4250
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agolscpu: remove extra space from field key name
Sami Kerola [Thu, 16 May 2019 20:51:47 +0000 (21:51 +0100)] 
lscpu: remove extra space from field key name

The extra space was more obvious in json output.  But as the expected test
output displays also the standard output can be effected by this change.

    $ lscpu --json | jq '.lscpu | .[].field' | grep ': '
    "L1d cache: "
    "L1i cache: "
    "L2 cache: "
    "L3 cache: "
    "Vulnerability L1tf: "
    "Vulnerability Mds: "
    "Vulnerability Meltdown: "
    "Vulnerability Spec store bypass: "
    "Vulnerability Spectre v1: "
    "Vulnerability Spectre v2: "

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agolscpu: Add additional aarch64 models
Jeremy Linton [Thu, 16 May 2019 17:10:17 +0000 (12:10 -0500)] 
lscpu: Add additional aarch64 models

ARM has released docs for Cortex-A76, Neoverse-N1 and Neoverse-E1.
That means we know the midr partnums, so we can add them to the
human readable model name table.

Signed-off-by: Jeremy Linton <lintonrjeremy@gmail.com>
4 years agofindmnt: keep it easy for static analyzers
Karel Zak [Thu, 16 May 2019 12:38:12 +0000 (14:38 +0200)] 
findmnt: keep it easy for static analyzers

4 years agofindmnt: (verify) check mnt_table_next_fs() return code [coverity scan]
Karel Zak [Thu, 16 May 2019 12:33:47 +0000 (14:33 +0200)] 
findmnt: (verify) check mnt_table_next_fs() return code [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agofincore: remove unused variable [clang scan]
Karel Zak [Thu, 16 May 2019 12:27:15 +0000 (14:27 +0200)] 
fincore: remove unused variable [clang scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agocal: make sure months_in_row makes sense [coverity scan]
Karel Zak [Thu, 16 May 2019 12:20:32 +0000 (14:20 +0200)] 
cal: make sure months_in_row makes sense [coverity scan]

* avoid divide by zero in mountly() dues to wrong months_in_row
* make sure months_in_row is at least 1

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoblkid: improve strcpy() usage [coverity scan]
Karel Zak [Thu, 16 May 2019 11:56:34 +0000 (13:56 +0200)] 
blkid: improve strcpy() usage [coverity scan]

The old deprecated list output format ("-o list") copies gettex string
into fixed buffer, that's really bad idea.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoutmpdump: check ftello() return value
Karel Zak [Thu, 16 May 2019 11:46:03 +0000 (13:46 +0200)] 
utmpdump: check ftello() return value

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'lscpu-output-fix' of https://github.com/kerolasa/util-linux
Karel Zak [Thu, 16 May 2019 11:31:30 +0000 (13:31 +0200)] 
Merge branch 'lscpu-output-fix' of https://github.com/kerolasa/util-linux

* 'lscpu-output-fix' of https://github.com/kerolasa/util-linux:
  lscpu: move trailing null after removing characters from a string

4 years agolscpu: move trailing null after removing characters from a string
Sami Kerola [Thu, 16 May 2019 10:44:38 +0000 (11:44 +0100)] 
lscpu: move trailing null after removing characters from a string

From the test input string ':' characters are removed:

    cat x86_64-epyc_7451/sys/devices/system/cpu/vulnerabilities/spectre_v2
    Mitigation: Full AMD retpoline, IBPB: conditional, STIBP: disabled, RSB filling

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agolibsmartcols: (groups) improve scols_table_group_lines() args check [coverity scan]
Karel Zak [Wed, 15 May 2019 15:46:31 +0000 (17:46 +0200)] 
libsmartcols: (groups) improve scols_table_group_lines() args check [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount: fix memory leak on error [coverity scan]
Karel Zak [Wed, 15 May 2019 15:25:04 +0000 (17:25 +0200)] 
libmount: fix memory leak on error [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibfdisk: avoid memory leak [coverity scan]
Karel Zak [Wed, 15 May 2019 15:12:38 +0000 (17:12 +0200)] 
libfdisk: avoid memory leak [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibfdisk: avoid division by zero [clang scan]
Karel Zak [Wed, 15 May 2019 15:10:38 +0000 (17:10 +0200)] 
libfdisk: avoid division by zero [clang scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibfdisk: remove unused code [clang scan]
Karel Zak [Wed, 15 May 2019 14:59:52 +0000 (16:59 +0200)] 
libfdisk: remove unused code [clang scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibfdisk: properly check return code of add_to_partitions_array() [coverity scan]
Karel Zak [Wed, 15 May 2019 14:49:26 +0000 (16:49 +0200)] 
libfdisk: properly check return code of add_to_partitions_array() [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibblkid: make partitions reference counting more robust [coverity scan]
Karel Zak [Wed, 15 May 2019 14:28:31 +0000 (16:28 +0200)] 
libblkid: make partitions reference counting more robust [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibblkid: don't ignore blkid_probe_set_magic() errors [coverity scan]
Karel Zak [Wed, 15 May 2019 14:24:51 +0000 (16:24 +0200)] 
libblkid: don't ignore blkid_probe_set_magic() errors [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibblkid: fix possible uninitialized value use [coverity scan]
Karel Zak [Wed, 15 May 2019 14:15:15 +0000 (16:15 +0200)] 
libblkid: fix possible uninitialized value use [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/strutils: keep static analyzer happy [coverity scan]
Karel Zak [Wed, 15 May 2019 14:09:16 +0000 (16:09 +0200)] 
lib/strutils: keep static analyzer happy [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/path: fix resource leak [coverity scan]
Karel Zak [Wed, 15 May 2019 14:01:32 +0000 (16:01 +0200)] 
lib/path: fix resource leak [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/path: fix possible NULL dereferencing [coverity scan]
Karel Zak [Wed, 15 May 2019 13:57:09 +0000 (15:57 +0200)] 
lib/path: fix possible NULL dereferencing [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/path: fix ul_path_get_dirfd() usage [coverity scan]
Karel Zak [Wed, 15 May 2019 13:52:54 +0000 (15:52 +0200)] 
lib/path: fix ul_path_get_dirfd() usage [coverity scan]

ul_path_get_dirfd() returns negative number on error...

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/path: consolidate ul_path_mkpath() usage
Karel Zak [Wed, 15 May 2019 13:47:29 +0000 (15:47 +0200)] 
lib/path: consolidate ul_path_mkpath() usage

* always use errno from ul_path_mkpath()
* keep code simple and short as possible

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/path: fix possible NULL pointer dereferencing [coverity scan]
Karel Zak [Wed, 15 May 2019 13:36:49 +0000 (15:36 +0200)] 
lib/path: fix possible NULL pointer dereferencing [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agocolumn: fix "maybe be" duplication
Austin English [Mon, 13 May 2019 18:53:19 +0000 (13:53 -0500)] 
column: fix "maybe be" duplication

Signed-off-by: Austin English <austinenglish@gmail.com>
4 years agortcwake: fix "maybe be" duplication
Austin English [Mon, 13 May 2019 18:53:18 +0000 (13:53 -0500)] 
rtcwake: fix "maybe be" duplication

Signed-off-by: Austin English <austinenglish@gmail.com>
4 years agomount: fix "maybe be" duplication
Austin English [Mon, 13 May 2019 18:53:17 +0000 (13:53 -0500)] 
mount: fix "maybe be" duplication

Signed-off-by: Austin English <austinenglish@gmail.com>
4 years agolsblk: fix "maybe be" duplication
Austin English [Mon, 13 May 2019 18:53:16 +0000 (13:53 -0500)] 
lsblk: fix "maybe be" duplication

Signed-off-by: Austin English <austinenglish@gmail.com>
4 years agolibmount: fix "maybe be" duplication
Austin English [Mon, 13 May 2019 18:53:15 +0000 (13:53 -0500)] 
libmount: fix "maybe be" duplication

Signed-off-by: Austin English <austinenglish@gmail.com>
4 years agolib/colors: fix "maybe be" duplication
Austin English [Mon, 13 May 2019 18:53:14 +0000 (13:53 -0500)] 
lib/colors: fix "maybe be" duplication

Signed-off-by: Austin English <austinenglish@gmail.com>
4 years agolosetup: keep static analyzer happy [coverity scan]
Karel Zak [Tue, 14 May 2019 14:43:40 +0000 (16:43 +0200)] 
losetup: keep static analyzer happy [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/colors: keep static analyzer happy [coverity scan]
Karel Zak [Tue, 14 May 2019 14:37:35 +0000 (16:37 +0200)] 
lib/colors: keep static analyzer happy [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/canonicalize: verify DM paths [coverity scan]
Karel Zak [Tue, 14 May 2019 13:47:02 +0000 (15:47 +0200)] 
lib/canonicalize: verify DM paths [coverity scan]

Now the code only checks that /sys/.../dm/name exists, but never
verify the device node in /dev (because path prefix is never NULL).

The prefix is used to redirect hardcoded paths to /sys dumps (e.g.
lsblk regression tests, etc.)

This bug has been introduced in v2.33. Fortunately, it's probably no
big issue as /dev is always in sync with /sys (thanks to udevd).

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agobuild-sys: add PKG_INSTALLDIR fallback
Karel Zak [Tue, 14 May 2019 13:25:07 +0000 (15:25 +0200)] 
build-sys: add PKG_INSTALLDIR fallback

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agofdisk: initialize buffers for get_user_reply() [coverity scan]
Karel Zak [Tue, 14 May 2019 13:00:01 +0000 (15:00 +0200)] 
fdisk: initialize buffers for get_user_reply() [coverity scan]

It's probably unnecessary, but better be safe than sorry.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agobuild-sys: add --with-pkgconfigdir
Karel Zak [Tue, 14 May 2019 11:50:59 +0000 (13:50 +0200)] 
build-sys: add --with-pkgconfigdir

It seems we need a way how to override the default pkg-config install directory.

default:
$ ./configure
$ grep 'pkgconfigdir ='  Makefile
pkgconfigdir = ${usrlib_execdir}/pkgconfig

user-defined:
$ ./configure --with-pkgconfigdir=/usr/share/pkgconfig
$ grep 'pkgconfigdir ='  Makefile
$ pkgconfigdir = /usr/share/pkgconfig

Addresses: https://github.com/karelzak/util-linux/issues/793
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibblkid: Set BLKID_BID_FL_VERIFIED in case revalidation is not needed
Nikolay Borisov [Mon, 13 May 2019 12:44:18 +0000 (15:44 +0300)] 
libblkid: Set BLKID_BID_FL_VERIFIED in case revalidation is not needed

If blkid_verify deems that device revalidation is not needed since BLKID_PROBE_MIN
seconds haven't elapsed since the last revalidation of the device it returns
a blkid_dev. However, if this device has been read from the cache file on disk then
it wont' have BLKID_BID_FL_VERIFIED bit set. This in turn could lead to a later
call to blkid_dev_get free this device in case its part of a multi device
configuration. This is particularly relevant to btrfs raid configurations.

Namely this  was exhibited by btrfs-progs which use blkid for device enumeration.
In case of a multi-device filesystem (i.e raid10) running xfstest btrfs/011
would fail sporadically since cached devices read from cache were not revalidated
due to being recently validated (according to timestamp in the cache file) at
the same time their in-memory blkid_dev structures didn't have BLKID_BID_FL_VERIFIED
set. This lead to their untimely removal from the cache from blkid_get_dev.

Fix this by setting the BLKID_BID_FL_VERIFIED when returning from blkid_verify
with a valid device irrespective of whether full revalidation was performed or
the device is deemed valid due to being recently validated.

[kzak@redhat.com: - remove also check for BLKID_BID_FL_VERIFIED, the
                    function needs to check for elapsed time only]

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibblkid: Don't check BLKID_PROBE_INTERVAL in blkid_verify
Nikolay Borisov [Mon, 13 May 2019 12:44:17 +0000 (15:44 +0300)] 
libblkid: Don't check BLKID_PROBE_INTERVAL in blkid_verify

That constant is set to 200 seconds and is already check in probe_all().
It essentially controls how often blkid_probe_all can do a full cache
revalidation. Since blkid_verify is called from within probe_all() iff at least
BLKID_PROBE_INTERVAL seconds have elapsed it makes no sense to check this value
in blkid_verify.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
4 years agolib/strutils: parse_size() fix frac digit calculation
Karel Zak [Mon, 13 May 2019 15:07:14 +0000 (17:07 +0200)] 
lib/strutils: parse_size() fix frac digit calculation

Old code:

./test_strutils --size 0.5MiB
0.5MiB :               512000 :     500K :      500 KiB
./test_strutils --size 0.50MiB
0.50MiB :              5120000 :     4.9M :      4.9 MiB

New code:
./test_strutils --size 0.5MiB
0.5MiB :               524288 :     512K :      512 KiB
./test_strutils --size 0.50MiB
       0.50MiB :               524288 :     512K :      512 KiB

Note that the new implementation also does not use float points,
because we need to support PiB and so on... it seems good enough for
things like:

        ./test_strutils --size 7.13G
                7.13G :           7656104581 :     7.1G :      7.1 GiB
        ./test_strutils --size 7.16G
                7.16G :           7690675814 :     7.2G :      7.2 GiB

to avoid situation where cfdisk creates partition with completely
crazy numbers.

Addresses: https://github.com/karelzak/util-linux/issues/782
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/strutils: parse_size() fix frac with zeros
Karel Zak [Mon, 13 May 2019 14:15:58 +0000 (16:15 +0200)] 
lib/strutils: parse_size() fix frac with zeros

Fix 0.001G as well as accept 0.000G as valid number.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agofstrim: affect only warnings by --quiet
Karel Zak [Thu, 9 May 2019 11:59:54 +0000 (13:59 +0200)] 
fstrim: affect only warnings by --quiet

We need the same return code from fstrim_filesystem() independently on
--quiet command line option.

Addresses: https://github.com/karelzak/util-linux/pull/791
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agobash-completion: add fstrim --quiet
Karel Zak [Thu, 9 May 2019 11:16:03 +0000 (13:16 +0200)] 
bash-completion: add fstrim --quiet

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'fstrim-bug-789' of https://github.com/kerolasa/util-linux
Karel Zak [Thu, 9 May 2019 11:15:10 +0000 (13:15 +0200)] 
Merge branch 'fstrim-bug-789' of https://github.com/kerolasa/util-linux

* 'fstrim-bug-789' of https://github.com/kerolasa/util-linux:
  fstrim: add --quiet option to suppress error messages

4 years agolibmount: return errno on failed fstab stat()
Karel Zak [Thu, 9 May 2019 08:09:34 +0000 (10:09 +0200)] 
libmount: return errno on failed fstab stat()

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agofstrim: add --quiet option to suppress error messages
Sami Kerola [Tue, 7 May 2019 19:18:08 +0000 (20:18 +0100)] 
fstrim: add --quiet option to suppress error messages

When fstrim interacts with NTFS it result can be error reporting bad file
descriptor.  That seems to be a bug in NTFS.  While waiting driver to get on
top of the issue and be commonly available lets add to fstrim option to make
it be more silent about errno 9 aka EBADF, Bad file descriptor.

Reported-by: https://github.com/moviuro
Proposed-by: Dave Reisner <dreisner@archlinux.org>
Reference: https://bugs.archlinux.org/task/62288
Addresses: https://github.com/karelzak/util-linux/issues/789
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agobuild-sys: use __SANITIZE_ADDRESS__ rather than custom USE_CLOSE_ATEXIT
Karel Zak [Tue, 7 May 2019 10:59:52 +0000 (12:59 +0200)] 
build-sys: use __SANITIZE_ADDRESS__ rather than custom USE_CLOSE_ATEXIT

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/loopdev.c: Retry LOOP_SET_STATUS64 on EAGAIN
Romain Izard [Fri, 3 May 2019 13:42:22 +0000 (15:42 +0200)] 
lib/loopdev.c: Retry LOOP_SET_STATUS64 on EAGAIN

A recent bugfix in the Linux kernel made it possible for the
LOOP_SET_STATUS64 ioctl to fail when called with a non-zero offset,
with an EAGAIN errno:

5db470e229e2 loop: drop caches if offset or block_size are changed

This fix changes a silent failure (where mount could sometimes access
the backing loop image through the cache without the specified offset)
to an explicit failure, and it has also been backported on stable
branches.

On a 5.0 kernel, other changes to the loop driver make it hard to get
generate the EAGAIN error, but this bugfix has also been backported to
stables branches, without these changes. At least with the 4.14 stable
branch, the EAGAIN error can be quickly generated with the following loop:

while mount -o loop,offset=239 disk point && umount point; do :; done

Retry the ioctl when it fails with EAGAIN, which means that mount or
losetup will eventually succeed when encountering this case.

[kzak@redhat.com: - use our local portable xusleep()]

Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibsmartcols: use scols_walk_* for calculations and printing
Karel Zak [Tue, 7 May 2019 09:46:11 +0000 (11:46 +0200)] 
libsmartcols: use scols_walk_* for calculations and printing

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibsmartcols: add generic function to walk on tree
Karel Zak [Tue, 7 May 2019 09:44:24 +0000 (11:44 +0200)] 
libsmartcols: add generic function to walk on tree

Now we implement the same thing on more places. Let's add one set of
functions to walk the tree and use it everywhere.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolsblk: fix heap-use-after-free
Karel Zak [Mon, 6 May 2019 10:39:07 +0000 (12:39 +0200)] 
lsblk: fix heap-use-after-free

Addresses: https://github.com/karelzak/util-linux/issues/787
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibsmartcols: cell width calulation cleanup
Karel Zak [Fri, 3 May 2019 15:27:17 +0000 (17:27 +0200)] 
libsmartcols: cell width calulation cleanup

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibsmartcols: (groups) use print functions tp calculate grpset
Karel Zak [Fri, 3 May 2019 15:12:18 +0000 (17:12 +0200)] 
libsmartcols: (groups) use print functions tp calculate grpset

Now we have extra code to calculate grpset. It seems better to use
only one way how we wall the tree.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibsmartcols: (groups) print group childrent after regualr tree
Karel Zak [Fri, 3 May 2019 12:53:23 +0000 (14:53 +0200)] 
libsmartcols: (groups) print group childrent after regualr tree

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibsmartcols: (groups) improve debug messages
Karel Zak [Fri, 3 May 2019 11:25:09 +0000 (13:25 +0200)] 
libsmartcols: (groups) improve debug messages

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolsblk: add more debug messages
Karel Zak [Thu, 2 May 2019 13:51:48 +0000 (15:51 +0200)] 
lsblk: add more debug messages

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibsmartcols: fix groups reset, add debugs
Karel Zak [Thu, 2 May 2019 13:51:29 +0000 (15:51 +0200)] 
libsmartcols: fix groups reset, add debugs

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibsmartcols: (groups) remove hardcoded const numbers
Karel Zak [Thu, 2 May 2019 11:44:12 +0000 (13:44 +0200)] 
libsmartcols: (groups) remove hardcoded const numbers

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agohardlink: fix compiler warnings [-Wsign-compare -Wmaybe-uninitialized]]
Karel Zak [Thu, 2 May 2019 10:48:05 +0000 (12:48 +0200)] 
hardlink: fix compiler warnings [-Wsign-compare -Wmaybe-uninitialized]]

misc-utils/hardlink.c: In function ‘process_path’:
misc-utils/hardlink.c:287:30: warning: operand of ?: changes signedness from ‘off_t’ {aka ‘long int’} to ‘long unsigned int’ due to unsignedness of other operand [-Wsign-compare]

misc-utils/hardlink.c: In function ‘main’:
misc-utils/hardlink.c:455:5: warning: ‘exclude_pattern’ may be used uninitialized in this function [-Wmaybe-uninitialized]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agohardlink: retire NIOBUF in favour of more common BUFSIZ
Sami Kerola [Wed, 1 May 2019 19:04:24 +0000 (20:04 +0100)] 
hardlink: retire NIOBUF in favour of more common BUFSIZ

Reason to retire NIOBUF is that it is obscure local definition, while BUFSIZ
is well understood and commonly used constant.  Besized sizes of these are
not far off, the NIOBUF was 4096 bytes and BUFSIZ tends to be 8192 bytes.

Proposed-by: Karel Zak <kzak@redhat.com>
Reference: https://github.com/karelzak/util-linux/pull/783
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agohardlink: move global variables to a control structure
Sami Kerola [Sat, 27 Apr 2019 08:54:11 +0000 (09:54 +0100)] 
hardlink: move global variables to a control structure

Well, sort of.  Due to use of ctl values in atexit() print_summary() there
is need for global control structure.

Secondly couple variables can be moved to more restricted scope, namely the
PCRE variables are now in main().

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agohardlink: use flexible array member rather than zero-size array
Sami Kerola [Sat, 27 Apr 2019 08:54:05 +0000 (09:54 +0100)] 
hardlink: use flexible array member rather than zero-size array

This fixes two standards compliancy warnings.

hardlink.c:65:7: warning: ISO C forbids zero-size array ‘name’ [-Wpedantic]

Reference: https://en.wikipedia.org/wiki/Flexible_array_member
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agobuild-sys: release++ (v2.34-rc1) v2.34-rc1
Karel Zak [Tue, 30 Apr 2019 09:56:27 +0000 (11:56 +0200)] 
build-sys: release++ (v2.34-rc1)

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agodocs: update v2.34-ReleaseNotes
Karel Zak [Tue, 30 Apr 2019 09:52:20 +0000 (11:52 +0200)] 
docs: update v2.34-ReleaseNotes

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agodocs: update AUTHORS file
Karel Zak [Mon, 29 Apr 2019 12:59:39 +0000 (14:59 +0200)] 
docs: update AUTHORS file

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agotests: build-sys update
Karel Zak [Mon, 29 Apr 2019 12:47:19 +0000 (14:47 +0200)] 
tests: build-sys update

* libblkid does not depend on libuuid anymore
* libncurses depends on libdl due to

  $ ncursesw6-config --libs
  -lncursesw -ltinfo -ldl

* new command hardlink (with dependence on libpcre2-8
* hwclock needs librt

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agobuild-sys: don't use ASAN on XOS
Karel Zak [Thu, 25 Apr 2019 08:18:08 +0000 (10:18 +0200)] 
build-sys: don't use ASAN on XOS

It seems that Apple Clang is not mature enough to use ASAN.

  AddressSanitizer: detect_leaks is not supported on this platform.

Let's disable ASAN on XOS at all.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agopo: merge changes
Karel Zak [Wed, 24 Apr 2019 16:39:05 +0000 (18:39 +0200)] 
po: merge changes

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agohardlink: remove \r from output
Karel Zak [Wed, 24 Apr 2019 16:31:08 +0000 (18:31 +0200)] 
hardlink: remove \r from output

* remove \r from internationalized messages
* remove \r from all output to make it easy to use (see for example
  output file from "hardlink -vv --dry-run . &> log")

* remove unnecessary formatting stuff from output, just keep is simple
  and stupid...

Signed-off-by: Karel Zak <kzak@redhat.com>