Commit Graph

12823 Commits

Author SHA1 Message Date
Karel Zak 47afae0caa libblkid: const qualifier cleanup
* 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>
2018-07-20 15:05:32 +02:00
Karel Zak 34708190d1 include/all-io: const cleanup
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-20 14:53:25 +02:00
Karel Zak ea927bde6b libmount: cleanup const in umount code
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-20 14:15:42 +02:00
Karel Zak c8b237a0ed lib/color-names: const cleanup
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-20 13:58:10 +02:00
Karel Zak a679b0823f libmount: add missing const
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-20 13:51:52 +02:00
Karel Zak 0d1e744c20 libmount: use const char in swaps parser
The parser does not modify the string, so let's keep it "const char".

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-20 13:49:08 +02:00
Karel Zak 4e4c9629e6 libmount: use const char in mountinfo parser
The parser does not modify the string, so let's keep it "const char".

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-20 13:48:09 +02:00
Karel Zak 4ccc64c4ca libmount: use const char in fstab parser
The parser does not modify the string, so let's keep it "const char".

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-20 13:44:53 +02:00
Karel Zak d54b83156f lib/strutils: follow const in parse_size()
* 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>
2018-07-20 12:54:58 +02:00
Karel Zak 8a7aeeda67 include/strutils: remove unnecessary cast
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-20 12:52:09 +02:00
Karel Zak 9854912fef hwclock: fix warning
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-20 12:25:38 +02:00
Karel Zak 17666c8760 build-sys: add -Wdiscarded-qualifiers
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-20 12:15:31 +02:00
Karel Zak b6cc121043 mount: add details about mtab and --namespace to mount.8
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-19 11:41:31 +02:00
Karel Zak fae8328928 libmount: add since tag for new functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-19 11:38:48 +02:00
Karel Zak 881953d735 lsblk: add note about --list -I <maj,...>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-18 16:21:01 +02:00
Karel Zak df4f1a6647 hwclock: add --delay <seconds>
* 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>
2018-07-18 13:59:15 +02:00
Karel Zak 4f9d999a97 build-sys: add -Wno-cast-function-type for python
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>
2018-07-18 10:23:51 +02:00
Karel Zak b9144a43c0 libfdisk: fix compiler warning [-Wmaybe-uninitialized]
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-18 10:00:18 +02:00
Karel Zak 4d43029b72 lslogins: remove redundant condition
[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>
2018-07-18 09:54:05 +02:00
Karel Zak 8deb816173 lib/strutils: remove redundant condition
[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>
2018-07-18 09:48:19 +02:00
Karel Zak 366edea76e mkfs.cramfs: remove redundant condition
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>
2018-07-18 09:46:40 +02:00
Karel Zak 3b6ca044da lib/pager: fix compiler warning [-Wrestrict]
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>
2018-07-18 09:41:46 +02:00
Karel Zak 342c66dee8 docs: add fdisk to TODO
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-17 12:10:37 +02:00
Karel Zak e8746956fc docs: add hwclock to TODO
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-17 11:58:09 +02:00
Milan Broz 8bee1a220d libblkid: Check for a secondary LUKS2 header.
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>
2018-07-11 14:18:33 +02:00
Frank Schaefer 8a12ab5775 * break up large strings for PySys_WriteStdout() 2018-07-10 20:21:02 -05:00
Karel Zak 690fa00b6c tests: add mountinfo with empty source
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-10 14:04:09 +02:00
Alban Crequy 18a52a5094 libmount: (mountinfo) parse empty strings in source
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>
2018-07-10 13:48:38 +02:00
Karel Zak 66638b0b70 lsblk: add PATH column
$ lsblk -o+PATH
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT    PATH
sda           8:0    0 223.6G  0 disk               /dev/sda
├─sda1        8:1    0   200M  0 part /boot/efi     /dev/sda1
├─sda2        8:2    0   200M  0 part /boot         /dev/sda2
├─sda3        8:3    0 130.3G  0 part               /dev/sda3
├─sda4        8:4    0    50G  0 part /             /dev/sda4
├─sda5        8:5    0  35.1G  0 part               /dev/sda5
└─sda6        8:6    0   7.8G  0 part               /dev/sda6

Requested-by: Marcel Partap <mpartap@gmx.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-10 10:33:18 +02:00
Karel Zak 46e972354d Merge branch 'master' of https://github.com/hjmallon/util-linux
* 'master' of https://github.com/hjmallon/util-linux:
  libblkid: Add more APFS checking to avoid false positives
2018-07-10 09:38:07 +02:00
YmrDtnJu 03190b73f0
logger: Define SD_JOURNAL_SUPPRESS_LOCATION.
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.
2018-07-07 20:11:46 +02:00
Harry Mallon 4d0bc05697 libblkid: Add more APFS checking to avoid false positives 2018-07-06 18:39:26 +01:00
Karel Zak e6dfbd70ea libfdisk: reduce number of asprintf() calls, check return value
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-04 15:16:35 +02:00
KyleMahlkuch 7377518976 libfdisk: Fix multipath partition seperators for user-friendly names
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.
2018-07-04 15:08:00 +02:00
Karel Zak 810b313688 libfdisk: use \x<hex> to read/write partition name
Addresses: https://github.com/karelzak/util-linux/issues/656
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-04 14:09:16 +02:00
Karel Zak 7a287e63b9 fallocate: remove unwanted debug message
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-04 13:37:06 +02:00
Karel Zak 3918998043 Merge branch 'master' of https://github.com/hjmallon/util-linux
* 'master' of https://github.com/hjmallon/util-linux:
  libblkid: Add very basic APFS recognition
2018-07-04 13:25:07 +02:00
Karel Zak 805400c730 Merge branch 'quick-fix-20180625' of https://github.com/sjitech/util-linux
* 'quick-fix-20180625' of https://github.com/sjitech/util-linux:
  exec_shell: prevent ".: applet not found" error when SHELL env is not set.
2018-07-04 11:00:58 +02:00
Karel Zak 9c836fde5f Merge branch 'fixes' of https://github.com/rudimeier/util-linux
* 'fixes' of https://github.com/rudimeier/util-linux:
  wipefs: add missing ifdef
  lib/path: remove unused expression
  ipcs,chmem: fix access() usage
2018-07-03 13:55:32 +02:00
Karel Zak 562adaed91 fallocate: add man page note about --collapse-range granularity
Reported-by: Radka Skvarilova <rskvaril@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-03 13:51:51 +02:00
Harry Mallon 084f092a62 libblkid: Add very basic APFS recognition 2018-06-25 16:19:18 +01:00
Ruediger Meier 3097f788f9 wipefs: add missing ifdef
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>
2018-06-25 16:49:54 +02:00
Ruediger Meier 24c329bbb3 lib/path: remove unused expression
error: expression result unused [-Werror,-Wunused-value]
                        prefix = optarg, "failed to parse range start";
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-06-25 16:49:37 +02:00
Ruediger Meier 77845f7bd7 ipcs,chmem: fix access() usage
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>
2018-06-25 16:49:00 +02:00
osexp2000 82adb91f6e exec_shell: prevent ".: applet not found" error when SHELL env is not set.
When SHELL env is not set, it cause xstrdup(NULL) be executed, and result in weird error message ".: applet not found" instead of /bin/sh being used.
2018-06-25 10:34:31 +09:00
Karel Zak 917f53cf13 docs: update TODO
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-22 12:47:25 +02:00
Karel Zak 2cb147e026 include/path: make sure PATH_MAX is defined
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 14:24:01 +02:00
Karel Zak f6447ee929 Merge branch 'more' of https://github.com/kerolasa/util-linux
* 'more' of https://github.com/kerolasa/util-linux:
  more: remove function like preprocessor defines
  more: remove global variables, add struct more_control
  more: move couple functions
2018-06-21 14:01:54 +02:00
Karel Zak bd5f7f2ef3 choom: use new ul_path_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:49:16 +02:00
Karel Zak 83bbeb77c1 lib/path: allow dir-path formatting
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:49:03 +02:00