* use "const" in functions where we don't modify arguments
* use "const" when cast from const buffer to any struct (superblock etc.)
Signed-off-by: Karel Zak <kzak@redhat.com>
* don't cast from char to const char
* don't share endptr from strtoxxx() with rest of the code
as the end pointer is char, but code works with const chars
Signed-off-by: Karel Zak <kzak@redhat.com>
* add command line option --delay <seconds>
* read RTC type from /sys/class/rtc/rtc<N>/name
* default to 0.5 (500ms) for rtc_cmos or when RTC type is impossible
determine; otherwise delay is 0.
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/python/pylibmount.c:158:19: warning: cast between incompatible function types
from ‘PyObject * (*)(PyObject *)’ {aka ‘struct _object * (*)(struct _object *)’}
to ‘PyObject * (*)(PyObject *, PyObject *)’ {aka ‘struct _object * (*)(struct _object *, struct _object *)’}
[-Wcast-function-type]
This is generic problem in all Python C code and gcc v8. The another
possible (and probably more correct) way is to add unused argument to
all API functions. Unfortunately, this solution is pretty invasive. The
question is if gcc is not too paranoid in this case.
For more details see https://bugs.python.org/issue33012. It seems
Python guys also prefer CFLAGS modification for now.
Signed-off-by: Karel Zak <kzak@redhat.com>
[util-linux-2.32.1/login-utils/lslogins.c:601]: (style) Redundant condition: If '!EXPR', the comparison 'EXPR != '$'' is always true.
Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
[util-linux-2.32.1/lib/strutils.c:122]: (style) Redundant condition: If 'EXPR == '0'', the comparison 'EXPR' is always true.
Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
util-linux-2.32.1/disk-utils/mkfs.cramfs.c:362]: (style) Redundant condition: If 'EXPR >= 16777216', the comparison 'EXPR' is always true.
Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/pager.c: In function ‘pager_preexec’:
lib/pager.c:148:12: warning: passing argument 2 to restrict-qualified parameter aliases with argument 4 [-Wrestrict]
Signed-off-by: Karel Zak <kzak@redhat.com>
This patch adds search for a secondary LUKS2 header,
if the primary one is corrupted.
This patch is primarily needed for wipefs that should wipe
both signatures (otherwise LUKS2 header recovery can use
secondary header and revert wipefs action).
Signed-off-by: Milan Broz <gmazyland@gmail.com>
The source of a mount in /proc/self/mountinfo can unfortunately be an
empty string. Before this patch, 'mount' and 'mountpoint' fail as
following:
$ sudo mount -t tmpfs "" /tmp/bb
$ mount
mount: /proc/self/mountinfo: parse error at line 64 -- ignored
$ mountpoint /tmp/bb
/tmp/bb is not a mountpoint
This patch fixes the parsing. It is unfortunately more complex because
sscanf() does not handle fields with empty strings easily.
Other projects have their own parser for mountinfo and have similar
issues. I know of runc and runtime-tools (I'll send a patch for those
two) but there are probably others.
Signed-off-by: Alban Crequy <alban@kinvolk.io>
The normal journald functions add the location in the C source code files to
the log messages. This is nice for a big C based project, but logger is used in
scripts so it would be more useful to let users specify the location in the
script by adding the CODE_FUNC, CODE_FILE and CODE_FILE fields to the log
message.
It is already possible to do this, but it will result in two versions of these
fields: one for the location in logger.c and one for the location in the
script.
The current code assumes "-part" is the only partition sepereator
but this is not true for some distros.
For example in Ubuntu 18.04 fdisk does not print the correct names for
mpatha:
~# ls -l /dev/mapper/mpatha*
lrwxrwxrwx 1 root root 7 Feb 1 04:39 /dev/mapper/mpatha -> ../dm-0
lrwxrwxrwx 1 root root 7 Feb 1 04:38 /dev/mapper/mpatha1 -> ../dm-4
lrwxrwxrwx 1 root root 7 Feb 1 04:38 /dev/mapper/mpatha2 -> ../dm-5
lrwxrwxrwx 1 root root 7 Feb 1 04:38 /dev/mapper/mpatha3 -> ../dm-6
~# fdisk -l /dev/mapper/mpatha
Device Boot Start End Sectors Size Id Type
/dev/mapper/mpatha-part1 2048 419432447 419430400 200G 83 Linux
/dev/mapper/mpatha-part2 419432448 838862847 419430400 200G 83 Linux
/dev/mapper/mpatha-part3 838862848 1258291199 419428352 200G 83 Linux
Instead of assuming a partition seperator of "-part" this patch uses
access to check the file system for a partition seperator of "p" or
the absense of a partition seperator. If neither of these work the patch
defaults to "-part" like we had before this patch.
Seen on OSX:
misc-utils/wipefs.c:822:5: warning: implicit declaration of function 'rereadpt' is invalid in C99 [-Wimplicit-function-declaration]
rereadpt(fd, devname);
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Some mistakes happened lately when switching from path_exist()
to ul_path_access(). See f09a98de and 8ca31279.
This caused ipcs test failures when running i386 binaries on x86_64
hosts, because the syscall fallback was always used. That's why I
reviewed all similar changes and found another one in chmem.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>