]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
4 years agolibmount: Recognize more FUSE pseudofs (avfsd, lxcfs, vmware-vmblock)
Darsey Litzenberger [Thu, 3 Oct 2019 00:29:05 +0000 (17:29 -0700)] 
libmount: Recognize more FUSE pseudofs (avfsd, lxcfs, vmware-vmblock)

General info about these filesystems:

* fuse.avfsd: https://sourceforge.net/projects/avf/
* fuse.lxcfs: https://linuxcontainers.org/lxcfs/
* fuse.vmware-vmblock: https://github.com/vmware/open-vm-tools

Signed-off-by: Darsey Litzenberger <dlitz@dlitz.net>
4 years agodocs: add sfdisk --dump and --backup improvements to TODO
Karel Zak [Tue, 1 Oct 2019 11:17:03 +0000 (13:17 +0200)] 
docs: add sfdisk --dump and --backup improvements to TODO

Addresses: https://github.com/karelzak/util-linux/issues/850
Addresses: https://github.com/karelzak/util-linux/issues/852
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agocleanup: Remove some spurious spaces
Elliott Mitchell [Wed, 28 Aug 2019 23:25:57 +0000 (16:25 -0700)] 
cleanup: Remove some spurious spaces

Sorry detail-oriented people tend to wipe these out if they notice them.
Add in automated tools and lots of excess end-of-line spaces get wiped
out.

Addresses: https://github.com/karelzak/util-linux/pull/849
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibfdisk: (gpt) fix hybrid MBR detection, fix 'w'
Karel Zak [Tue, 1 Oct 2019 10:51:04 +0000 (12:51 +0200)] 
libfdisk: (gpt) fix hybrid MBR detection, fix 'w'

* current code overwrites hybrid MBR because EE partition
  is expected from fist sector, this is not true for hybrid MBR

* print "The partition table has been altered." message also for
  nested contexts

* remove "You have to sync the MBR manually" message

Addresses: https://github.com/karelzak/util-linux/issues/851
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agofdisk: Correct handling of hybrid MBR
Elliott Mitchell [Thu, 29 Aug 2019 03:12:50 +0000 (20:12 -0700)] 
fdisk: Correct handling of hybrid MBR

The traditional MBR has pretty well NO limitations on slices.  They can
be a single misaligned sector if desired.  While this is undesireable
for most real world uses, for the few places they're still used extra
limitations cause breakage not safety.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agofdisk: use 'r' to return from MBR to GPT
Karel Zak [Mon, 30 Sep 2019 11:11:17 +0000 (13:11 +0200)] 
fdisk: use 'r' to return from MBR to GPT

The current code uses 'M' to switch between MBR and GPT, but it's not
intuitive to "go back" by 'M'. It seems more user-friendly to use 'r'
as in another places (for example when go from expert menu or from BRD
menu).

The 'M' to return to GPT is still supported for backward compatibility.

Addresses: https://github.com/karelzak/util-linux/pull/849
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agosfdisk: (move-data) improve MiB/s progress bar
Karel Zak [Mon, 30 Sep 2019 10:25:17 +0000 (12:25 +0200)] 
sfdisk: (move-data) improve MiB/s progress bar

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'master' of https://github.com/dsd/util-linux
Karel Zak [Mon, 30 Sep 2019 09:15:57 +0000 (11:15 +0200)] 
Merge branch 'master' of https://github.com/dsd/util-linux

* 'master' of https://github.com/dsd/util-linux:
  libblkid: improve handling of ISO files with partition tables

4 years agoMerge branch 'nproc' of https://github.com/mator/util-linux
Karel Zak [Mon, 30 Sep 2019 09:12:35 +0000 (11:12 +0200)] 
Merge branch 'nproc' of https://github.com/mator/util-linux

* 'nproc' of https://github.com/mator/util-linux:
  Don't use `nproc --all` for getting cpu number. For example below, sparc64 is reporting 128 as a total, but only 32 is online. So use only online cpus for tests parallel runs.

4 years agoMerge branch 'non-canonical-completion' of https://github.com/kevinoid/util-linux
Karel Zak [Mon, 30 Sep 2019 09:06:09 +0000 (11:06 +0200)] 
Merge branch 'non-canonical-completion' of https://github.com/kevinoid/util-linux

* 'non-canonical-completion' of https://github.com/kevinoid/util-linux:
  bash-completion: Add non-canonical device fallback
  bash-completion: Add fallback for symlinks/images
  bash-completion: Standardize fsck/mkfs file/device

4 years agodocs: fix mixtyped constant.
Andrius Štikonas [Mon, 23 Sep 2019 21:22:48 +0000 (22:22 +0100)] 
docs: fix mixtyped constant.

Signed-off-by: Andrius Štikonas <andrius@stikonas.eu>
4 years agochsh: replace getpw unsafe functions with xgetpw
Quentin Rameau [Sat, 21 Sep 2019 18:50:21 +0000 (20:50 +0200)] 
chsh: replace getpw unsafe functions with xgetpw

4 years agolib/pwdutils: add xgetpwuid
Quentin Rameau [Sat, 21 Sep 2019 18:50:20 +0000 (20:50 +0200)] 
lib/pwdutils: add xgetpwuid

4 years agosfdisk: (man) add note about interactive mode)
Karel Zak [Tue, 17 Sep 2019 09:06:08 +0000 (11:06 +0200)] 
sfdisk: (man) add note about interactive mode)

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibblkid: improve handling of ISO files with partition tables
Daniel Drake [Tue, 24 Sep 2019 09:46:16 +0000 (17:46 +0800)] 
libblkid: improve handling of ISO files with partition tables

The ISO format specifically leaves the first 32kb blank so that it
can be used for other purposes, such as adding a partition table.
This is commonly used (e.g. by Endless and Fedora installation media) to
have partition 0 starting at sector 0 as a mountable iso9660 filesystem,
followed by more partitions (e.g. an EFI system partition).
Such layouts can be easily created by tools such as xorriso.

When plugging in a USB disk flashed with this type of ISO, blkid presents
a somewhat confusing view of the block devices. Taking the example of
a 'sda' disk with two partitions:
 1. The "iso partition"
 2. An unformatted partition

In such a setup, before the changes here, blkid will currently report the
ISO metadata attributes ID_FS_PUBLISHER_ID, ID_FS_UUID, ID_FS_LABEL, and
ID_FS_TYPE=iso9660 on both sda *and* sda1.

Since sda2 is unformatted, it won't have any ID_FS_ attributes of it's
own. And due to the following standard udev rule:

  # for partitions import parent information
  ENV{DEVTYPE}=="partition", IMPORT{parent}="ID_*"

sda2 will actually import all of the ID_FS_ stuff from the parent device
sda.

The result at this point is that three udev devices all have the same
ID_FS_ attribute values, leading to strange results such as three
devices all racing to own the link in /dev/disk/by-uuid, so you can't
reliably do a mount-by-UUID.

Clean up this situation by detecting such partitioned ISO disks
in the superblock probing setup. If files of this kind are detected,
we now only expose the ISO metadata attributes on the specific partition
that points to the ISO data (and not the parent disk).

Signed-off-by: Daniel Drake <drake@endlessm.com>
4 years agoDon't use `nproc --all` for getting cpu number. For example below,
Anatoly Pugachev [Tue, 24 Sep 2019 15:15:33 +0000 (18:15 +0300)] 
Don't use `nproc --all` for getting cpu number. For example below,
sparc64 is reporting 128 as a total, but only 32 is online. So use only
online cpus for tests parallel runs.

$ nproc
32

$ nproc --all
128

$ lscpu
Architecture:        sparc64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Big Endian
CPU(s):              32
On-line CPU(s) list: 0-31
Thread(s) per core:  8
Core(s) per socket:  4
Socket(s):           1
Model name:          UltraSparc T5 (Niagara5)
Flags:               sun4v

Signed-off-by: Anatoly Pugachev <matorola@gmail.com>
4 years agoMerge branch 'next' of https://github.com/rskvaril/util-linux
Karel Zak [Sun, 22 Sep 2019 12:05:18 +0000 (14:05 +0200)] 
Merge branch 'next' of https://github.com/rskvaril/util-linux

* 'next' of https://github.com/rskvaril/util-linux:
  tests: lscpu s390 nested virtualization

4 years agotests: lscpu s390 nested virtualization
Radka Skvarilova [Sun, 22 Sep 2019 11:49:45 +0000 (13:49 +0200)] 
tests: lscpu s390 nested virtualization

Signed-off-by: Radka Skvarilova <rskvaril@redhat.com>
Addresses:https://bugzilla.redhat.com/show_bug.cgi?id=1739443

4 years agodocs: update howto-tests.txt
Karel Zak [Sun, 22 Sep 2019 11:39:40 +0000 (13:39 +0200)] 
docs: update howto-tests.txt

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount: fix free() call on error
Karel Zak [Sat, 21 Sep 2019 09:16:34 +0000 (11:16 +0200)] 
libmount: fix free() call on error

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agohexdump: add header file guards [lgtm scan]
Karel Zak [Fri, 20 Sep 2019 14:13:52 +0000 (16:13 +0200)] 
hexdump: add header file guards [lgtm scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoterm-utils: add header file guards [lgtm scan]
Karel Zak [Fri, 20 Sep 2019 14:12:34 +0000 (16:12 +0200)] 
term-utils: add header file guards [lgtm scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agologin-utils: add header file guards [lgtm scan]
Karel Zak [Fri, 20 Sep 2019 14:10:43 +0000 (16:10 +0200)] 
login-utils: add header file guards [lgtm scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibuuid: add header file guard [lgtm scan]
Karel Zak [Fri, 20 Sep 2019 14:06:00 +0000 (16:06 +0200)] 
libuuid: add header file guard [lgtm scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoinclude/all-io: remove unnecessary condition [lgtm scan]
Karel Zak [Fri, 20 Sep 2019 14:00:13 +0000 (16:00 +0200)] 
include/all-io: remove unnecessary condition [lgtm scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agofsfreeze: remove unnecessary condition [lgtm scan]
Karel Zak [Fri, 20 Sep 2019 13:57:31 +0000 (15:57 +0200)] 
fsfreeze: remove unnecessary condition [lgtm scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibblkid: remove unnecessary condition [lgtm scan]
Karel Zak [Fri, 20 Sep 2019 13:52:34 +0000 (15:52 +0200)] 
libblkid: remove unnecessary condition [lgtm scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agomkswap: cast before lseek [lgtm scan]
Karel Zak [Fri, 20 Sep 2019 13:47:55 +0000 (15:47 +0200)] 
mkswap: cast before lseek [lgtm scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agofdformat: cast before lseek [lgtm scan]
Karel Zak [Fri, 20 Sep 2019 13:45:15 +0000 (15:45 +0200)] 
fdformat: cast before lseek [lgtm scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibfdisk: (bsd) cast before ask [lgtm scan]
Karel Zak [Fri, 20 Sep 2019 13:43:12 +0000 (15:43 +0200)] 
libfdisk: (bsd) cast before ask [lgtm scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibfdisk: (gpt) cast number of entries [lgtm scan]
Karel Zak [Fri, 20 Sep 2019 13:40:14 +0000 (15:40 +0200)] 
libfdisk: (gpt) cast number of entries [lgtm scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agobuild-sys: fix UTIL_LINUX_PT_SGI_H macro [lgtm scan]
Karel Zak [Fri, 20 Sep 2019 13:31:31 +0000 (15:31 +0200)] 
build-sys: fix UTIL_LINUX_PT_SGI_H macro [lgtm scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount: use fmemopen() in more robust way [coverity scan]
Karel Zak [Fri, 20 Sep 2019 11:00:19 +0000 (13:00 +0200)] 
libmount: use fmemopen() in more robust way [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agobash-completion: Add non-canonical device fallback
Kevin Locke [Thu, 19 Sep 2019 13:45:54 +0000 (07:45 -0600)] 
bash-completion: Add non-canonical device fallback

It is desirable for bash-completion to complete block devices via
symlinks (e.g. under /dev/disk) and with non-canonical locations (e.g.
./sda if $PWD is /dev, and /chroot/dev/sda).

Unfortunately, this is a non-trivial task due to how bash-completion
works.  It is necessary to un-escape the last partial argument, search,
then escape the results, ideally handling tilde and variable
expansion/completion.  See [_get_comp_words_by_ref] and [_filedir] in
the bash-completion project for details.

Given the development costs of a complete and correct implementation,
the annoyance/frustration which would result from an incomplete/buggy
implementation, and the trade-offs between under- and over-completion,
this commit adds fallback to bash default completion if the argument
does not match any canonical device names.  This correctly completes in
the cases mentioned above, although it incorrectly completes on
non-block-device files as well.

[_filedir]: https://github.com/scop/bash-completion/blob/2.9/bash_completion#L552
[_get_comp_words_by_ref]: https://github.com/scop/bash-completion/blob/2.9/bash_completion#L365

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
4 years agobash-completion: Add fallback for symlinks/images
Kevin Locke [Thu, 19 Sep 2019 13:40:13 +0000 (07:40 -0600)] 
bash-completion: Add fallback for symlinks/images

For commands which support operating on files (i.e. disk images), it is
desirable for bash-completion to complete matching file names.  It is
also desirable to complete on block device symlinks (e.g. under
/dev/disk).  To complete common use cases, often on canonical device
names, continue to try completion using canonical device names, then
fall back to matching any file incrementally as Bash does by default.[1]

[1]: https://github.com/karelzak/util-linux/issues/842#issuecomment-523450243

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
4 years agobash-completion: Standardize fsck/mkfs file/device
Kevin Locke [Thu, 19 Sep 2019 13:27:31 +0000 (07:27 -0600)] 
bash-completion: Standardize fsck/mkfs file/device

Some of the fsck and mkfs commands complete differently than the others,
and differently than the desired behavior.[1]  Standardize on completing
with $(lsblk -pnro name):

* fsck: Don't complete completes on all block devices and device links
  under /dev immediately (which is excessive and prone to search
  problems).
* mkfs, mkfs.bfs: Don't complete "/path/to/file" literally.  I assume
  this was copy/pasted from example code, since it does not appear to be
  a valid argument unless it is a valid path, which is rare.
* fsck.cramfs, mkfs, mkfs.bfs, mkfs.cramfs, mkswap: Don't complete on
  all filenames initially.  The desired behavior is to complete
  filenames only if there are no canonical matches.[1]

Note: A subsequent commit will add the desired fallback behavior.

[1]: https://github.com/karelzak/util-linux/issues/842#issuecomment-523450243

Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
4 years agoMerge branch 'typos' of https://github.com/kerolasa/util-linux
Karel Zak [Mon, 16 Sep 2019 10:38:43 +0000 (12:38 +0200)] 
Merge branch 'typos' of https://github.com/kerolasa/util-linux

* 'typos' of https://github.com/kerolasa/util-linux:
  bash-completion: update options
  misc: fix typos [codespell]

4 years agotests: update sfdisk dumps
Karel Zak [Mon, 16 Sep 2019 10:01:54 +0000 (12:01 +0200)] 
tests: update sfdisk dumps

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibfdisk: add sector-size to dump
Karel Zak [Mon, 16 Sep 2019 08:29:41 +0000 (10:29 +0200)] 
libfdisk: add sector-size to dump

We do not use sector-size from dumps to create partition tables,
because it's always necessary to use real device specific settings.

The new sector-size value is usable when you use the dump as
a description of the device or disk image.

Addresses: https://github.com/karelzak/util-linux/issues/869
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agobash-completion: update options
Sami Kerola [Thu, 12 Sep 2019 18:43:17 +0000 (19:43 +0100)] 
bash-completion: update options

unshare: cef4decf0436953031b4a8ea91a8aec89459a8fd --keep-caps
dmesg:   646bba41fd162fe1b8e303ff90914253e5fc669e --noescape

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agomisc: fix typos [codespell]
Sami Kerola [Thu, 5 Sep 2019 19:38:41 +0000 (20:38 +0100)] 
misc: fix typos [codespell]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agoMerge branch 'sfdisk-man-page-typo' of https://github.com/mkrupcale/util-linux
Karel Zak [Thu, 12 Sep 2019 11:28:55 +0000 (13:28 +0200)] 
Merge branch 'sfdisk-man-page-typo' of https://github.com/mkrupcale/util-linux

* 'sfdisk-man-page-typo' of https://github.com/mkrupcale/util-linux:
  disk-utils: docs: fix sfdisk(8) man page typo

4 years agoblkid: (man) add note about udev to --list-one
Karel Zak [Thu, 12 Sep 2019 11:24:42 +0000 (13:24 +0200)] 
blkid: (man) add note about udev to --list-one

Addresses: https://github.com/karelzak/util-linux/issues/866
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agobuild-sys: check for linux/capability.h
Karel Zak [Thu, 12 Sep 2019 10:45:30 +0000 (12:45 +0200)] 
build-sys: check for linux/capability.h

Addresses: https://github.com/karelzak/util-linux/pull/864
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'unshare/keep-caps' of https://github.com/jpeach/util-linux
Karel Zak [Thu, 12 Sep 2019 10:29:28 +0000 (12:29 +0200)] 
Merge branch 'unshare/keep-caps' of https://github.com/jpeach/util-linux

* 'unshare/keep-caps' of https://github.com/jpeach/util-linux:
  unshare: add --keep-caps option

4 years agodisk-utils: docs: fix sfdisk(8) man page typo
Matthew Krupcale [Tue, 10 Sep 2019 21:05:22 +0000 (17:05 -0400)] 
disk-utils: docs: fix sfdisk(8) man page typo

 * disk-utils/sfdisk.8: fix typo: "ir" -> "it"

4 years agolibfdisk: (gpt) add GUID for APFS containers
Ernesto A. Fernández [Mon, 9 Sep 2019 20:59:07 +0000 (17:59 -0300)] 
libfdisk: (gpt) add GUID for APFS containers

Add the partition type GUID for the Apple File System to gpt_parttypes.

Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@gmail.com>
4 years agosetterm: cleanup usage() and man page
Karel Zak [Tue, 10 Sep 2019 10:14:25 +0000 (12:14 +0200)] 
setterm: cleanup usage() and man page

usage:
 * use --option[=<argument>] to make it obvious that '=' is required
 * don't use [ ] for required arguments
 * add separators to make it more readable

man page
 * use --option=[<argument>] for optional arguments in man page
 * don't use \fI or \fB for keywords based arguments (on|off|default ...)
 * use the same style in all man page

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agosetterm: fix --clear
Karel Zak [Tue, 10 Sep 2019 09:12:38 +0000 (11:12 +0200)] 
setterm: fix --clear

* make argument optional as in the original version
* fix typo (reset -> rest)

Addresses: https://github.com/karelzak/util-linux/issues/861
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agodmesg: do not stop on \0
Karel Zak [Tue, 10 Sep 2019 08:34:01 +0000 (10:34 +0200)] 
dmesg: do not stop on \0

... but I have doubts this change fixes the issue. It seems (on my
system) that \0 is already filtered out by kernel/syslog.

Addresses: https://github.com/karelzak/util-linux/issues/862
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agounshare: add --keep-caps option
James Peach [Thu, 17 Jan 2019 22:16:54 +0000 (14:16 -0800)] 
unshare: add --keep-caps option

Add the --keep-caps option to unshare to preserve capabilities that
are granted when creating a new user namespace. This allows the child
process to retain privilege within the new user namespace without also
being UID 0.

4 years agobash-completion: (unshare) add --map-current-user
Karel Zak [Mon, 9 Sep 2019 10:58:03 +0000 (12:58 +0200)] 
bash-completion: (unshare) add --map-current-user

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agodmesg: add --noescape
Karel Zak [Mon, 9 Sep 2019 10:53:08 +0000 (12:53 +0200)] 
dmesg: add --noescape

We have no way how to print the kernel message buffer in really raw
way. The new option --noescape disables all \x<hex> translations.

Addresses: https://github.com/karelzak/util-linux/issues/858
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'unshare/map-current' of https://github.com/jpeach/util-linux
Karel Zak [Mon, 9 Sep 2019 09:31:04 +0000 (11:31 +0200)] 
Merge branch 'unshare/map-current' of https://github.com/jpeach/util-linux

* 'unshare/map-current' of https://github.com/jpeach/util-linux:
  unshare: add --map-current-user option

4 years agotests: (sfdisk) update move output
Karel Zak [Mon, 9 Sep 2019 09:27:03 +0000 (11:27 +0200)] 
tests: (sfdisk) update move output

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agounshare: add --map-current-user option
James Peach [Thu, 17 Jan 2019 22:17:54 +0000 (14:17 -0800)] 
unshare: add --map-current-user option

Add the --map-current-user option to unshare. This option maps the
current effective UID and GID in the new user namespace so that the
inner and outer credentials match.

Signed-off-by: James Peach <jpeach@apache.org>
4 years agosfdisk: (--move-data) add speed to progress bar, don't use POSIX_FADV_DONTNEED
Karel Zak [Fri, 6 Sep 2019 14:57:40 +0000 (16:57 +0200)] 
sfdisk: (--move-data) add speed to progress bar, don't use POSIX_FADV_DONTNEED

posix_fadvise() in the loop is pretty expensive.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agosfdisk: (--move-data) add simple progress bar
Karel Zak [Fri, 6 Sep 2019 13:05:21 +0000 (15:05 +0200)] 
sfdisk: (--move-data) add simple progress bar

Addresses: https://github.com/karelzak/util-linux/issues/848
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibfdisk: cleanup fdisk_deassign_device() docs
Karel Zak [Fri, 6 Sep 2019 12:32:12 +0000 (14:32 +0200)] 
libfdisk: cleanup fdisk_deassign_device() docs

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agosfdisk: add --move-use-fsync, disable fsync() by default
Karel Zak [Fri, 6 Sep 2019 12:27:42 +0000 (14:27 +0200)] 
sfdisk: add --move-use-fsync, disable fsync() by default

It's slow, so slooow...

Addresses: https://github.com/karelzak/util-linux/issues/848
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agosfdisk: (--move-data) make log optional
Karel Zak [Fri, 6 Sep 2019 12:17:28 +0000 (14:17 +0200)] 
sfdisk: (--move-data) make log optional

The log may be pretty huge and very probably not used by many users.
Let's make it optional.

The patch also clean up move-data output messages.

Addresses: https://github.com/karelzak/util-linux/issues/848
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agosfdisk: (--move-data) keep step size based on optimal I/O
Karel Zak [Fri, 6 Sep 2019 11:53:50 +0000 (13:53 +0200)] 
sfdisk: (--move-data) keep step size based on optimal I/O

The current implementation is too paranoid and tries to keep in
memory only data which are on disk too. It means very small step size
when move partition only a few sectors left/right.

This patch enlarge the buffer to at least 1MiB and aligned to optimal
I/O.

Addresses: https://github.com/karelzak/util-linux/issues/848
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibfdisk: use grain as small as possible
Karel Zak [Fri, 6 Sep 2019 11:09:30 +0000 (13:09 +0200)] 
libfdisk: use grain as small as possible

The current implementation does not allow to move partition for
example in +/-1 sector range, because free space analyze is by default
based on regular grain used for partitioning (=1MiB).

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agosfdisk: make --no-act usable for --move-data too
Karel Zak [Fri, 6 Sep 2019 10:37:26 +0000 (12:37 +0200)] 
sfdisk: make --no-act usable for --move-data too

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'xfs-v5' of https://github.com/mator/util-linux
Karel Zak [Fri, 6 Sep 2019 08:33:45 +0000 (10:33 +0200)] 
Merge branch 'xfs-v5' of https://github.com/mator/util-linux

* 'xfs-v5' of https://github.com/mator/util-linux:
  tests: Add test for current version (v5) of XFS filesystem

4 years agotests: update sfdisk wipe output
Karel Zak [Thu, 5 Sep 2019 14:46:14 +0000 (16:46 +0200)] 
tests: update sfdisk wipe output

- stderr is used for the warning (like in fdisk)

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agofstrim: ignore non-directory mountpoints
Karel Zak [Thu, 5 Sep 2019 14:28:49 +0000 (16:28 +0200)] 
fstrim: ignore non-directory mountpoints

It seems better to silently ignore mount binds on file (= mountpoint
is not a directory).

This patch also fixes use-after-free bug from commit 402006fa6e.

Addresses: https://github.com/karelzak/util-linux/issues/857
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agofdisk: fix quit dialog for non-libreadline version
Karel Zak [Thu, 5 Sep 2019 10:34:01 +0000 (12:34 +0200)] 
fdisk: fix quit dialog for non-libreadline version

We need to clear stdin errors otherwise it returns EOF forever after
CTRL+D.

Reported-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agofdisk: make quit question more usable
Karel Zak [Thu, 5 Sep 2019 10:06:27 +0000 (12:06 +0200)] 
fdisk: make quit question more usable

Reported-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agofdisk: cleanup wipe warning
Karel Zak [Wed, 4 Sep 2019 12:51:02 +0000 (14:51 +0200)] 
fdisk: cleanup wipe warning

Let's remove 'old' from the sentence, add man page reference to
sfdisk.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: Add test for current version (v5) of XFS filesystem
Anatoly Pugachev [Tue, 3 Sep 2019 16:08:22 +0000 (19:08 +0300)] 
tests: Add test for current version (v5) of XFS filesystem

Old xfs.img cannot be used with current version (5.0) of xfsprogs, so create
a new version of xfs-v5.img.

Since I wasn't able to find logs on how was created old xfs.img, saving
create log with this commit message:

$ fallocate -l 16M xfs-v5.img
$ mkfs.xfs -L test-xfs-v5 xfs-v5.img
$ ./blkid -p -o udev xfs-v5.img | sort -V > tests/expected/blkid/low-probe-xfs-v5
$ xz -c xfs-v5.img > tests/ts/blkid/images-fs/xfs-v5.img.xz

Signed-off-by: Anatoly Pugachev <matorola@gmail.com>
4 years agosfdisk: add -J between mutually exclusive options
Karel Zak [Tue, 3 Sep 2019 14:22:21 +0000 (16:22 +0200)] 
sfdisk: add -J between mutually exclusive options

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount: fix typo
Karel Zak [Tue, 3 Sep 2019 14:18:48 +0000 (16:18 +0200)] 
libmount: fix typo

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibblkid: (xfs) fix sector size calculation
Karel Zak [Tue, 3 Sep 2019 13:10:35 +0000 (15:10 +0200)] 
libblkid: (xfs) fix sector size calculation

Reported-by: Anatoly Pugachev <matorola@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agofdisk: add hint about --wipe to warning
Karel Zak [Tue, 3 Sep 2019 09:53:59 +0000 (11:53 +0200)] 
fdisk: add hint about --wipe to warning

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1748020
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agosfdisk: mark --dump and --list-free as mutually exclusive
Karel Zak [Mon, 2 Sep 2019 11:10:44 +0000 (13:10 +0200)] 
sfdisk: mark --dump and --list-free as mutually exclusive

Reported-by: Bertrand Jacquin <bertrand@jacquin.bzh>
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: (blkid) update regression tests (due to BLOCK_SIZE)
Karel Zak [Mon, 2 Sep 2019 10:57:11 +0000 (12:57 +0200)] 
tests: (blkid) update regression tests (due to BLOCK_SIZE)

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoblkid: retport block size of a filesystem
Mikulas Patocka [Mon, 2 Sep 2019 10:28:39 +0000 (12:28 +0200)] 
blkid: retport block size of a filesystem

This patch extends libblkid, so that it reports filesystem block size.

When blkid returns a specific number in the BLOCK_SIZE attribute, it
guarantees that all the bios submitted by the filesystem are aligned on
this boundary.

We need this because when we want to enable dm-integrity or dm-writecache
on an existing filesystem, we need to know filesystem block size, so that
dm-integrity or dm-writecache is initialized with matching block size.

We could always use block size 512 for dm-integrity and dm-writecache, but
that would cause metadata overhead and performance degradation. On the
other hand, if we used block size 4096, it would fail if the filesystem
has smaller blocksize.

[kzak@redhat.com: - move vfat BLOCK_SIZE to probing function
  - remove unwanted debug fprintf from ZFS prober]

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoinclude/closestream: fix assignment to read-only standard streams
Patrick Steinhardt [Thu, 22 Aug 2019 09:40:15 +0000 (11:40 +0200)] 
include/closestream: fix assignment to read-only standard streams

In order to avoid closing standard streams multiple times, commit
52aa1a661 (include/closestream: avoid close more than once, 2019-06-13)
introduced code to set the standard output and error streams to `NULL`.
As musl libc defines standard streams as constant pointers, the change
causes compiler errors on systems with that libc. According to ISO C89,
being able to assign to the standard text streams is not a requirement
for any C implementation, see footnote 238 in chapter §7.19.5.6:

    The primary use of the freopen function is to change the file
    associated with a standard text stream (stderr, stdin, or stdout),
    as those identifiers need not be modifiable lvalues to which the
    value returned by the fopen function may be assigned.

This commit implements a new function `flush_standard_stream` that tries
to reliably flush standard streams without actually closing them. By not
calling fclose(3P), we can neatly avoid the issue of accessing standard
streams in an unspecified state and thus remove the infringing `NULL`
assignments.

Properly flushing standard streams without fclose(3P) proves to be more
intricate than one may expect, though, as some filesystems like NFS may
defer flushing until they see a close(3P) of the underlying descriptor.
One may call fsync(3P) to remedy that, but this may incur a heavy
performance penalty in some scenarios. To work around the issue and
still get proper errors, we duplicate the stream's file descriptor and
close that one instead, which is sufficient to cause a flush.

Note that both `close_stdout` and `close_stdout_atexit` are misnamed
after this change, as we do not actually close the streams now. In order
to avoid unnecessary code churn, we still retain their current names.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
4 years agocolcrt: make seek to \n more robust
Karel Zak [Mon, 2 Sep 2019 09:53:10 +0000 (11:53 +0200)] 
colcrt: make seek to \n more robust

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: (colcrt) use env to set locale
Karel Zak [Fri, 30 Aug 2019 18:45:29 +0000 (20:45 +0200)] 
tests: (colcrt) use env to set locale

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: (getopt) remove unwanted paths from error output
Karel Zak [Fri, 30 Aug 2019 18:35:55 +0000 (20:35 +0200)] 
tests: (getopt) remove unwanted paths from error output

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: remove unbuffered ts_run feature
Karel Zak [Fri, 30 Aug 2019 14:10:48 +0000 (16:10 +0200)] 
tests: remove unbuffered ts_run feature

It's unnecessary as stdout and stderr are split in the tests.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: add remaining stderr outputs
Karel Zak [Fri, 30 Aug 2019 14:10:01 +0000 (16:10 +0200)] 
tests: add remaining stderr outputs

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibdisk: write sample output to stdout
Karel Zak [Fri, 30 Aug 2019 14:05:50 +0000 (16:05 +0200)] 
libdisk: write sample output to stdout

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: split stdout and stderr
Karel Zak [Fri, 30 Aug 2019 13:50:07 +0000 (15:50 +0200)] 
tests: split stdout and stderr

* add $TS_ERRLOG for script stderr output
* add optional $TS_EXPECTED_ERR which points to expected/*/*.err

This change allows to keep track about stderr output from our commands
(already found bug in sfdisk...).

We do not have to depend on fragile stdout vs. stderr order (due to
different buffering semantic in different libc, etc.).

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agosfdisk: write all message to stdout
Karel Zak [Fri, 30 Aug 2019 13:40:06 +0000 (15:40 +0200)] 
sfdisk: write all message to stdout

The code writes message to stdout and \n to stderr.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount; fix and improve read+poll mountinfo
Karel Zak [Thu, 29 Aug 2019 13:50:58 +0000 (15:50 +0200)] 
libmount; fix and improve read+poll mountinfo

* fix read() buffer size (stupid bug...)

* split read() EINTR and poll() based attempts

* use 100 attempts

* wait 10000 usec between attempts, but first 10 attempts are without
  this delay. It makes the function usable for usual use-cases as well
  as on very busy systems (successfully tested with 300 concurrent
  mount/umount processes)

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount: improve mountinfo reliability
Karel Zak [Wed, 28 Aug 2019 13:47:16 +0000 (15:47 +0200)] 
libmount: improve mountinfo reliability

The standard way how we read mount table is not reliable because
during the read() syscalls the table may be modified by some another
process. The changes in the table is possible to detect by poll()
event, and in this case it seems better to lseek to the begin of the file
and read it again. It's expensive, but better than races...

This patch does not modify mountinfo parser, but it reads all file to
memory (by read()+poll()) and than it creates memory stream
from the buffer and use it rather than a regular file stream.

It means the parser is still possible to use for normal files
(e.g. fstab) as well as for mountinfo and it's also portable to
systems where for some reason is no fmemopen().

Note that re-read after poll() event is limited to 5 attempts (but
successful read() without event zeroize the counter). It's because we
do not want to wait for consistent mountinfo for ever. It seems better
to use old (less reliable) way than hang up in read()+poll()
loop.

Addresses: https://github.com/systemd/systemd/issues/10872
Reported-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: use env and support both unbuffer/stdbuf
Patrick Steinhardt [Wed, 28 Aug 2019 06:56:24 +0000 (08:56 +0200)] 
tests: use env and support both unbuffer/stdbuf

Triggered by commit f612c4c67 (tests: fix --unbuffered mode with
ASAN, 2019-08-27), which says:

    Well, this patch sucks. It would be nice to have things in
    the way how it has been original expected by Patrick's patch,
    but ...

So this commit here effectively reverts it and instead tries to
improve the shortcomings of the original patch. First, it uses
env(1) to set ASAN_OPTIONS instead of directly adding it to the
args array to fix execution of "${args[@]}" "$@".

Second, it now supports both unbuffer(1) and stdbuf(1). The
latter uses LD_PRELOAD tricks, which doesn't play nicely with
ASAN, so it will not be used if ASAN has been requested. It's
still valuable to have support for both, as many more systems
will have stdbuf(1) from coreutils installed but not unbuffer(1)
from expect.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: don't show diff for TS_KNOWN_FAIL
Karel Zak [Tue, 27 Aug 2019 12:38:21 +0000 (14:38 +0200)] 
tests: don't show diff for TS_KNOWN_FAIL

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: improve unbuffer check
Karel Zak [Tue, 27 Aug 2019 12:28:11 +0000 (14:28 +0200)] 
tests: improve unbuffer check

* remove obsolete stdbuf check

* check for unbuffer command in ts_run() than skip all test

Reported-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: (fdisk) avoid hardcoding of errno string
Patrick Steinhardt [Fri, 23 Aug 2019 13:32:58 +0000 (15:32 +0200)] 
tests: (fdisk) avoid hardcoding of errno string

The test fdisk/oddinput hardcodes strings returned by strerror(3P) for
both the errors ENOENT and ENOTTY. As these strings are unportable,
convert the tests to use the test_strerror helper instead to convert
them with sed(1).

Signed-off-by: Patrick Steinhardt <ps@pks.im>
4 years agotests: fix --unbuffered mode with ASAN
Karel Zak [Tue, 27 Aug 2019 11:02:38 +0000 (13:02 +0200)] 
tests: fix --unbuffered mode with ASAN

Unfortunately, ASAN is pretty sensitive to LD_PRELOAD, but stdbuf from
coreutils is based on LD_PRELOAD. So, I have replaced stdbuf with
unbuffer (from expect pkg).

The another problem is "${args[@]}" "$@" which does not work as expected.

Well, this patch sucks. It would be nice to have things in the way
how it has been original expected by Patrick's patch, but ...

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch '2019wk33' of https://github.com/kerolasa/util-linux
Karel Zak [Tue, 27 Aug 2019 08:11:02 +0000 (10:11 +0200)] 
Merge branch '2019wk33' of https://github.com/kerolasa/util-linux

* '2019wk33' of https://github.com/kerolasa/util-linux:
  docs: try to find broken man references and fix them
  docs: correct su.1 runuser reference from section 8 to 1
  po: remove possibility to translate static option arguments

4 years agotests: (col) avoid hardcoding of errno string
Patrick Steinhardt [Fri, 23 Aug 2019 13:32:57 +0000 (15:32 +0200)] 
tests: (col) avoid hardcoding of errno string

The col/multibyte test has a hardcoded error string as part of its
expected output that is returned by glibc's strerror(3P) function. Even
though many of these strings are the same across libc implementations,
they are not standardiced and some are certainly different. One example
is the string for EILSEQ on musl libc.

To fix this, we introduce a new test helper "test_strerror". The helper
can be invoked with an error code like "EILSEQ", which will cause it to
print out the the respective error message for that code. Note that
"test_strerror" cannot act on the error's value (e.g. 84 for EILSEQ), as
these aren't standardized either. Instead, we thus need to have an array
of the error's string representation ("EILSEQ") to its respective error
code (the define EILSEQ). The array can trivially be extended as
required, thus it is only sparsely populated with EILSEQ right now.

To fix the col/multibyte test, we introduce a call to sed(1) to replace
the strerror(3P) message from EILSEQ with "EILSEQ". Furthermore, as
we're running tests with the POSIX locale by default which treats all
bytes as valid multibyte sequences, we have to change to the C.UTF-8
locale instead to actually get an error.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
4 years agotests: (column) use actually invalid multibytes to test encoding
Patrick Steinhardt [Fri, 23 Aug 2019 13:32:56 +0000 (15:32 +0200)] 
tests: (column) use actually invalid multibytes to test encoding

If reading an invalid multibyte sequence, column(1) will encode the byte
as "\x<hex>" instead. The tests try to verify that by piping "£" into
column(1). As the tests run with LC_ALL=POSIX by default, though, libc
implementations strictly adhering to the POSIX standard will treat all
characters as valid multibyte characters. As a consequence, no EILSEQ is
raised by mbtowc(3P) and the character is not encoded as hex, breaking
the test.

Fix this by setting LC_ALL=C.UTF-8. As "£" is a valid UTF-8 character,
we also change the test to use a proper illegal multibyte sequence.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
4 years agotests: (colcrt) fix reliance on EILSEQ in POSIX locale
Patrick Steinhardt [Fri, 23 Aug 2019 13:32:55 +0000 (15:32 +0200)] 
tests: (colcrt) fix reliance on EILSEQ in POSIX locale

The input file "crash1" in the colcrt/regressions test contains the
illegal byte sequence "\x94\x7e". While "\x7e" is '~', "\x94" is not a
valid character. Thus, the test assumes that getwc(3P) will return
`WEOF` and set `errno=EILSEQ`, causing colcrt(1) to abort reading the
stream and thus not print the trailing '~'.

This assumption holds just fine for glibc as it will dutifully report
EILSEQ, but musl libc will happily read the complete stream without
complaining about the illegal character. But in fact, as tests run with
LC_ALL=POSIX by default, glibc's behaviour is wrong while musl is right.
Quoting mbrtowc(3P) from POSIX.1-2017:

    [EILSEQ] An invalid character sequence is detected. In the POSIX locale an
             [EILSEQ] error cannot occur since all byte values are valid
             characters.

Fix the issue by running the colcrt tests with C.UTF8 locale.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
4 years agotests: (libfdisk) remove reliance on buffer behaviour of standard streams
Patrick Steinhardt [Fri, 23 Aug 2019 13:32:54 +0000 (15:32 +0200)] 
tests: (libfdisk) remove reliance on buffer behaviour of standard streams

The tests in libfdisk/mkpart-full all rely on the buffering behaviour of
standard output and standard error streams, most importantly that stderr
is non-buffering and stdout is buffering. This doesn't hold on all libc
implementations when redirecting to a file, breaking the test suite on
such platforms.

Use `ts_run --unbuffered` to stop buffering of the standard output
stream to fix this.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
4 years agotests: remove reliance on buffer behaviour of stderr/stdout streams
Patrick Steinhardt [Fri, 23 Aug 2019 13:32:53 +0000 (15:32 +0200)] 
tests: remove reliance on buffer behaviour of stderr/stdout streams

In the test cases "rename::exit_codes" and "rename::exit_codes", we rely
on the flushing behaviour of stderr and stdout streams relative to each
other. Streams in glibc will not flush on newlines if stdout is pointing
to a non-TTY file descriptor, but relying on this is fragile and may
break on systems with a different behaviour like musl libc.

Fix this by introducing a new parameter "--unbuffered" to `ts_run`. If
this parameter is passed and stdbuf(1) from coreutils is available, then
it will use it to disable buffering of standard output completely. Like
this, we can selectively run tests with this if ordering of messages
from stdout and stderr is being checked.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
x