Karel Zak [Tue, 30 Jul 2019 12:32:13 +0000 (14:32 +0200)]
scriptlive: run shell in PTY
After this change shell executed by scriptlive(1) is going to behave
like shell in script(1). It means that the shell stdin is a
pseudo-terminal rather than pipe. This allows live replay of
interactive applications, ssh sessions, etc.
Karel Zak [Tue, 2 Jul 2019 15:03:53 +0000 (17:03 +0200)]
scriptlive: add new command to re-execute script(1) typescript
The old good scriptreplay(1) just display your recorded session, the
scriptlive(1) uses stdin typescript (from new script(1)) to execute
your commands again.
Karel Zak [Thu, 20 Jun 2019 11:08:00 +0000 (13:08 +0200)]
scriptreplay: add --cr-mode
The stdin log does not contain line breaks as command line uses CR
between commands. This makes scriptreplay for stdin very
user-unfriendly, because it overwrites still the same line.
The new option --cr-mode provides opportunity to control this
behavior. The default for stdin logs is replace CR with line-break.
Karel Zak [Fri, 12 Apr 2019 14:27:54 +0000 (16:27 +0200)]
script: support multi-stream logging
* allow to use --log-in <infile> and --log-out <outfile> in the same time
* add --log-io <file> to log stdout and stdin to the one log file
* introduce a new timing file format with entry type identifirs
I <delay> <size> : info about input stream
O <delay> <size> : info about output stream
in the next commits it's possible to add 'S' for signals and 'H' for
extra (header) information.
* the new file format is optional and enabled only if multiple streams
logging is requested.
Karel Zak [Fri, 12 Apr 2019 10:47:03 +0000 (12:47 +0200)]
script: add option --log-timing
The current -t[=<file>] is pretty messy due to optional <file>
argument; and default is to output to stderr. The default output to
stderr is very unusual semantic. This path makes the old -t
deprecated.
The new option -T, --log-timing requires the file name.
Karel Zak [Wed, 3 Apr 2019 14:32:41 +0000 (16:32 +0200)]
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
Karel Zak [Mon, 7 Oct 2019 10:57:43 +0000 (12:57 +0200)]
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>
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.
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>
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.
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).
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
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.
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]
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.