]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
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 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

4 years agosys-utils/manuals: Make the number of the paired macros ".RS" and ".RE" equal
Bjarni Ingi Gislason [Mon, 26 Aug 2019 19:05:01 +0000 (19:05 +0000)] 
sys-utils/manuals: Make the number of the paired macros ".RS" and ".RE" equal

  Adjust the number of the macros ".RS" and ".RE" to be equal.

  There is no change in the formatted output.

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
4 years agodocs: try to find broken man references and fix them
Sami Kerola [Sat, 24 Aug 2019 21:34:16 +0000 (22:34 +0100)] 
docs: try to find broken man references and fix them

Unfortunately methods I used to find and fix were based on quite manual
process that cannot be easily repeated so I do not see how this fix could be
turned into a tools/checkmans.sh addition.  Well, lets hope doing this
manually twice every decade is good enough.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agodocs: correct su.1 runuser reference from section 8 to 1
Sami Kerola [Wed, 21 Aug 2019 20:18:21 +0000 (21:18 +0100)] 
docs: correct su.1 runuser reference from section 8 to 1

Addresses: https://bugs.debian.org/929677
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agopo: remove possibility to translate static option arguments
Sami Kerola [Wed, 21 Aug 2019 19:25:31 +0000 (20:25 +0100)] 
po: remove possibility to translate static option arguments

These strings are expected to be wrote exactly as they are parsed, so make
translating them impossible.  Since mkfs.cramfs -N option arguments need
this treatment use opportunity to slice usage() output to multiple lines.

Addresses: https://bugs.debian.org/907568
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agoMerge branch 'fix-ger-translation-chrt-help' of https://github.com/Thermi/util-linux
Karel Zak [Fri, 23 Aug 2019 10:32:06 +0000 (12:32 +0200)] 
Merge branch 'fix-ger-translation-chrt-help' of https://github.com/Thermi/util-linux

* 'fix-ger-translation-chrt-help' of https://github.com/Thermi/util-linux:
  Fix -n to -b in German help message

4 years agolibfidk: (dos) fix tiny partitions calculation
Karel Zak [Thu, 22 Aug 2019 12:00:32 +0000 (14:00 +0200)] 
libfidk: (dos) fix tiny partitions calculation

The code uses last_sector -= 1 for tiny partitions. This does not make
sense. This stupidity has been introduced by (my) badly commented commit
09a4ca5e450c5e7cbe860453b76fd68c60fe591f ... sorry.

Fortunately, this issue is visible only for tiny partitions on large
devices (partitions where size < grain; usual grain is 1MiB) if the last
sector is specified by relative notation (+size{siffix}).

Note that "last -= 1" makes sense when the "last" is align to the
optimal I/O boundary; in this case we need to set the end of the
partition one sector before the boundary. For tiny devices it does not
makes sense as we do not align these partitions.

Addresses: https://github.com/karelzak/util-linux/issues/843
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoeject: use O_EXCL on default
Karel Zak [Thu, 22 Aug 2019 11:05:06 +0000 (13:05 +0200)] 
eject: use O_EXCL on default

* by default we assume all is umounted; so O_EXCL is no problem,
  otherwise there is bug or race (someone else remounted the device)...

* --force and --no-umount disable O_EXCL

Addresses: https://github.com/karelzak/util-linux/issues/423
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoFix -n to -b in German help message
Noel Kuntze [Thu, 22 Aug 2019 07:02:49 +0000 (09:02 +0200)] 
Fix -n to -b in German help message

4 years agoinclude/xalloc: reindent function bodies to unify indentation
Sami Kerola [Sun, 18 Aug 2019 10:11:00 +0000 (11:11 +0100)] 
include/xalloc: reindent function bodies to unify indentation

The file used unusual 7 spaces indent step in some of the functions.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agoinclude/xalloc: use multiline function declarations
Sami Kerola [Sun, 18 Aug 2019 10:03:44 +0000 (11:03 +0100)] 
include/xalloc: use multiline function declarations

There are two things happening in this commit.  1) Move each function
attribute to it's own line 2) move function return value after attributes so
that function inputs and outputs are on same line.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agosetpwnam: use more appropriate allocation size types
Sami Kerola [Sun, 18 Aug 2019 09:29:32 +0000 (10:29 +0100)] 
setpwnam: use more appropriate allocation size types

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agocolumn: pass control struct to local_wcstok()
Sami Kerola [Sat, 17 Aug 2019 20:05:39 +0000 (21:05 +0100)] 
column: pass control struct to local_wcstok()

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agoMerge branch 'container' of https://github.com/slashdd/util-linux
Karel Zak [Wed, 21 Aug 2019 12:37:26 +0000 (14:37 +0200)] 
Merge branch 'container' of https://github.com/slashdd/util-linux

* 'container' of https://github.com/slashdd/util-linux:
  fstrim shouldn't run inside a container

4 years agopartx: document -d vs. --nr and fix test
Karel Zak [Wed, 21 Aug 2019 11:42:22 +0000 (13:42 +0200)] 
partx: document -d vs. --nr and fix test

The commit ab025087f91b66ee8e23a16bc49eb0d9bd421d65 has disabled error
message, but unfortunately it keeps wrong return code. This has been fixed
by commit 53ae7d60cfeacd4e87bfe6fcc015b58b78ef4555.

This commit add hit about it to docs and fix regression test too.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agopartx: don't report ENXIO as error on -d
Karel Zak [Wed, 21 Aug 2019 08:51:18 +0000 (10:51 +0200)] 
partx: don't report ENXIO as error on -d

The errno ENXIO should be ignored, unfortunately the current code uses
variable 'rc' for ioctl return code as well as for final del_parts()
return value. So, failed ioctl (which should be ignored) affects all
del_parts() status.

  # modprobe scsi_debug dev_size_mb=100
  # partx  -d --nr 1-1024 /dev/sdc; echo $?
  1

The device dos not contains any partitions, so 0 return code is
expected in this case.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1739179
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount: fix comment referring to passno field
Patrick Steinhardt [Thu, 15 Aug 2019 10:50:05 +0000 (12:50 +0200)] 
libmount: fix comment referring to passno field

There's an obvious copy-paste error in `mnt_parse_table_line` when
referring to the 6th field of the fstab format, where it says "freq"
instead of "passno". This has probably been copied from the 5th field,
which is in fact correctly labelled as "freq".

Fix the mistake by changing the comment to say "passno" instead.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
4 years agowdctl: remove duplicate include of <unistd.h>
Patrick Steinhardt [Thu, 15 Aug 2019 12:03:23 +0000 (14:03 +0200)] 
wdctl: remove duplicate include of <unistd.h>

The <unistd.h> header is included twice in "wdctl.c". Remove one
of these includes to keep "make checkincludes" happy.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
4 years agolibmount: Keep the mnt_tab info for the existent dest in mnt_copy_fs()
Kevin Hao [Mon, 19 Aug 2019 08:30:22 +0000 (16:30 +0800)] 
libmount: Keep the mnt_tab info for the existent dest in mnt_copy_fs()

The "umount -f -a -r" get stuck in a endless loop when run with a
mountinfo like below:
  15 0 179:2 / / ro,relatime - ext4 /dev/root ro
  16 15 0:6 / /dev rw,relatime - devtmpfs devtmpfs rw,size=242896k,nr_inodes=60724,mode=755
  17 15 0:4 / /proc rw,relatime - proc proc rw
  18 15 0:15 / /mnt/.psplash rw,relatime - tmpfs tmpfs rw,size=40k
  19 15 0:16 / /sys rw,relatime - sysfs sysfs rw
  20 19 0:7 / /sys/kernel/debug rw,relatime - debugfs debugfs rw
  21 15 0:17 / /run rw,nosuid,nodev - tmpfs tmpfs rw,mode=755
  22 15 0:18 / /var/volatile rw,relatime - tmpfs tmpfs rw
  23 15 179:1 / /boot rw,relatime - vfat /dev/mmcblk0p1 rw,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro
  24 16 0:19 / /dev/pts rw,relatime - devpts devpts rw,gid=5,mode=620,ptmxmode=000
  25 18 0:20 / /mnt/.psplash rw,relatime - tmpfs tmpfs rw,size=40k

The reason is that the two same mnt entry "/mnt/.psplash" will cause
the dst->tab set to NULL when umount this mnt entry the second time.
This will trigger an endless loop in mnt_reset_table() because that
mnt entry is linked on the libmnt_table but its .tab is set to NULL.

Signed-off-by: Kevin Hao <kexin.hao@windriver.com>
4 years agotests: Skip fdisk/mbr-nondos-mode on Sparc as unsupported
Karel Zak [Mon, 19 Aug 2019 12:28:50 +0000 (14:28 +0200)] 
tests: Skip fdisk/mbr-nondos-mode on Sparc as unsupported

The test has been originally designed as usable on sparc, but now we
use it for many features which are MBR specific.

Reported-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Co-Author: Anatoly Pugachev <matorola@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agochfn: don't append extra tailing commas
Karel Zak [Mon, 19 Aug 2019 12:03:07 +0000 (14:03 +0200)] 
chfn: don't append extra tailing commas

 # grep kzak /etc/passwd
 kzak:x:1000:1000::/home/kzak:/bin/bash

 # chfn kzak
 ...
 grep kzak /etc/passwd

old version:
 kzak:x:1000:1000:Karel Zak,,,,:/home/kzak:/bin/bash

fixed version:
 kzak:x:1000:1000:Karel Zak:/home/kzak:/bin/bash

Reported-by: Filip Dvorak <fdvorak@redhat.com>
References: f723cbf544a7eac2927634f2cb6d802437a2d519
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agofstrim shouldn't run inside a container
Eric Desrochers [Wed, 14 Aug 2019 16:58:39 +0000 (12:58 -0400)] 
fstrim shouldn't run inside a container

Container type implies the following products:
openvz OpenVZ/Virtuozzo
lxc Linux container implementation by LXC
lxc-libvirt Linux container implementation by libvirt
systemd-nspawn systemd's minimal container implementation, see systemd-nspawn(1)
docker Docker container manager
podman Podman container manager
rkt rkt app container runtime
wsl Windows Subsystem for Linux

References:
https://www.freedesktop.org/software/systemd/man/systemd.unit.html
https://www.freedesktop.org/software/systemd/man/systemd-detect-virt.html#

Fix: #840

Signed-off-by: Eric Desrochers <eric.desrochers@canonical.com>
4 years agoRemove unused utime.h header
Rosen Penev [Thu, 8 Aug 2019 19:14:39 +0000 (12:14 -0700)] 
Remove unused utime.h header

It is sometimes unavailable and errors on inclusion. For example, when
disabled in uClibc-ng.

4 years agoRemove isascii usage
Rosen Penev [Thu, 8 Aug 2019 19:12:55 +0000 (12:12 -0700)] 
Remove isascii usage

There is a c_isascii function that can be used.

isascii is deprecated and not available with some libcs like uClibc-ng
where it can be compile time disabled.

4 years agotests: update fdisk output
Karel Zak [Thu, 8 Aug 2019 12:20:05 +0000 (14:20 +0200)] 
tests: update fdisk output

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibfdisk: (script) support shortcuts in the type= field
Karel Zak [Thu, 8 Aug 2019 08:34:27 +0000 (10:34 +0200)] 
libfdisk: (script) support shortcuts in the type= field

The unnamed-field format supports partition type shortcuts:

",1MiB,L'

but for named-field format it requires full type:

 (mbr) "size=1MiB,type=83"
 (gpt)  "size=1MiB,type=0FC63DAF-8483-4772-8E79-3D69D8477DE4"

This patch implements type shortcuts also for named-field format:

"size=1MiB,type=L"

to make it more user-friendly and unified.

Addresses: https://github.com/karelzak/util-linux/issues/837
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: use subtests for mountpoint(1)
Karel Zak [Wed, 7 Aug 2019 09:45:57 +0000 (11:45 +0200)] 
tests: use subtests for mountpoint(1)

Signed-off-by: Karel Zak <kzak@redhat.com>