]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
23 months agolibmount: cleanup --fake mode
Karel Zak [Tue, 1 Aug 2023 12:49:48 +0000 (14:49 +0200)] 
libmount: cleanup --fake mode

It was originally designed to play nasty games with /etc/mtab (mount
when /etc is read-only and update later when it's write-able).

The --fake is completely useless with the new API due to complexity
where we cannot skip any step, because the next stuff depends on it.
So, it makes more sense skip all functionality where libmount does
anything significant.

This commit add --fake check to hooks logic to skip all hooks as the
hooks are place where libmount implements mount related invasive
operations (create mountpoint, namespaces, create superblock, move,
mount, etc.).

Frankly, --fake without mtab is useless.

Fixes: https://github.com/util-linux/util-linux/issues/2395
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoMerge branch 'lsfd--fix-2399-use-fifo-in-test-cases' of https://github.com/masatake...
Karel Zak [Tue, 1 Aug 2023 08:43:59 +0000 (10:43 +0200)] 
Merge branch 'lsfd--fix-2399-use-fifo-in-test-cases' of https://github.com/masatake/util-linux

* 'lsfd--fix-2399-use-fifo-in-test-cases' of https://github.com/masatake/util-linux:
  tests: (lsfd::option-inet) get child-processes' pids via fifo

2 years agoMerge branch 'cachestat' of https://github.com/t-8ch/util-linux
Karel Zak [Tue, 1 Aug 2023 08:42:06 +0000 (10:42 +0200)] 
Merge branch 'cachestat' of https://github.com/t-8ch/util-linux

* 'cachestat' of https://github.com/t-8ch/util-linux:
  fincore: report data from cachestat()
  fincore: refactor output formatting
  fincore: add --output-all

2 years agofincore: report data from cachestat()
Thomas Weißschuh [Mon, 31 Jul 2023 16:00:11 +0000 (18:00 +0200)] 
fincore: report data from cachestat()

The cachestat() syscall was introduced in Linux 6.5 and reports data
that complements that from mincore().

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agofincore: refactor output formatting
Thomas Weißschuh [Mon, 31 Jul 2023 16:00:08 +0000 (18:00 +0200)] 
fincore: refactor output formatting

This will make the upcoming addition of cachestat() columns nicer.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agofincore: add --output-all
Thomas Weißschuh [Mon, 31 Jul 2023 16:00:05 +0000 (18:00 +0200)] 
fincore: add --output-all

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolsclocks: add support for cpu clocks
Thomas Weißschuh [Mon, 31 Jul 2023 15:49:11 +0000 (17:49 +0200)] 
lsclocks: add support for cpu clocks

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolsclocks: improve dynamic clocks docs and completion
Thomas Weißschuh [Mon, 31 Jul 2023 15:49:07 +0000 (17:49 +0200)] 
lsclocks: improve dynamic clocks docs and completion

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agolsclocks: don't fail without dynamic clocks
Thomas Weißschuh [Mon, 31 Jul 2023 15:49:04 +0000 (17:49 +0200)] 
lsclocks: don't fail without dynamic clocks

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agotests: (lsfd::option-inet) get child-processes' pids via fifo
Masatake YAMATO [Mon, 31 Jul 2023 11:32:18 +0000 (20:32 +0900)] 
tests: (lsfd::option-inet) get child-processes' pids via fifo

Close #2399.

The original code assumes the background processes prepare sockets enough
fast. #2399 showed the assumption was wrong; lsfd reported half-cooked
sockets.

To avoid the timing issue, the test case with this change uses a fifo
to receive pids from the child test_mkfds processes. test_mkfds reports
its pid after cooking the sockets. When the option-inet script recives the pid,
we can expect the sockets are ready.

Note: bash's coproc cannot be used here; it supports only one co-process at
once.

Analysed-by: Alexander Kanavin <alex.kanavin@gmail.com>
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agoMerge branch 'fincore-test' of https://github.com/zeha/util-linux
Karel Zak [Mon, 31 Jul 2023 10:44:17 +0000 (12:44 +0200)] 
Merge branch 'fincore-test' of https://github.com/zeha/util-linux

* 'fincore-test' of https://github.com/zeha/util-linux:
  fincore: (tests) fix double log output

2 years agochrt: (man) add note about --sched-period lower limit
Karel Zak [Mon, 31 Jul 2023 10:41:39 +0000 (12:41 +0200)] 
chrt: (man) add note about --sched-period lower limit

References: https://github.com/util-linux/util-linux/pull/2393
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoMerge branch 'chrt/fixes' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 31 Jul 2023 10:31:35 +0000 (12:31 +0200)] 
Merge branch 'chrt/fixes' of https://github.com/t-8ch/util-linux

* 'chrt/fixes' of https://github.com/t-8ch/util-linux:
  ci: (codeql) ignore cpp/uncontrolled-process-operation
  chrt: allow option separator
  chrt: (tests) don't mark tests as known failed
  chrt: (tests) increase deadline test parameters

2 years agoMerge branch 'lsfd--handle-newline-in-unix-socket-path' of https://github.com/masatak...
Karel Zak [Mon, 31 Jul 2023 10:29:01 +0000 (12:29 +0200)] 
Merge branch 'lsfd--handle-newline-in-unix-socket-path' of https://github.com/masatake/util-linux

* 'lsfd--handle-newline-in-unix-socket-path' of https://github.com/masatake/util-linux:
  lsfd: (test) add a case for testing a unix socket including newline characters in its path name
  lsfd: re-fill unix socket paths with sockdiag netlink interface
  lsfd: add comment listing functions names importing via #include
  lsfd: include common headers in lsfd.h
  lsfd: include system header files first
  lsfd: fix a misleading parameter name
  lsfd: add const modifier

2 years agoMerge branch 'lsfd--bpf-prog' of https://github.com/masatake/util-linux
Karel Zak [Mon, 31 Jul 2023 10:13:24 +0000 (12:13 +0200)] 
Merge branch 'lsfd--bpf-prog' of https://github.com/masatake/util-linux

* 'lsfd--bpf-prog' of https://github.com/masatake/util-linux:
  test: (lsfd) add a case for testing BPF-PROG.TYPE and BPF-PROG.TYPE.RAW columns
  test: (mkfds::bpf-prog) new factory
  lsfd: add BPF-PROG.TYPE, BPF-PROG.TYPE.RAW, and BPF-PROG.ID columns

2 years agoMerge branch 'last-reboot-crash-reporting' of https://github.com/troyrollo/util-linux
Karel Zak [Mon, 31 Jul 2023 10:10:26 +0000 (12:10 +0200)] 
Merge branch 'last-reboot-crash-reporting' of https://github.com/troyrollo/util-linux

* 'last-reboot-crash-reporting' of https://github.com/troyrollo/util-linux:
  login-utils: Report crashes on reboot lines insted of overlapping uptimes

2 years agoMerge branch 'fincore-block' of https://github.com/dancerj/util-linux
Karel Zak [Mon, 31 Jul 2023 09:48:37 +0000 (11:48 +0200)] 
Merge branch 'fincore-block' of https://github.com/dancerj/util-linux

* 'fincore-block' of https://github.com/dancerj/util-linux:
  iterate according to review comments.
  Support device files.

2 years agofincore: (tests) fix double log output
Chris Hofstaedtler [Tue, 18 Jul 2023 21:34:51 +0000 (23:34 +0200)] 
fincore: (tests) fix double log output

The fincore tests call ts_log_both inside an output redirection of both stdout
and stderr, leading to the ts_log_both output ending up twice in both stdout
and stderr.
Call ts_log_both before setting up the output redirection.

Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
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 agolsfd: (test) add a case for testing a unix socket including newline characters in...
Masatake YAMATO [Sun, 23 Jul 2023 05:43:36 +0000 (14:43 +0900)] 
lsfd: (test) add a case for testing a unix socket including newline characters in its path name

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: re-fill unix socket paths with sockdiag netlink interface
Masatake YAMATO [Fri, 21 Jul 2023 19:02:38 +0000 (04:02 +0900)] 
lsfd: re-fill unix socket paths with sockdiag netlink interface

This commit is mostly based on Thomas Weißschuh's work,
https://github.com/t-8ch/util-linux/commit/06030390a5e6a16cc4b914bbf5fcedd3b6d83608.

Unlike the original work, this commit keeps /proc related code.

Unlike /proc interface, the sockdiag information source doesn't provide
enough information for filling struct unix_xinfo::st member. So this
commit uses /proc interface for filling the most of all unix_xinfo
members as before.

On the other hande, as discussed in
https://github.com/util-linux/util-linux/pull/2067, the /proc
interface in unreliable if a unix path name includes newline
characters. This commit uses the sockdiag interface to compensate
for the weakness of the /proc interface.

2 years agolsfd: add comment listing functions names importing via #include
Masatake YAMATO [Wed, 19 Jul 2023 21:11:55 +0000 (06:11 +0900)] 
lsfd: add comment listing functions names importing via #include

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: include common headers in lsfd.h
Masatake YAMATO [Wed, 19 Jul 2023 21:06:27 +0000 (06:06 +0900)] 
lsfd: include common headers in lsfd.h

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: include system header files first
Masatake YAMATO [Wed, 19 Jul 2023 21:34:30 +0000 (06:34 +0900)] 
lsfd: include system header files first

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: fix a misleading parameter name
Masatake YAMATO [Thu, 20 Jul 2023 13:00:54 +0000 (22:00 +0900)] 
lsfd: fix a misleading parameter name

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: add const modifier
Thomas Weißschuh [Fri, 14 Apr 2023 10:48:59 +0000 (12:48 +0200)] 
lsfd: add const modifier

(The log is edited by @masatake.)

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 agotest: (lsfd) add a case for testing BPF-PROG.TYPE and BPF-PROG.TYPE.RAW columns
Masatake YAMATO [Wed, 19 Jul 2023 06:38:55 +0000 (15:38 +0900)] 
test: (lsfd) add a case for testing BPF-PROG.TYPE and BPF-PROG.TYPE.RAW columns

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agotest: (mkfds::bpf-prog) new factory
Masatake YAMATO [Wed, 19 Jul 2023 06:27:07 +0000 (15:27 +0900)] 
test: (mkfds::bpf-prog) new factory

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: add BPF-PROG.TYPE, BPF-PROG.TYPE.RAW, and BPF-PROG.ID columns
Masatake YAMATO [Tue, 11 Jul 2023 13:12:05 +0000 (22:12 +0900)] 
lsfd: add BPF-PROG.TYPE, BPF-PROG.TYPE.RAW, and BPF-PROG.ID columns

Based on these new columsn, the NAME column for "bpf-prog" is
enhanced.

An example output:

  # ./lsfd -p 1 -Q '(TYPE == "bpf-prog")' | head
  COMMAND PID USER ASSOC XMODE     TYPE       SOURCE MNTID INODE NAME
  systemd   1 root    14 rw--- bpf-prog anon_inodefs    15   106 id=1008 type=lsm
  systemd   1 root    26 rw--- bpf-prog anon_inodefs    15   106 id=2073 type=cgroup_device
  systemd   1 root    27 rw--- bpf-prog anon_inodefs    15   106 id=2074 type=cgroup_skb
  systemd   1 root    28 rw--- bpf-prog anon_inodefs    15   106 id=2075 type=cgroup_skb
  systemd   1 root    30 rw--- bpf-prog anon_inodefs    15   106 id=2076 type=cgroup_device
  systemd   1 root    31 rw--- bpf-prog anon_inodefs    15   106 id=2077 type=cgroup_device
  systemd   1 root    32 rw--- bpf-prog anon_inodefs    15   106 id=2078 type=cgroup_device
  systemd   1 root    33 rw--- bpf-prog anon_inodefs    15   106 id=2079 type=cgroup_skb
  systemd   1 root    34 rw--- bpf-prog anon_inodefs    15   106 id=2080 type=cgroup_skb

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agologin-utils: Report crashes on reboot lines insted of overlapping uptimes
Troy Rollo [Wed, 19 Jul 2023 01:04:56 +0000 (11:04 +1000)] 
login-utils: Report crashes on reboot lines insted of overlapping uptimes

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 agoiterate according to review comments.
Junichi Uekawa [Mon, 10 Jul 2023 12:14:56 +0000 (21:14 +0900)] 
iterate according to review comments.

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 agoSupport device files.
Junichi Uekawa [Thu, 6 Jul 2023 08:40:38 +0000 (17:40 +0900)] 
Support device files.

Device files do not give file size with st.st_size field, they return
0. Instead use blkdev_get_size to call the ioctls for block devices.

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