]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
2 years agoci: (codeql) ignore cpp/uncontrolled-process-operation
Thomas Weißschuh [Thu, 27 Jul 2023 05:21:02 +0000 (07:21 +0200)] 
ci: (codeql) ignore cpp/uncontrolled-process-operation

In the context of util-linux these are mostly false positives.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agochrt: allow option separator
Thomas Weißschuh [Wed, 26 Jul 2023 14:33:09 +0000 (16:33 +0200)] 
chrt: allow option separator

Allow the option separator "--".
It works in other, similar tools like nice and ionice.

Example:

chrt 1 -- id

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agochrt: (tests) don't mark tests as known failed
Thomas Weißschuh [Wed, 26 Jul 2023 14:33:05 +0000 (16:33 +0200)] 
chrt: (tests) don't mark tests as known failed

The broken CI platform is not used anymore.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agochrt: (tests) increase deadline test parameters
Thomas Weißschuh [Wed, 26 Jul 2023 14:32:59 +0000 (16:32 +0200)] 
chrt: (tests) increase deadline test parameters

Since kernel commit
b4098bfc5efb ("sched/deadline: Impose global limits on sched_attr::sched_period")
the value for dl_period has a lower bound of 100us.
Adjust the test parameters so the test can work on newer kernels.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolosetup: add --loop-ref and REF column
Karel Zak [Thu, 16 Mar 2023 12:41:36 +0000 (13:41 +0100)] 
losetup: add --loop-ref and REF column

The lo_file_name is nowhere used (kernel uses backing file descriptor,
no path) and it was used to store limited info about the backing file path
(64 bytes only!). For backward compatibility, we still fill lo_file_name
with the path, but it's nowhere in the userspace used as the complete
backing file path in sysfs.

This commit introduces a new option to overwrite the default path in
lo_file_name. The idea is to use the reference string by udevd in
/dev/loop/by-ref to address loop devices independently on paths.

Addresses: https://github.com/util-linux/util-linux/issues/2106
Suggested-by: Lennart Poettering <lennart@poettering.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolibmount: use some MS_* flags as superblock flags
Karel Zak [Thu, 20 Jul 2023 10:34:14 +0000 (12:34 +0200)] 
libmount: use some MS_* flags as superblock flags

The old mount(2) API usually utilizes MS_* flags to set up the VFS
node. However, there are some exceptions like "sync" (MS_SYNCHRONOUS),
where the flag is used (by kernel) for the superblock instead. The new
API addresses this issue, ensuring that these options are used for
fsconfig().

This commit introduces MNT_SUPERBLOCK to identify these options in the
libmount options Linux map, and it enforces the new mount code to
utilize these options for fsconfig(FSCONFIG_SET_FLAG).

Reported-by: Abbink Esger <esger.abbink.ext@siemens.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoMerge branch 'libsmartcols/noheading-width' of https://github.com/t-8ch/util-linux
Karel Zak [Tue, 18 Jul 2023 08:13:09 +0000 (10:13 +0200)] 
Merge branch 'libsmartcols/noheading-width' of https://github.com/t-8ch/util-linux

* 'libsmartcols/noheading-width' of https://github.com/t-8ch/util-linux:
  libsmartcols: don't include hidden headers in column width calculation
  lsfd: avoid passing NULL to qsort()
  column: fix memory leak

2 years agoMerge branch 'wip/rishi/libmount-handle-failure-to-apply-flags-as-part-of-mount'...
Karel Zak [Tue, 18 Jul 2023 08:05:03 +0000 (10:05 +0200)] 
Merge branch 'wip/rishi/libmount-handle-failure-to-apply-flags-as-part-of-mount' of https://github.com/debarshiray/util-linux

* 'wip/rishi/libmount-handle-failure-to-apply-flags-as-part-of-mount' of https://github.com/debarshiray/util-linux:
  libmount: handle failure to apply flags as part of a mount operation

2 years agoMerge branch 'lsfd--revise-help-message' of https://github.com/masatake/util-linux
Karel Zak [Tue, 18 Jul 2023 08:03:35 +0000 (10:03 +0200)] 
Merge branch 'lsfd--revise-help-message' of https://github.com/masatake/util-linux

* 'lsfd--revise-help-message' of https://github.com/masatake/util-linux:
  lsfd: show default columns in the help message
  lsfd: update the help message for XMODE column
  lsfd: introduce -H, --list-columns option for making help messages short
  lsfd: (man) fix the form for the optional argument of --inet option
  lsfd: rearrange the aligment of the help messages
  lsfd: use the specified output stream for printing help messages

2 years agoMerge branch 'ci/codeql-path-injection' of https://github.com/t-8ch/util-linux
Karel Zak [Tue, 18 Jul 2023 08:02:52 +0000 (10:02 +0200)] 
Merge branch 'ci/codeql-path-injection' of https://github.com/t-8ch/util-linux

* 'ci/codeql-path-injection' of https://github.com/t-8ch/util-linux:
  ci: disable cpp/path-injection rule

2 years agoMerge branch 'raidrevert' of https://github.com/Vogtinator/util-linux
Karel Zak [Tue, 18 Jul 2023 08:02:06 +0000 (10:02 +0200)] 
Merge branch 'raidrevert' of https://github.com/Vogtinator/util-linux

* 'raidrevert' of https://github.com/Vogtinator/util-linux:
  Revert "libblkid: try LUKS2 first when probing"

2 years agoMerge branch 'lsclocks/dynamic-clock' of https://github.com/t-8ch/util-linux
Karel Zak [Tue, 18 Jul 2023 08:01:02 +0000 (10:01 +0200)] 
Merge branch 'lsclocks/dynamic-clock' of https://github.com/t-8ch/util-linux

* 'lsclocks/dynamic-clock' of https://github.com/t-8ch/util-linux:
  lsclocks: automatically discover dynamic clocks
  lsclocks: add support for dynamic clocks
  lsclocks: split out data function
  lsclocks: add COL_TYPE

2 years agoMerge branch 'libblkid/bcachefs-major-minor' of https://github.com/t-8ch/util-linux
Karel Zak [Tue, 18 Jul 2023 07:59:38 +0000 (09:59 +0200)] 
Merge branch 'libblkid/bcachefs-major-minor' of https://github.com/t-8ch/util-linux

* 'libblkid/bcachefs-major-minor' of https://github.com/t-8ch/util-linux:
  libblkid: (bcachefs) adapt to major.minor version

2 years agolibsmartcols: don't include hidden headers in column width calculation
Thomas Weißschuh [Mon, 17 Jul 2023 19:26:45 +0000 (21:26 +0200)] 
libsmartcols: don't include hidden headers in column width calculation

Fixes #2380

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolsfd: avoid passing NULL to qsort()
Thomas Weißschuh [Mon, 17 Jul 2023 20:46:04 +0000 (22:46 +0200)] 
lsfd: avoid passing NULL to qsort()

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agocolumn: fix memory leak
Thomas Weißschuh [Mon, 17 Jul 2023 19:07:18 +0000 (21:07 +0200)] 
column: fix memory leak

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agoswapon: (man) fix --priority description
Karel Zak [Mon, 17 Jul 2023 12:15:33 +0000 (14:15 +0200)] 
swapon: (man) fix --priority description

It's not true anymore that Linux uses -1 as the default. I could be
also another negative number (default is -2 for the first swap since
kernel commit a2468cc9bfdff6139f59ca896671e5819ff5f94a).

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2188894
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolsfd: show default columns in the help message
Masatake YAMATO [Wed, 12 Jul 2023 15:30:34 +0000 (00:30 +0900)] 
lsfd: show default columns in the help message

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolibmount: handle failure to apply flags as part of a mount operation
Debarshi Ray [Thu, 13 Jul 2023 09:07:27 +0000 (11:07 +0200)] 
libmount: handle failure to apply flags as part of a mount operation

If a mount operation with extra flags runs into an EPERM when applying
the flags, then mnt_context_get_mount_excode() returns 'Unknown error
5005' and MNT_EX_FAIL.  Here's an example:

Create a mount point on the host with 'nodev,nosuid,noexec':
  $ dd if=/dev/zero of=/var/tmp/loopfile bs=40960 count=1024
  $ sudo losetup --find /var/tmp/loopfile
  $ sudo mkfs.ext4 /dev/loop0
  $ sudo mkdir /mnt/a
  $ sudo mount -o nosuid,nodev,noexec /dev/loop0 /mnt/a

Check the mount options to be sure:
  $ findmnt --output OPTIONS,PROPAGATION /mnt/a
  OPTIONS                                  PROPAGATION
  rw,nosuid,nodev,noexec,relatime,seclabel shared

Enter a mount and user namespace:
  $ podman run \
        --interactive \
        --privileged \
        --rm \
        --tty \
        --volume /:/run/host:rslave \
        registry.fedoraproject.org/fedora:38 \
        /bin/bash

Try to bind mount the mount point from the host inside the namespace
with some extra flags:
  # mkdir ~/b
  # mount --bind -o ro /run/host/mnt/a ~/b
  mount: /root/b: filesystem was mounted, but any subsequent operation
      failed: Unknown error 5005.
  # echo $?
  32

It will be better to show something more human-readable than 'Unknown
error 5005'.

Secondly, an exit code of 32 means 'mount failure', which isn't quite
correct here.  The mount operation is split into two mount(2) calls,
where the first one uses MS_BIND to create the bind mount, and the
second uses MS_REMOUNT | MS_BIND | MS_RDONLY to apply the 'ro' flag.
Here, the first mount(2) does succeed:
  # findmnt --output OPTIONS,PROPAGATION ~/b
  OPTIONS                                  PROPAGATION
  rw,nosuid,nodev,noexec,relatime,seclabel private,slave

It's only the application of the 'ro' flag with the second mount(2) that
fails with an EPERM.  Hence, an exit code of 1 that means 'incorrect
invocation or permissions' seems more appropriate.

Signed-off-by: Debarshi Ray <rishi@fedoraproject.org>
2 years agoci: disable cpp/path-injection rule
Thomas Weißschuh [Wed, 12 Jul 2023 15:16:16 +0000 (17:16 +0200)] 
ci: disable cpp/path-injection rule

This rule fires for file operations on user-specified paths.
As this behavior is the very core of many util-linux utilities it is a
false positive.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolsfd: update the help message for XMODE column
Masatake YAMATO [Wed, 12 Jul 2023 15:16:08 +0000 (00:16 +0900)] 
lsfd: update the help message for XMODE column

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: introduce -H, --list-columns option for making help messages short
Masatake YAMATO [Wed, 12 Jul 2023 15:14:10 +0000 (00:14 +0900)] 
lsfd: introduce -H, --list-columns option for making help messages short

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: (man) fix the form for the optional argument of --inet option
Masatake YAMATO [Wed, 12 Jul 2023 15:02:12 +0000 (00:02 +0900)] 
lsfd: (man) fix the form for the optional argument of --inet option

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: rearrange the aligment of the help messages
Masatake YAMATO [Wed, 12 Jul 2023 15:01:25 +0000 (00:01 +0900)] 
lsfd: rearrange the aligment of the help messages

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: use the specified output stream for printing help messages
Masatake YAMATO [Wed, 12 Jul 2023 14:53:54 +0000 (23:53 +0900)] 
lsfd: use the specified output stream for printing help messages

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsclocks: automatically discover dynamic clocks
Thomas Weißschuh [Tue, 11 Jul 2023 11:36:19 +0000 (13:36 +0200)] 
lsclocks: automatically discover dynamic clocks

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolsclocks: add support for dynamic clocks
Thomas Weißschuh [Fri, 30 Jun 2023 11:32:18 +0000 (13:32 +0200)] 
lsclocks: add support for dynamic clocks

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolsclocks: split out data function
Thomas Weißschuh [Fri, 30 Jun 2023 11:16:42 +0000 (13:16 +0200)] 
lsclocks: split out data function

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolsclocks: add COL_TYPE
Thomas Weißschuh [Tue, 11 Jul 2023 11:16:00 +0000 (13:16 +0200)] 
lsclocks: add COL_TYPE

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agoRevert "libblkid: try LUKS2 first when probing"
Fabian Vogt [Wed, 12 Jul 2023 13:48:27 +0000 (15:48 +0200)] 
Revert "libblkid: try LUKS2 first when probing"

mdadm superblocks before 1.1 are placed at the end of the device, which
means that the data contained inside the array starts at offset 0. For
LUKS inside MD, blkid falsely detects this as plain LUKS instead of a
linux_raid_member. This causes e.g. dracut to not assemble the array
during boot and system startup fails.

This reverts commit b8889c0a214aeb3dd47bf1ab280fe5534b64d2aa.

2 years agoMerge branch 'lsclocks/ns-offset' of https://github.com/t-8ch/util-linux
Karel Zak [Wed, 12 Jul 2023 08:05:06 +0000 (10:05 +0200)] 
Merge branch 'lsclocks/ns-offset' of https://github.com/t-8ch/util-linux

* 'lsclocks/ns-offset' of https://github.com/t-8ch/util-linux:
  lsclocks: add NS_OFFSET column

2 years agonsenter: fix possible NULL dereferece [coverity scan]
Karel Zak [Wed, 12 Jul 2023 07:56:17 +0000 (09:56 +0200)] 
nsenter: fix possible NULL dereferece [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolibblkid: (bcachefs) adapt to major.minor version
Thomas Weißschuh [Sun, 9 Jul 2023 18:03:57 +0000 (20:03 +0200)] 
libblkid: (bcachefs) adapt to major.minor version

The version superblock field has been split into a major and minor
version part in the upstream code.
Adapt libblkid to it.

Link: https://lore.kernel.org/linux-bcachefs/20230709171551.2349961-11-kent.overstreet@linux.dev/
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agoMerge branch 'python312' of https://github.com/t-8ch/util-linux
Karel Zak [Tue, 11 Jul 2023 10:05:37 +0000 (12:05 +0200)] 
Merge branch 'python312' of https://github.com/t-8ch/util-linux

* 'python312' of https://github.com/t-8ch/util-linux:
  libmount: (python): work around python 3.12 bug
  build-sys: add AX_COMPARE_VERSION

2 years agoMerge branch 'lsfd--multiplexed-flag-of-XMODE-column' of https://github.com/masatake...
Karel Zak [Tue, 11 Jul 2023 10:01:00 +0000 (12:01 +0200)] 
Merge branch 'lsfd--multiplexed-flag-of-XMODE-column' of https://github.com/masatake/util-linux

* 'lsfd--multiplexed-flag-of-XMODE-column' of https://github.com/masatake/util-linux:
  tests: (lsfd) add a case testing 'm' flag in XMODE column
  lsfd: add 'm' flag representing "multiplexed by epoll_wait(2)" to XMODE column
  lsfd: (man) fix the broken page output for the description of NAME column

2 years agodmesg: cleanup function names
Karel Zak [Tue, 11 Jul 2023 09:49:06 +0000 (11:49 +0200)] 
dmesg: cleanup function names

The function read_buffer() also prints data when reads from kmesg. The
name is pretty confusing for readers. Let's rename it.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agodmesg: Delete redundant pager setup
Karel Zak [Tue, 11 Jul 2023 09:40:39 +0000 (11:40 +0200)] 
dmesg: Delete redundant pager setup

The pager is necessary only for SYSLOG_ACTION_READ* actions (print
kernel messages). Let's remove redundant global initialization.

Based on patch from Dragan Simic.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolib/pager: Apply pager-specific fixes only when needed
Dragan Simic [Tue, 4 Jul 2023 09:14:30 +0000 (11:14 +0200)] 
lib/pager: Apply pager-specific fixes only when needed

Currently defined output filter quirk fixes and environment variable
tweaks apply to less(1) only, so let's don't apply them when the pager
is actually configured to something else.

While there, rename the less(1)-specific callback function to make
clear what it applies to, and to make adding any posible additional
pager-specific callback functions a bit easier.

Signed-off-by: Dragan Simic <dsimic@manjaro.org>
2 years agolib/pager: Allow PAGER commands with options
Dragan Simic [Tue, 4 Jul 2023 09:14:28 +0000 (11:14 +0200)] 
lib/pager: Allow PAGER commands with options

It's quite common to have options in the commands specified in the
PAGER environment variable, to customize the behavior of the configured
output filter.  For example, someone might want to include the "-X"
option when less(1) is configured as the output filter, or might want
to specifically not include it, depending on the personal preferences.

For example, man(1), git(1) and bat(1) already allow and properly handle
the presence of any options in the configured output filter commands,
which assures that it's fine to do the same in util-linux.

Here's also a quotation from the description of the man(1) utility that
describes the PAGER environment variable, as found in The Single UNIX
Specification, version 4:

  PAGER
       Determine an output filtering command for writing the output
       to a terminal. Any string acceptable as a command_string operand
       to the sh -c command shall be valid. When standard output is
       a terminal device, the reference page output shall be piped
       through the command. If the PAGER variable is null or not set,
       the command shall be either more or another paginator utility
       documented in the system documentation.

This quotation just confirms, rather formally, that allowing options
in the output filter commands is a perfectly valid thing to do.

While there, perform a couple of minor cleanups as well, to make the
formatting of the code a tiny bit more consistent, and to slightly
improve one of the logged debug messages.

Signed-off-by: Dragan Simic <dsimic@manjaro.org>
2 years agotests: (lsfd) add a case testing 'm' flag in XMODE column
Masatake YAMATO [Mon, 10 Jul 2023 15:03:31 +0000 (00:03 +0900)] 
tests: (lsfd) add a case testing 'm' flag in XMODE column

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: add 'm' flag representing "multiplexed by epoll_wait(2)" to XMODE column
Masatake YAMATO [Mon, 10 Jul 2023 14:49:41 +0000 (23:49 +0900)] 
lsfd: add 'm' flag representing "multiplexed by epoll_wait(2)" to XMODE column

An example output:

    $ ./lsfd -p 3101482 -Q '(FD > 2)'
    COMMAND        PID   USER ASSOC  XMODE      TYPE       SOURCE MNTID INODE NAME
    test_mkfds 3101482 yamato     3 rw---- eventpoll anon_inodefs    15   106 tfds=4,5
    test_mkfds 3101482 yamato     4 r----m       CHR        mem:8    23     8 /dev/random
    test_mkfds 3101482 yamato     5 -w---m       CHR        mem:8    23     8 /dev/random

The fd 4 and 5 is multiplexed by 3, an evetpoll fd.
Therefore 'm' flags in XMODE column for fd 4 and 5 are set.

Just one character but 'm' may help users to understand the "IO structure"
of a process.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: (man) fix the broken page output for the description of NAME column
Masatake YAMATO [Mon, 10 Jul 2023 14:51:01 +0000 (23:51 +0900)] 
lsfd: (man) fix the broken page output for the description of NAME column

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsclocks: add NS_OFFSET column
Thomas Weißschuh [Fri, 30 Jun 2023 20:23:55 +0000 (22:23 +0200)] 
lsclocks: add NS_OFFSET column

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agonsenter: add missing free()
Karel Zak [Mon, 10 Jul 2023 11:38:11 +0000 (13:38 +0200)] 
nsenter: add missing free()

Addresses: https://github.com/util-linux/util-linux/pull/2320
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoMerge branch 'master' of https://github.com/u2386/util-linux
Karel Zak [Mon, 10 Jul 2023 11:35:16 +0000 (13:35 +0200)] 
Merge branch 'master' of https://github.com/u2386/util-linux

* 'master' of https://github.com/u2386/util-linux:
  nsenter: add option `-c` to join the cgroup of target process

2 years agolibmount: (python): work around python 3.12 bug
Thomas Weißschuh [Sun, 9 Jul 2023 08:18:15 +0000 (10:18 +0200)] 
libmount: (python): work around python 3.12 bug

Python 3.12 introduced a -Wredundant-decls warning.
Work around it by not breaking the build.

See https://github.com/python/cpython/issues/106560

Closes: #2366
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agobuild-sys: add AX_COMPARE_VERSION
Thomas Weißschuh [Mon, 10 Jul 2023 11:23:22 +0000 (13:23 +0200)] 
build-sys: add AX_COMPARE_VERSION

It will be used to check the found python version.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agoMerge branch 'lsfd--lock-flags-in-XMODE-column' of https://github.com/masatake/util...
Karel Zak [Mon, 10 Jul 2023 10:33:21 +0000 (12:33 +0200)] 
Merge branch 'lsfd--lock-flags-in-XMODE-column' of https://github.com/masatake/util-linux

* 'lsfd--lock-flags-in-XMODE-column' of https://github.com/masatake/util-linux:
  test: (lsfd): add a case for l and L flags in XMODE column
  test: (mkfds::ro-regular-file) add a parameter for a read lease
  test: (mkfds::make-regular-file) add a parameter for file locking
  lsfd: add flags, [-lL], representing file lock/lease states to XMODE column
  test: (mkfds::make-regular-file) add a parameter for making the new file readable
  test: (mkfds::make-regular-file) add a parameter for writing some bytes
  test: (mkfds::make-regular-file) make 'fd' local variable reusable
  test: (mkfds::make-regular-file) delete the created file when an error occurs
  test: (lsfd::column-xmode): add mising "wait" invocation

2 years agoMerge branch 'lsclocks/relative-time' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 10 Jul 2023 09:54:48 +0000 (11:54 +0200)] 
Merge branch 'lsclocks/relative-time' of https://github.com/t-8ch/util-linux

* 'lsclocks/relative-time' of https://github.com/t-8ch/util-linux:
  lsclocks: add column RESOL for clock resolution
  lsclocks: rename column RESOLUTION to RESOL_RAW
  lsclocks: add relative time
  timeutils: add strtimespec_relative
  lib/timeutils: (tests) add test for formatting
  lib/timeutils: (tests) move to struct timespec
  lsclocks: trim default columns
  lsclocks: add --output-all

2 years agoMerge branch 'prlimit' of https://github.com/jwilk-forks/util-linux
Karel Zak [Mon, 10 Jul 2023 09:52:12 +0000 (11:52 +0200)] 
Merge branch 'prlimit' of https://github.com/jwilk-forks/util-linux

* 'prlimit' of https://github.com/jwilk-forks/util-linux:
  prlimit: (man) fix formatting

2 years agoMerge branch 'lslocks' of https://github.com/jwilk-forks/util-linux
Karel Zak [Mon, 10 Jul 2023 09:40:23 +0000 (11:40 +0200)] 
Merge branch 'lslocks' of https://github.com/jwilk-forks/util-linux

* 'lslocks' of https://github.com/jwilk-forks/util-linux:
  lslocks: don't attempt to open /proc/-1/fd/

2 years agotest: (lsfd): add a case for l and L flags in XMODE column
Masatake YAMATO [Wed, 5 Jul 2023 04:47:35 +0000 (13:47 +0900)] 
test: (lsfd): add a case for l and L flags in XMODE column

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agotest: (mkfds::ro-regular-file) add a parameter for a read lease
Masatake YAMATO [Wed, 5 Jul 2023 02:20:52 +0000 (11:20 +0900)] 
test: (mkfds::ro-regular-file) add a parameter for a read lease

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agotest: (mkfds::make-regular-file) add a parameter for file locking
Masatake YAMATO [Tue, 4 Jul 2023 16:58:24 +0000 (01:58 +0900)] 
test: (mkfds::make-regular-file) add a parameter for file locking

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: add flags, [-lL], representing file lock/lease states to XMODE column
Masatake YAMATO [Wed, 5 Jul 2023 02:48:33 +0000 (11:48 +0900)] 
lsfd: add flags, [-lL], representing file lock/lease states to XMODE column

The flags hide the details of locking: methods for locking (including
lease), mandatory or advisory, and ranges. The flags can be used only
for distinguishing three states: not locked, read (or shared) locked,
or write (or exclusive) locked.

An example output:

  # ./lsfd -Q '(XMODE =~ "....[lL]")'
  COMMAND             PID   USER ASSOC XMODE TYPE SOURCE MNTID     INODE NAME
  abrtd              1854   root     7 rw--L  REG  tmpfs    27      3093 /run/abrt/abrtd.pid
  ...
  qemu-system-x86 2846033   qemu    11 rw--l  REG   dm-2  1313   5146111 /var/lib/libvirt/images/acn.qcow2

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agotest: (mkfds::make-regular-file) add a parameter for making the new file readable
Masatake YAMATO [Tue, 4 Jul 2023 16:56:37 +0000 (01:56 +0900)] 
test: (mkfds::make-regular-file) add a parameter for making the new file readable

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agotest: (mkfds::make-regular-file) add a parameter for writing some bytes
Masatake YAMATO [Tue, 4 Jul 2023 16:54:54 +0000 (01:54 +0900)] 
test: (mkfds::make-regular-file) add a parameter for writing some bytes

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agotest: (mkfds::make-regular-file) make 'fd' local variable reusable
Masatake YAMATO [Tue, 4 Jul 2023 14:55:22 +0000 (23:55 +0900)] 
test: (mkfds::make-regular-file) make 'fd' local variable reusable

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agotest: (mkfds::make-regular-file) delete the created file when an error occurs
Masatake YAMATO [Wed, 5 Jul 2023 03:38:12 +0000 (12:38 +0900)] 
test: (mkfds::make-regular-file) delete the created file when an error occurs

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agotest: (lsfd::column-xmode): add mising "wait" invocation
Masatake YAMATO [Wed, 5 Jul 2023 04:18:56 +0000 (13:18 +0900)] 
test: (lsfd::column-xmode): add mising "wait" invocation

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsclocks: add column RESOL for clock resolution
Thomas Weißschuh [Mon, 3 Jul 2023 16:02:31 +0000 (18:02 +0200)] 
lsclocks: add column RESOL for clock resolution

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolsclocks: rename column RESOLUTION to RESOL_RAW
Thomas Weißschuh [Mon, 3 Jul 2023 15:58:29 +0000 (17:58 +0200)] 
lsclocks: rename column RESOLUTION to RESOL_RAW

The new name is shorter and opens the path for a human readable version.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolsclocks: add relative time
Thomas Weißschuh [Fri, 30 Jun 2023 12:58:42 +0000 (14:58 +0200)] 
lsclocks: add relative time

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agotimeutils: add strtimespec_relative
Thomas Weißschuh [Tue, 4 Jul 2023 07:45:55 +0000 (09:45 +0200)] 
timeutils: add strtimespec_relative

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolib/timeutils: (tests) add test for formatting
Thomas Weißschuh [Tue, 4 Jul 2023 11:57:44 +0000 (13:57 +0200)] 
lib/timeutils: (tests) add test for formatting

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolib/timeutils: (tests) move to struct timespec
Thomas Weißschuh [Tue, 4 Jul 2023 07:44:42 +0000 (09:44 +0200)] 
lib/timeutils: (tests) move to struct timespec

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolsclocks: trim default columns
Thomas Weißschuh [Mon, 3 Jul 2023 15:55:45 +0000 (17:55 +0200)] 
lsclocks: trim default columns

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolsclocks: add --output-all
Thomas Weißschuh [Mon, 3 Jul 2023 15:55:40 +0000 (17:55 +0200)] 
lsclocks: add --output-all

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agoprlimit: (man) fix formatting
Jakub Wilk [Mon, 3 Jul 2023 13:03:15 +0000 (15:03 +0200)] 
prlimit: (man) fix formatting

2 years agoMerge branch 'enosys/locale' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 3 Jul 2023 10:52:38 +0000 (12:52 +0200)] 
Merge branch 'enosys/locale' of https://github.com/t-8ch/util-linux

2 years agoMerge branch 'clock' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 3 Jul 2023 10:47:08 +0000 (12:47 +0200)] 
Merge branch 'clock' of https://github.com/t-8ch/util-linux

* 'clock' of https://github.com/t-8ch/util-linux:
  lsclocks: new util to interact with system clocks
  lib/timeutils: implement timespec formatting
  lib/timeutils: implement nanosecond formatting
  lib/timeutils: constify some arguments
  utmpdump: validate subsecond granularity

2 years agoMerge branch 'lsfd--xmode' of https://github.com/masatake/util-linux
Karel Zak [Mon, 3 Jul 2023 10:41:04 +0000 (12:41 +0200)] 
Merge branch 'lsfd--xmode' of https://github.com/masatake/util-linux

* 'lsfd--xmode' of https://github.com/masatake/util-linux:
  lsfd: add 'D' flag for representing deleted files to XMODE column
  lsfd: introduce XMODE column, extensible variant of MODE
  test: (lsfd) add a subcase for testing NAME column for a deleted file
  test: (lsfd) add a case for testing DELETED column
  test: (mkfds) add "make-regular-file" factory

2 years agoMerge branch 'lsfd--misc-tun' of https://github.com/masatake/util-linux
Karel Zak [Mon, 3 Jul 2023 10:38:48 +0000 (12:38 +0200)] 
Merge branch 'lsfd--misc-tun' of https://github.com/masatake/util-linux

* 'lsfd--misc-tun' of https://github.com/masatake/util-linux:
  tests: (lsfd) add a case testing TUN.IFACE column
  tests: (mkfds) add a factor for opening tun device
  lsfd: add TUN.IFFACE, a column for interfaces behind tun devices
  lsfd: (refactor) move miscdev specific code to cdev_misc_ops
  lsfd: (refactor) make the way to handle character devices extensible
  lsfd: (refactor) introduce a content data type for char devices

2 years agoMerge branch 'patch-1' of https://github.com/diizzyy/util-linux
Karel Zak [Mon, 3 Jul 2023 10:36:07 +0000 (12:36 +0200)] 
Merge branch 'patch-1' of https://github.com/diizzyy/util-linux

* 'patch-1' of https://github.com/diizzyy/util-linux:
  include/bitops.h: Remove bswap* compatibility hack for FreeBSD

2 years agoMerge branch 'wip/rishi/libmount-src-hook-mount-move_setattr-typo' of https://github...
Karel Zak [Mon, 3 Jul 2023 10:32:42 +0000 (12:32 +0200)] 
Merge branch 'wip/rishi/libmount-src-hook-mount-move_setattr-typo' of https://github.com/debarshiray/util-linux

* 'wip/rishi/libmount-src-hook-mount-move_setattr-typo' of https://github.com/debarshiray/util-linux:
  libmount: fix typo

2 years agoMerge branch 'wip/rishi/libmount-src-libmount.h-MNT_ERR_APPLYFLAGS-docs' of https...
Karel Zak [Mon, 3 Jul 2023 10:30:43 +0000 (12:30 +0200)] 
Merge branch 'wip/rishi/libmount-src-libmount.h-MNT_ERR_APPLYFLAGS-docs' of https://github.com/debarshiray/util-linux

* 'wip/rishi/libmount-src-libmount.h-MNT_ERR_APPLYFLAGS-docs' of https://github.com/debarshiray/util-linux:
  libmount: update documentation for MNT_ERR_APPLYFLAGS

2 years agoMerge branch 'unshare/negative-time-offset' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 3 Jul 2023 10:28:54 +0000 (12:28 +0200)] 
Merge branch 'unshare/negative-time-offset' of https://github.com/t-8ch/util-linux

* 'unshare/negative-time-offset' of https://github.com/t-8ch/util-linux:
  unshare: allow negative time offsets

2 years agolslocks: don't attempt to open /proc/-1/fd/
Jakub Wilk [Mon, 3 Jul 2023 10:18:51 +0000 (12:18 +0200)] 
lslocks: don't attempt to open /proc/-1/fd/

Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
2 years agounshare: allow negative time offsets
Thomas Weißschuh [Fri, 30 Jun 2023 20:36:06 +0000 (22:36 +0200)] 
unshare: allow negative time offsets

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolsclocks: new util to interact with system clocks
Thomas Weißschuh [Sun, 25 Jun 2023 14:44:10 +0000 (16:44 +0200)] 
lsclocks: new util to interact with system clocks

Usecases:
* Compare current monotonic time to timestamps reported by systemd
* Validate time namespace operations
* Inspect clock resolutions

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agoprlimit: reject trailing junk in limits without ":"
Jakub Wilk [Thu, 29 Jun 2023 18:11:41 +0000 (20:11 +0200)] 
prlimit: reject trailing junk in limits without ":"

Before:

    $ prlimit --verbose --core=1x
    New CORE limit for pid 42: <1:1>

After:

    $ prlimit --verbose --core=1x
    prlimit: failed to parse CORE limit

Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
2 years agolibmount: update documentation for MNT_ERR_APPLYFLAGS
Debarshi Ray [Thu, 29 Jun 2023 11:04:41 +0000 (13:04 +0200)] 
libmount: update documentation for MNT_ERR_APPLYFLAGS

The implementation using the new FD based mount kernel API (ie.,
fsconfig/fsopen) uses MNT_ERR_APPLYFLAGS for failed mount_setattr(2)
calls, which involves more mount attributes (eg., MOUNT_ATTR_RDONLY,
MOUNT_ATTR_NOSUID, etc.) in addition to the MS_PROPAGATION flags (eg.,
MS_SHARED, MS_UNBINDABLE, etc.).

Note that mount_setattr(2) is part of the new FD based mount kernel API,
and is not used by the classic mount(2) based version.

Fallout from 987d844cdbc0f91ca81de3c1e5d0628a60eb458f

Signed-off-by: Debarshi Ray <rishi@fedoraproject.org>
2 years agolibmount: fix typo
Debarshi Ray [Thu, 29 Jun 2023 10:21:07 +0000 (12:21 +0200)] 
libmount: fix typo

Similar to e80f8e46127e45907db25b4ffd58c699fdf4c35f and fallout from
6753e6f6912658e836966a6316df956e1af5fcae

Signed-off-by: Debarshi Ray <rishi@fedoraproject.org>
2 years agonsenter: add option `-c` to join the cgroup of target process
u2386 [Sun, 11 Jun 2023 16:16:57 +0000 (16:16 +0000)] 
nsenter: add option `-c` to join the cgroup of target process

This commit adds support for the -c or --join-cgroup option in nsenter, allowing a new process to join the cgroup of target process.

Example:
    Setup the target process:
        $ podman run --rm -d docker.io/golang sleep 10000
        51a89deb6baf6d
        $ podman inspect --format '{{ .State.Pid }}' 51a89deb6baf6d6
        216054

    Enter the cgroup namespace of target process without option -c:
        $ sudo ./nsenter -C -U -t 216054 sh -c "cat /proc/self/cgroup"
        0::/../../../../session-899.scope

    Enter the cgroup namespace of target process with option -c:
        $ sudo ./nsenter -c -C -U -t 216054 sh -c "cat /proc/self/cgroup"
        0::/

Reviewed-by: Karel Zak <kzak@redhat.com>
Reviewed-by: Thomas Weißschuh <thomas@t-8ch.de>
Signed-off-by: u2386 <hugo.cavan2386@gmail.com>
2 years agolib/timeutils: implement timespec formatting
Thomas Weißschuh [Tue, 27 Jun 2023 06:57:09 +0000 (08:57 +0200)] 
lib/timeutils: implement timespec formatting

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolib/timeutils: implement nanosecond formatting
Thomas Weißschuh [Tue, 27 Jun 2023 06:53:56 +0000 (08:53 +0200)] 
lib/timeutils: implement nanosecond formatting

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolib/timeutils: constify some arguments
Thomas Weißschuh [Tue, 27 Jun 2023 10:41:06 +0000 (12:41 +0200)] 
lib/timeutils: constify some arguments

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agoutmpdump: validate subsecond granularity
Thomas Weißschuh [Wed, 28 Jun 2023 05:21:38 +0000 (07:21 +0200)] 
utmpdump: validate subsecond granularity

tv_usec is only valid in the range [0, 999999].
If the file contains garbage data replace interpret it as "0" instead.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agoinclude/crc64: add missing license header
Karel Zak [Wed, 28 Jun 2023 10:41:08 +0000 (12:41 +0200)] 
include/crc64: add missing license header

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agonsenter: avoid NULL pointer dereference [coverity scan]
Karel Zak [Wed, 28 Jun 2023 08:19:34 +0000 (10:19 +0200)] 
nsenter: avoid NULL pointer dereference [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoenosys: enable locale handling
Thomas Weißschuh [Tue, 27 Jun 2023 09:24:21 +0000 (11:24 +0200)] 
enosys: enable locale handling

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agoMerge branch 'cal' of https://github.com/jwilk-forks/util-linux
Karel Zak [Tue, 27 Jun 2023 08:29:59 +0000 (10:29 +0200)] 
Merge branch 'cal' of https://github.com/jwilk-forks/util-linux

* 'cal' of https://github.com/jwilk-forks/util-linux:
  cal: fix long option name for -c
  cal: fix error message for bad -c argument

2 years agotests: (lsfd) add a case testing TUN.IFACE column
Masatake YAMATO [Mon, 26 Jun 2023 16:16:45 +0000 (01:16 +0900)] 
tests: (lsfd) add a case testing TUN.IFACE column

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agocal: fix long option name for -c
Jakub Wilk [Mon, 26 Jun 2023 19:02:13 +0000 (21:02 +0200)] 
cal: fix long option name for -c

2 years agocal: fix error message for bad -c argument
Jakub Wilk [Mon, 26 Jun 2023 18:58:21 +0000 (20:58 +0200)] 
cal: fix error message for bad -c argument

2 years agolib/strutils: fix typo
Jakub Wilk [Mon, 26 Jun 2023 18:00:43 +0000 (20:00 +0200)] 
lib/strutils: fix typo

2 years agoinclude/bitops.h: Remove bswap* compatibility hack for FreeBSD
Daniel Engberg [Mon, 26 Jun 2023 17:22:16 +0000 (19:22 +0200)] 
include/bitops.h: Remove bswap* compatibility hack for FreeBSD

This is no longer needed on supported versions of FreeBSD and causes build failures

2 years agotests: (mkfds) add a factor for opening tun device
Masatake YAMATO [Mon, 26 Jun 2023 16:15:04 +0000 (01:15 +0900)] 
tests: (mkfds) add a factor for opening tun device

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: add TUN.IFFACE, a column for interfaces behind tun devices
Masatake YAMATO [Sun, 25 Jun 2023 17:41:33 +0000 (02:41 +0900)] 
lsfd: add TUN.IFFACE, a column for interfaces behind tun devices

An example output:

  # ./lsfd -Q '(SOURCE == "misc:tun")'  -o+TUN.IFACE
  COMMAND             PID       USER ASSOC MODE TYPE   SOURCE MNTID INODE NAME          TUN.IFACE
  qemu-system-x86 2846033       qemu    48  rw-  CHR misc:tun    23   306 iface=vnet89     vnet89
  qemu-system-x86 2865022       qemu    56  rw-  CHR misc:tun    23   306 iface=vnet103   vnet103
  openvpn         3113730 nm-openvpn     7  rw-  CHR misc:tun   588   306 iface=tun0         tun0
  qemu-system-x86 3608136       qemu    36  rw-  CHR misc:tun    23   306 iface=vnet104   vnet104
  qemu-system-x86 3608136       qemu    39  rw-  CHR misc:tun    23   306 iface=vnet105   vnet105
  qemu-system-x86 3608238       qemu    40  rw-  CHR misc:tun    23   306 iface=vnet106   vnet106
  qemu-system-x86 3608238       qemu    43  rw-  CHR misc:tun    23   306 iface=vnet107   vnet107
  qemu-system-x86 3608338       qemu    54  rw-  CHR misc:tun    23   306 iface=vnet108   vnet108
  qemu-system-x86 3608338       qemu    60  rw-  CHR misc:tun    23   306 iface=vnet109   vnet109

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: (refactor) move miscdev specific code to cdev_misc_ops
Masatake YAMATO [Sun, 25 Jun 2023 16:52:27 +0000 (01:52 +0900)] 
lsfd: (refactor) move miscdev specific code to cdev_misc_ops

Signed-off-by: Masatake YAMATO <yamato@redhat.com>