Commit Graph

12805 Commits

Author SHA1 Message Date
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
Karel Zak 91d28f5986 tests: add simple LVM lsblk dump
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak 905bc7817e lsblk: fix ul_path_read_string() usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak d6d24dda29 tests: add simple ATA and NVME lsblk dump
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak 314adce668 tests: add lsblk test script
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak bd45b74fc9 lsblk: fix COL_SCHED
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak 8ab664a77e tests: add simple & stupid script to generate lsblk /sys and /proc dump
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak 498d148661 lsblk: document --sysroot
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak 3273ce07e3 lsblk: fix sysfs_devno_to_devname() usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak caf1b443c0 lsblk: follow --sysroot when read mountpoints
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak 5a89aa99a7 lsblk: use prefix for DM name
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak ffc2762393 lsblk: add --sysroot
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak be869840b1 docs: add note about lsblk to TODO
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak f153614c57 lsblk: use new ul_path_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak ab628c7c18 lib/sysfs: cleanup function names
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak 345ddd2828 blockdev: use new ul_path_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak 61bc5fd156 partx: use new ul_path_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak 7f8a406679 resizepart: use new ul_path_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak 4448b3ab9e blkzone: use new ul_path_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00