Commit Graph

13647 Commits

Author SHA1 Message Date
Kevin Locke 559888c873 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>
2019-09-19 07:27:31 -06:00
Karel Zak d978ec31f7 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]
2019-09-16 12:38:43 +02:00
Karel Zak c50d77e6a3 tests: update sfdisk dumps
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-16 12:01:54 +02:00
Karel Zak e56ca06815 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>
2019-09-16 10:29:41 +02:00
Sami Kerola e79f20f57d
bash-completion: update options
unshare: cef4decf04 --keep-caps
dmesg:   646bba41fd --noescape

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-09-12 19:49:51 +01:00
Sami Kerola 218b1dd6f9
misc: fix typos [codespell]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-09-12 19:41:46 +01:00
Karel Zak 9245c84dfd 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
2019-09-12 13:28:55 +02:00
Karel Zak bce4a17b01 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>
2019-09-12 13:24:42 +02:00
Karel Zak 2c2ff2ed26 build-sys: check for linux/capability.h
Addresses: https://github.com/karelzak/util-linux/pull/864
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-12 12:45:50 +02:00
Karel Zak 8434a362c9 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
2019-09-12 12:29:28 +02:00
Matthew Krupcale c7a3455c12 disk-utils: docs: fix sfdisk(8) man page typo
* disk-utils/sfdisk.8: fix typo: "ir" -> "it"
2019-09-10 17:05:22 -04:00
Ernesto A. Fernández b221b9a9d7 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>
2019-09-10 12:40:32 +02:00
Karel Zak bc6439ba32 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>
2019-09-10 12:14:25 +02:00
Karel Zak 36ce5ebaf4 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>
2019-09-10 11:12:38 +02:00
Karel Zak fd7b0b4e54 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>
2019-09-10 10:34:01 +02:00
James Peach cef4decf04 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.
2019-09-09 20:23:08 -07:00
Karel Zak a1790d265d bash-completion: (unshare) add --map-current-user
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-09 12:58:03 +02:00
Karel Zak 646bba41fd 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>
2019-09-09 12:56:53 +02:00
Karel Zak a6cc5c16f4 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
2019-09-09 11:31:04 +02:00
Karel Zak b008e4d668 tests: (sfdisk) update move output
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-09 11:27:03 +02:00
James Peach 4175f29e62 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>
2019-09-08 15:00:00 -07:00
Karel Zak 925f2d4f4f 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>
2019-09-06 16:57:40 +02:00
Karel Zak 4bf424188d sfdisk: (--move-data) add simple progress bar
Addresses: https://github.com/karelzak/util-linux/issues/848
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-06 15:07:59 +02:00
Karel Zak e4e0b1a6f0 libfdisk: cleanup fdisk_deassign_device() docs
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-06 15:07:43 +02:00
Karel Zak 7942ba8a79 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>
2019-09-06 15:07:43 +02:00
Karel Zak 69f30c3126 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>
2019-09-06 15:07:30 +02:00
Karel Zak 4ce4675cce 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>
2019-09-06 15:05:59 +02:00
Karel Zak 1116884cf7 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>
2019-09-06 13:09:30 +02:00
Karel Zak 45aaa8f3db sfdisk: make --no-act usable for --move-data too
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-06 12:37:26 +02:00
Karel Zak 492a5c70b4 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
2019-09-06 10:33:45 +02:00
Karel Zak 91099dea35 tests: update sfdisk wipe output
- stderr is used for the warning (like in fdisk)

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-05 16:46:14 +02:00
Karel Zak f227757c77 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>
2019-09-05 16:32:10 +02:00
Karel Zak 40af0db4cd 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>
2019-09-05 12:34:01 +02:00
Karel Zak fff85eb577 fdisk: make quit question more usable
Reported-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-05 12:06:27 +02:00
Karel Zak 6cd671d427 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>
2019-09-04 14:54:54 +02:00
Anatoly Pugachev 037bc610e5 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>
2019-09-03 19:08:22 +03:00
Karel Zak 03154d2cf2 sfdisk: add -J between mutually exclusive options
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-03 16:22:21 +02:00
Karel Zak 987ec2a696 libmount: fix typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-03 16:18:48 +02:00
Karel Zak 2771d40b88 libblkid: (xfs) fix sector size calculation
Reported-by: Anatoly Pugachev <matorola@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-03 15:10:35 +02:00
Karel Zak ce16f04efa 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>
2019-09-03 11:57:23 +02:00
Karel Zak eabcbfc449 sfdisk: mark --dump and --list-free as mutually exclusive
Reported-by: Bertrand Jacquin <bertrand@jacquin.bzh>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-02 13:10:44 +02:00
Karel Zak e7d318a9dd tests: (blkid) update regression tests (due to BLOCK_SIZE)
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-02 12:57:11 +02:00
Mikulas Patocka cd129b7d2f 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>
2019-09-02 12:55:53 +02:00
Patrick Steinhardt 530220b6bf 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>
2019-09-02 11:55:56 +02:00
Karel Zak d356507207 colcrt: make seek to \n more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-02 11:53:10 +02:00
Karel Zak 50c77b6afe tests: (colcrt) use env to set locale
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-30 20:46:58 +02:00
Karel Zak e3803ff869 tests: (getopt) remove unwanted paths from error output
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-30 20:46:44 +02:00
Karel Zak eb61e95f1c 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>
2019-08-30 16:30:35 +02:00
Karel Zak 18c1f9e643 tests: add remaining stderr outputs
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-30 16:10:01 +02:00
Karel Zak b161f810b0 libdisk: write sample output to stdout
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-08-30 16:05:50 +02:00