Commit Graph

13690 Commits

Author SHA1 Message Date
Karel Zak c64963f87c script: cleanup usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-08 13:11:53 +02:00
Karel Zak 9f82264851 script: allow to use the same log for more streams
The plan (for the next commits) is to use for example timing file for
stdin as well as for stdout.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-08 13:11:53 +02:00
Karel Zak d805688afc script: report also timing file, do it only once
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-08 13:11:53 +02:00
Karel Zak 4f7521d66c script: make optional argument more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-08 13:11:53 +02:00
Karel Zak 596f42027d script: log file usage refactoring
This commit does not add any new feature. It just prepare code for
future extensions only.

* introduce two new structs: script_stream and script_log
* define two streams: 'stdout' and 'stdin'
* allow associate log files (type script or timing file) with the stream
* support more log file formats

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-08 13:11:53 +02:00
Karel Zak b3fc2a3c33 hwclock: report rtc open() errors on --verbose
Let's be more verbose and provide real open() error to make
debugging easier on --verbose.

For example:

$ hwclock --verbose
hwclock from util-linux 2.34.193-6bebea-dirty
System Time: 1570445823.701266
Trying to open: /dev/rtc0
hwclock: cannot open /dev/rtc0: Permission denied          <---
No usable clock interface found.
hwclock: Cannot access the Hardware Clock via any known method.

Addresses: https://github.com/karelzak/util-linux/issues/879
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-10-07 12:57:43 +02:00
Karel Zak 6bebea1b13 Merge branch 'for-upstream/more-pseudofs' of https://github.com/dlitz/util-linux
* 'for-upstream/more-pseudofs' of https://github.com/dlitz/util-linux:
  libmount: Recognize more FUSE pseudofs (avfsd, lxcfs, vmware-vmblock)
2019-10-07 12:41:32 +02:00
Jan Chren (rindeal) a7f9588745 po/update-potfiles: fallback to `find` when git doesn't work
It allows to run po/update-potfiles not only in tarballs
and git repositories, but in git snapshots as well.
2019-10-04 16:40:49 +02:00
Darsey Litzenberger e7305e4ea3 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>
2019-10-02 17:29:05 -07:00
Karel Zak 7b41ae5b4e 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>
2019-10-01 13:17:03 +02:00
Elliott Mitchell 2bb3aa36b2 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>
2019-10-01 13:01:43 +02:00
Karel Zak 1d84470388 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>
2019-10-01 12:51:04 +02:00
Elliott Mitchell eb913f6b98 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>
2019-10-01 12:04:02 +02:00
Karel Zak 5c1c594ee5 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>
2019-09-30 13:11:17 +02:00
Karel Zak 980a25f9c4 sfdisk: (move-data) improve MiB/s progress bar
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-30 12:25:17 +02:00
Karel Zak 52a1f767c0 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
2019-09-30 11:15:57 +02:00
Karel Zak 8e4d8767fd 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.
2019-09-30 11:12:35 +02:00
Karel Zak 1c07615932 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
2019-09-30 11:06:09 +02:00
Andrius Štikonas 2ebc944fa4 docs: fix mixtyped constant.
Signed-off-by: Andrius Štikonas <andrius@stikonas.eu>
2019-09-26 15:55:48 +02:00
Quentin Rameau 83db544dda chsh: replace getpw unsafe functions with xgetpw 2019-09-26 15:55:41 +02:00
Quentin Rameau cd083615b4 lib/pwdutils: add xgetpwuid 2019-09-26 15:55:39 +02:00
Karel Zak 135e03892b sfdisk: (man) add note about interactive mode)
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-26 15:20:47 +02:00
Daniel Drake 7ef86a0891 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>
2019-09-25 11:41:30 +08:00
Anatoly Pugachev 616f57d949 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>
2019-09-24 18:15:33 +03:00
Karel Zak 775022bdd7 Merge branch 'next' of https://github.com/rskvaril/util-linux
* 'next' of https://github.com/rskvaril/util-linux:
  tests: lscpu s390 nested virtualization
2019-09-22 14:05:18 +02:00
Radka Skvarilova 2062164894 tests: lscpu s390 nested virtualization
Signed-off-by: Radka Skvarilova <rskvaril@redhat.com>
Addresses:https://bugzilla.redhat.com/show_bug.cgi?id=1739443
2019-09-22 13:49:45 +02:00
Karel Zak 55ff4da890 docs: update howto-tests.txt
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-22 13:39:40 +02:00
Karel Zak bc747dfccf libmount: fix free() call on error
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-21 11:16:34 +02:00
Karel Zak dc626a7586 hexdump: add header file guards [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-20 16:13:52 +02:00
Karel Zak 0f60f643a9 term-utils: add header file guards [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-20 16:12:34 +02:00
Karel Zak b04f7d0e01 login-utils: add header file guards [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-20 16:10:43 +02:00
Karel Zak e0bea4dfa8 libuuid: add header file guard [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-20 16:06:00 +02:00
Karel Zak b2ce7d5827 include/all-io: remove unnecessary condition [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-20 16:00:13 +02:00
Karel Zak 8e76d28dbd fsfreeze: remove unnecessary condition [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-20 15:57:31 +02:00
Karel Zak 351de28ae6 libblkid: remove unnecessary condition [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-20 15:52:34 +02:00
Karel Zak a6a24f18e6 mkswap: cast before lseek [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-20 15:47:55 +02:00
Karel Zak c135625734 fdformat: cast before lseek [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-20 15:45:15 +02:00
Karel Zak e3cabf33e5 libfdisk: (bsd) cast before ask [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-20 15:43:12 +02:00
Karel Zak 2815af9ed4 libfdisk: (gpt) cast number of entries [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-20 15:40:14 +02:00
Karel Zak 7618b3be4b build-sys: fix UTIL_LINUX_PT_SGI_H macro [lgtm scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-20 15:31:31 +02:00
Karel Zak 026f7d3020 libmount: use fmemopen() in more robust way [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-09-20 13:00:19 +02:00
Kevin Locke 0c8865f843 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>
2019-09-19 08:17:09 -06:00
Kevin Locke 6ead91ce1e 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>
2019-09-19 08:16:32 -06:00
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