We do not need to provide details in the default output. It seems
better to hide it behind --verbose to be user-friendly.
Signed-off-by: Karel Zak <kzak@redhat.com>
Option --follow-new (-W) works the same as --follow (-w) but initially
seeks to the end of kernel ring buffer, so it prints only new messages.
Useful for capturing kernel messages during actions without past log.
Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
This new option works like --all but it allows to specify multiple
files with filesystems to make fstrim configuration more portable
between distributions. For example:
fstrim --listed-in /etc/fstab:/proc/self/mountinfo
forces fstrim to try fstab and if unsuccessful than try mountinfo.
Addresses: https://github.com/karelzak/util-linux/issues/1019
Signed-off-by: Karel Zak <kzak@redhat.com>
This patch brings support for automatic dangerous shell characters
escape in umount autocompletion. Due to the very peculiar way for
bash to handle autocompletion routines, proper escaping of the shell
sequences only worked properly inside a function: _umount_point_list,
which will add to the user's namespace at the next umount attempt of
autocompleting mount point.
It also translates calls of gensub to the portable alternatives sub
and gsub, in order to allow the use of various awk implementations
(mawk, Gnu, Busybox, etc), and as such kind of undoes a recent change
to enforce the use of Gnu awk. The whole story landed into the Debian
BTS initially:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=933934
PS: It's been a few months since the patch is available, sorry for the
delay; I only got myself a Github account quite recently...
Signed-off-by: Étienne Mollier <etienne.mollier@mailoo.org>
gensub() is a gawk extension, so use it explicitly. Otherwise users will
get an error if their 'awk' defaults to something else.
Fixes: 3ebfc8d37 ("bash-completion: umount support relative path and ~ as home shorthands")
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
This commit also includes fix to how initial skip lines and search are
instructed in the code. Earlier version was pretty close impossible to make
work with getopt_long() and had minor flaw - if both initial skip lines and
search were defined at the same time the skipping did not happen. That is
now corrected.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* '2020wk12' of https://github.com/kerolasa/util-linux:
lslogins: use lastlog as wtmp fallback
login: avoid lseek() with pread() and pwrite()
libuuid: ensure variable is initialized [cppcheck]
ctrlaltdel: display error message indicated by errno
We use --verbose together with --quite in service files. It seems
confusing, let's make the option more descriptive.
Addresses: https://github.com/karelzak/util-linux/issues/1001
Signed-off-by: Karel Zak <kzak@redhat.com>
The wtmp file tends to rotate higher rate than lastlog, so use the later as
fallback in when wtmp tells nothing in LAST-LOGIN column.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This adds support to unshare for time namespaces. With the newly added
options '-t, --time' and '--monotonic' and '--boottime' it is now
possible to change CLOCK_MONOTONIC and CLOCK_BOOTTIME in a new time
namespace.
The time namespace has been merged in kernel version 5.6 and an easy way
to test it is using CLOCK_BOOTTIME and the uptime command:
# uptime
11:08:26 up 20:28, 1 user, load average: 0.00, 0.00, 0.00
# ./unshare --fork --time --boottime 100000000 uptime
11:08:29 up 1158 days, 6:15, 1 user, load average: 0.00, 0.00, 0.00
Signed-off-by: Adrian Reber <areber@redhat.com>
This commit add total and delta as separate columns rather than a toggle,
making output generally more informative. When using command I found that
sort order key bindings should match with first letter of column headers so
that they are as easy as possible to remember, and therefore enhancing user
experience.
Requested-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
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>
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>
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>
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>
The no follow option will allow user to distinct mount points from symbolic
links pointing to them. Arguably this is pretty pedantic option, mounting a
device or bind mount to a directory via symlink does not have or cause any
issues.
Addresses: https://github.com/karelzak/util-linux/issues/832
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This patch introduces two new parameters to set the
user ID and the group ID of the program to be executed.
Setting group ID also drops supplementary groups.
The option names used are the same as for nsenter,
-S, --setuid and -G, --setgid.
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
This patch instroduces two new parameters to set the new
root and the new working directory in this new root.
This allows to combine "unshare chroot" in one command,
and doing like this the /proc filesystem is correctly
mounted in the new root with "--mount-proc".
The new parameters are -R, --root and -w, --wd. The names
are the same as for nsenter, except for "-r" that is already
used by "--map-root-user" and replaced by "-R".
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Check what has changed in usage functions in between v2.32..a77bd80d5 and
update bash-completion files accordingly.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
When script is used on a host with a relatively small free disk space, it
is sometimes desirable to limit the size of the captured output. This
can now be enforced with the --output-limit option.
The --output-limit option lets the user specify a maximum size. The program
uses the size parsing from strutils and thus supports the usual
multiplicative suffixes (kiB, KB, MiB, MB, etc.). After the specified
number of bytes have been written to the output file, the script program
will terminate the child process.
Due to buffering, the size of the output file might exceed the specified
limit. This limit also does not include the start and done messages.
The race test was throwing an error dur to a variable being "" in some cases.
Quoting the variable in the equal test took care of that test.
[kzak@redhat.com: - use done() to stop script
- count also timing file
- remove unnamed member initialization in ctl struct
- add to bash-completion]
Signed-off-by: Fred Mora <fmora@datto.com>
Signed-off-by: Karel Zak <kzak@redhat.com>