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.
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.
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
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
[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.
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:'.
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>
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>
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>
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>
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>
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>
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]
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>
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...