]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
14 months 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>
14 months 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>
14 months 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>
14 months 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

14 months 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

14 months 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

14 months 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

14 months 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/

14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months agoprlimit: (man) fix formatting
Jakub Wilk [Mon, 3 Jul 2023 13:03:15 +0000 (15:03 +0200)] 
prlimit: (man) fix formatting

14 months 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

14 months 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

14 months 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

14 months 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

14 months 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

14 months 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

14 months 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

14 months 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

14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
14 months 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>
15 months 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>
15 months 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>
15 months 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>
15 months 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

15 months 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>
15 months 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

15 months 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

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

15 months 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

15 months 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>
15 months 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>
15 months 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>
15 months agolsfd: (refactor) make the way to handle character devices extensible
Masatake YAMATO [Sun, 25 Jun 2023 16:10:57 +0000 (01:10 +0900)] 
lsfd: (refactor) make the way to handle character devices extensible

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
15 months agolsfd: (refactor) introduce a content data type for char devices
Masatake YAMATO [Sun, 25 Jun 2023 10:00:39 +0000 (19:00 +0900)] 
lsfd: (refactor) introduce a content data type for char devices

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
15 months agoMerge branch 'nsenter-add-parent-ns-option' of https://github.com/igo95862/util-linux
Karel Zak [Mon, 26 Jun 2023 12:04:52 +0000 (14:04 +0200)] 
Merge branch 'nsenter-add-parent-ns-option' of https://github.com/igo95862/util-linux

* 'nsenter-add-parent-ns-option' of https://github.com/igo95862/util-linux:
  Add `--user-parent` option to nsenter

15 months agocfdisk: fix menu behavior after writing changes
Karel Zak [Mon, 26 Jun 2023 11:25:11 +0000 (13:25 +0200)] 
cfdisk: fix menu behavior after writing changes

Florian wrote:
  after a successful write, cfdisk remains on the "Write" cursor and
  furthermore when navigating to "Quit" will continue to  show
  "...without writing changes", despite there were writes. This patch
  addresses that.

Based on patch from Florian Zimmermann <florian.zimmermann@gmail.com>

Signed-off-by: Karel Zak <kzak@redhat.com>
15 months agodmesg: -r LOG_MAKEPRI needs fac << 3
Edward Chron [Fri, 23 Jun 2023 01:31:31 +0000 (18:31 -0700)] 
dmesg: -r LOG_MAKEPRI needs fac << 3

Submission to Project: util-linux
Open Incident: #2325 at github.com/util-linux/util-linux/issues/2325
Component: util-linux/sys-utils
File: dmesg.c
Code level patch applied against: 2.39 - latest code pulled from
           git.github.com:util-linux/util-linux.git

BUG: The facility field passed to macro from /usr/include/sys/syslog.h
     LOG_MAKEPRI(fac, pri) by dmesg -r needs to have fac argument
     shifted 3 bit to the left to return a valid raw valid. The lower
     3 bits for a raw value are used by the loglevel priority (pri)
     field, so the facility bits can only occupy the bits above the
     bits used to hold the pri field value.

The dmesg -r command produces the incorrect output for the raw value
for the or'ed combination of the facility | loglevel priority that gets
produced by the LOG_MAKEPRI macro. That macro is defined as:

    #define LOG_MAKEPRI(fac, pri) ((fac) | (pri))

which is defined in the current glibc code in /usr/include/sys/syslog.h
and is used only in the dmesg -r (raw output option) command to form the
raw value for facility or'ed with loglevel priority and displayed as:

    <#>[#######.######] ...

where the # in <#> contains the output from the LOG_MAKEPRI macro.

The lower 3 bits are reserved for the loglevel priority 0-7
and the bits above that are for the facility value, so the facility
index should be shifted to the left three bits and or'ed with the
loglevel priority.

In the glibc file: /usr/include/sys/syslog.h the macro LOG_MAKEPRI is
defined as:

        #define LOG_MAKEPRI(fac, pri) ((fac) | (pri)

and returns the wrong facility and loglevel priority values, ideally it
should be defined as:

        #define LOG_MAKEPRI(fac, pri) ((fac << 3) | (pri))

to return the correct raw value.

We checked with glibc developement and the LOG_MAKEPRI macro is correct
as is and can't be changed as it used by *BSD as is so the solution for
dmesg -r is to shift the facility index left by 3 bits as input to the
LOG_MAKEPRI macro. That is what glibc development recommended.
(For reference, see glibc bugzilla Bug 30563)

We can front end the LOG_MAKEPRI macro with a macro that shifts the
facility by the needed 3 bits which we've added to dmesg.c:

    #define LOG_RAW_FAC_PRI(fac, pri) LOG_MAKEPRI((fac << 3), (pri))

This has been tested and works correctly to produce the correct raw
mode value for Facility or'ed together with Loglevel priority.

You can verify that this fix works correctly.

We can test by adding several records to /dev/kmsg like this:

    echo "<14> Test Message Facility 8 Loglevel 6" >> /dev/kmsg
    echo "<15> Test Message Facility 8 Loglevel 7" >> /dev/kmsg
    echo "<30> Test Message Facility 24 Loglevel 6" >> /dev/kmsg
    echo "<31> Test Message Facility 24 Loglevel 7" >> /dev/kmsg

these commands add 4 records to the dmesg buffer. Then when we print the
records by cat'ing /dev/kmsg or using the dmesg command several ways:

    -bash-4.2# cat /dev/kmsg | grep "Test Message Facility"
    14,1114,495317239,-; Test Message Facility 8 Loglevel 6
    15,1115,503340779,-; Test Message Facility 8 Loglevel 7
    30,1116,643374764,-; Test Message Facility 24 Loglevel 6
    31,1117,657165117,-; Test Message Facility 24 Loglevel 7

    -bash-4.2# dmesg -x | grep "Test Message Facility"
    user  :info  : [  495.317239]  Test Message Facility 8 Loglevel 6
    user  :debug : [  503.340779]  Test Message Facility 8 Loglevel 7
    daemon:info  : [  643.374764]  Test Message Facility 24 Loglevel 6
    daemon:debug : [  657.165117]  Test Message Facility 24 Loglevel 7

    -bash-4.2# dmesg -S -x | grep "Test Message Facility"
    user  :info  : [  495.317239]  Test Message Facility 8 Loglevel 6
    user  :debug : [  503.340779]  Test Message Facility 8 Loglevel 7
    daemon:info  : [  643.374764]  Test Message Facility 24 Loglevel 6
    daemon:debug : [  657.165117]  Test Message Facility 24 Loglevel 7

   -bash-4.2# dmesg -S -r | grep "Test Message Facility"
   <14>[  495.317239]  Test Message Facility 8 Loglevel 6
   <15>[  503.340779]  Test Message Facility 8 Loglevel 7
   <30>[  643.374764]  Test Message Facility 24 Loglevel 6
   <31>[  657.165117]  Test Message Facility 24 Loglevel 7

All the above methods agree in their output as expected.
However, running dmesg -r does not agree.

dmesg -r erronously produces:
----------------------------

    -bash-4.2# dmesg -r | grep "Test Message Facility"
    <7>[  495.317239]  Test Message Facility 8 Loglevel 6
    <7>[  503.340779]  Test Message Facility 8 Loglevel 7
    <7>[  643.374764]  Test Message Facility 24 Loglevel 6
    <7>[  657.165117]  Test Message Facility 24 Loglevel 7

However, if we run the dmesg -r command using the new front end macro
LOG_RAW_FAC_PRI(fac, pri) we do get the correct output:

Here is the corrected dmesg -r output:
-------------------------------------

    -bash-4.2# dmesg -r | grep "Test Message Facility"
    <14>[  495.317239]  Test Message Facility 8 Loglevel 6
    <15>[  503.340779]  Test Message Facility 8 Loglevel 7
    <30>[  643.374764]  Test Message Facility 24 Loglevel 6
    <31>[  657.165117]  Test Message Facility 24 Loglevel 7

shifting the facility index value by 3 bits in the LOG_RAW_FAC_PRI macro
provides the correct ouput as shown. All the other commands produce the
same output so now they are all in agreement.

Signed-off-by: Ivan Delalande <colona@arista.com>
Signed-off-by: Edward Chron <echron@arista.com>
15 months agobuild-sys: don't call pkg-config --static if unnecessary
Karel Zak [Mon, 26 Jun 2023 10:46:15 +0000 (12:46 +0200)] 
build-sys: don't call pkg-config --static if unnecessary

Addresses: https://github.com/util-linux/util-linux/issues/2327
Signed-off-by: Karel Zak <kzak@redhat.com>
15 months agologger: initialize socket credentials contol union
Karel Zak [Mon, 26 Jun 2023 09:56:23 +0000 (11:56 +0200)] 
logger: initialize socket credentials contol union

Addresses: https://github.com/util-linux/util-linux/issues/2336
Signed-off-by: Karel Zak <kzak@redhat.com>
15 months agoMerge branch 'unshare/time-msg' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 26 Jun 2023 09:50:02 +0000 (11:50 +0200)] 
Merge branch 'unshare/time-msg' of https://github.com/t-8ch/util-linux

* 'unshare/time-msg' of https://github.com/t-8ch/util-linux:
  unshare: fix error message for unexpected time offsets

15 months agoMerge branch 'test/builddir-pwd' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 26 Jun 2023 09:49:43 +0000 (11:49 +0200)] 
Merge branch 'test/builddir-pwd' of https://github.com/t-8ch/util-linux

* 'test/builddir-pwd' of https://github.com/t-8ch/util-linux:
  tests: (run.sh) detect builddir from working directory

15 months agoMerge branch 'losetup-errormsg' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 26 Jun 2023 09:49:20 +0000 (11:49 +0200)] 
Merge branch 'losetup-errormsg' of https://github.com/t-8ch/util-linux

* 'losetup-errormsg' of https://github.com/t-8ch/util-linux:
  losetup: deduplicate find_unused() logic
  lib/loopdev: consistently return error values from loopcxt_find_unused()
  lib/loopdev: document function return values

15 months agoMerge branch 'hardlink' of https://github.com/jwilk-forks/util-linux
Karel Zak [Mon, 26 Jun 2023 09:48:43 +0000 (11:48 +0200)] 
Merge branch 'hardlink' of https://github.com/jwilk-forks/util-linux

* 'hardlink' of https://github.com/jwilk-forks/util-linux:
  hardlink: (man) add missing comma

15 months agoMerge branch 'lsfd--fix-separators-for-json-output-cleanup' of https://github.com...
Karel Zak [Mon, 26 Jun 2023 09:48:24 +0000 (11:48 +0200)] 
Merge branch 'lsfd--fix-separators-for-json-output-cleanup' of https://github.com/masatake/util-linux

* 'lsfd--fix-separators-for-json-output-cleanup' of https://github.com/masatake/util-linux:
  lsfd: fix specifying wrong JSON typs when building the help message
  tests: (lsfd) add a case for verifying ENDPOINTS column output in JSON mode

15 months agoMerge branch 'PR/libmount-optstr-sync' of github.com:karelzak/util-linux-work
Karel Zak [Mon, 26 Jun 2023 09:45:50 +0000 (11:45 +0200)] 
Merge branch 'PR/libmount-optstr-sync' of github.com:karelzak/util-linux-work

* 'PR/libmount-optstr-sync' of github.com:karelzak/util-linux-work:
  libmount: add sample to test fs and context relation
  libmount: fix sync options between context and fs structs

15 months agounshare: fix error message for unexpected time offsets
Thomas Weißschuh [Sun, 25 Jun 2023 11:28:19 +0000 (13:28 +0200)] 
unshare: fix error message for unexpected time offsets

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
15 months agolosetup: deduplicate find_unused() logic
Thomas Weißschuh [Sun, 25 Jun 2023 07:59:05 +0000 (09:59 +0200)] 
losetup: deduplicate find_unused() logic

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
15 months agolib/loopdev: consistently return error values from loopcxt_find_unused()
Thomas Weißschuh [Sun, 25 Jun 2023 07:59:26 +0000 (09:59 +0200)] 
lib/loopdev: consistently return error values from loopcxt_find_unused()

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
15 months agolib/loopdev: document function return values
Thomas Weißschuh [Sun, 25 Jun 2023 07:58:43 +0000 (09:58 +0200)] 
lib/loopdev: document function return values

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
15 months agotests: (run.sh) detect builddir from working directory
Thomas Weißschuh [Wed, 21 Jun 2023 12:26:05 +0000 (14:26 +0200)] 
tests: (run.sh) detect builddir from working directory

This makes it easier to run test.sh from the build directory as
everything will work without any parameters irrespective of the build
directories name.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
15 months agohardlink: (man) add missing comma
Jakub Wilk [Sat, 24 Jun 2023 07:24:29 +0000 (09:24 +0200)] 
hardlink: (man) add missing comma

15 months agoAdd `--user-parent` option to nsenter
igo95862 [Sun, 26 Mar 2023 15:04:11 +0000 (21:04 +0600)] 
Add `--user-parent` option to nsenter

When this option is used nsenter will fetch the parent user
namespace from any namespace file descriptors available.

It can be combined with existing `--user` option in which case
the parent user namespace will be fetched from the user namespace
and replace it.

The usecase of this option is when a user namespace that owns
the other type namespaces we want to switch to is not actually
bound to any process. Without using ioctl it is impossible to
acquire namespace file descriptor. For example, bubblewrap
`bwrap` command creates unbinded user namespace when `--dev`
option is used.

15 months agolsfd: fix specifying wrong JSON typs when building the help message
Masatake YAMATO [Thu, 22 Jun 2023 16:10:04 +0000 (01:10 +0900)] 
lsfd: fix specifying wrong JSON typs when building the help message

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
15 months agotests: (lsfd) add a case for verifying ENDPOINTS column output in JSON mode
Masatake YAMATO [Thu, 22 Jun 2023 15:45:23 +0000 (00:45 +0900)] 
tests: (lsfd) add a case for verifying ENDPOINTS column output in JSON mode

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
15 months agoMerge branch 'lsfd--fix-separators-for-json-output' of https://github.com/masatake...
Karel Zak [Thu, 22 Jun 2023 12:26:09 +0000 (14:26 +0200)] 
Merge branch 'lsfd--fix-separators-for-json-output' of https://github.com/masatake/util-linux

* 'lsfd--fix-separators-for-json-output' of https://github.com/masatake/util-linux:
  lsfd.1.adoc: fix a typo
  lsfd: use ARRAY_STRING and ARRAY_NUMBER json types in some columns
  lsfd: use \n as the separator in INOTIFY.INODES and INOTIFY.INODES.RAW columns
  lsfd: use \n as the separator in EVENTPOLL.TFDS column
  lsfd: (filter) weakly support ARRAY_STRING and ARRAY_NUMBER json types

15 months agoMerge branch 'coverage-tweaks' of https://github.com/mrc0mmand/util-linux
Karel Zak [Thu, 22 Jun 2023 12:19:07 +0000 (14:19 +0200)] 
Merge branch 'coverage-tweaks' of https://github.com/mrc0mmand/util-linux

* 'coverage-tweaks' of https://github.com/mrc0mmand/util-linux:
  ci: collect coverage on _exit() as well
  ci: hide coverage-related stuff begind --enable-coverage
  ci: tweak build dir's ACL when collecting coverage
  ci: fix indentation

15 months agoMerge branch 'cancel-jobs-on-push' of https://github.com/mrc0mmand/util-linux
Karel Zak [Thu, 22 Jun 2023 12:15:46 +0000 (14:15 +0200)] 
Merge branch 'cancel-jobs-on-push' of https://github.com/mrc0mmand/util-linux

* 'cancel-jobs-on-push' of https://github.com/mrc0mmand/util-linux:
  ci: cancel running jobs on push

15 months agolibmount: add sample to test fs and context relation
Karel Zak [Thu, 22 Jun 2023 12:00:46 +0000 (14:00 +0200)] 
libmount: add sample to test fs and context relation

Reerences: https://github.com/util-linux/util-linux/issues/2326
Signed-off-by: Karel Zak <kzak@redhat.com>
15 months agolibmount: fix sync options between context and fs structs
Karel Zak [Thu, 22 Jun 2023 11:11:57 +0000 (13:11 +0200)] 
libmount: fix sync options between context and fs structs

Since v2.39 libmount prefers "struct libmnt_optlist" to keep mount options
rather than the original "struct libmnt_fs". This is problem if the
"fs" struct is defined and maintained outside the context.

The library has already a way how to sync "fs" and "optlist", but this
needs to be improved and used more widely. Changes:

* force "fs" from context to always read options from "optlist"

* copy options from "fs" to "optlist" in mnt_context_set_fs()

* internally redirect mnt_fs_* API for options to "optlist" if optlist
  defined

* add simple test to make sure options from different sources are
  always merged together

Addresses: https://github.com/util-linux/util-linux/issues/2326
Signed-off-by: Karel Zak <kzak@redhat.com>
15 months agoci: cancel running jobs on push
Frantisek Sumsal [Thu, 22 Jun 2023 10:33:12 +0000 (12:33 +0200)] 
ci: cancel running jobs on push

Let's cancel already running GH Actions jobs when a PR is (force) pushed
to conserve resources and make the CI runs faster thanks to the freed up
queue.

15 months agoci: collect coverage on _exit() as well
Frantisek Sumsal [Tue, 20 Jun 2023 21:01:35 +0000 (23:01 +0200)] 
ci: collect coverage on _exit() as well

_exit() skips the gcov hooks, so we lose all coverage collected up to
that point. Let's work around this by intercepting _exit() with our
wrapper that calls __gcov_dump() just before _exit().

15 months agoci: hide coverage-related stuff begind --enable-coverage
Frantisek Sumsal [Tue, 20 Jun 2023 21:00:28 +0000 (23:00 +0200)] 
ci: hide coverage-related stuff begind --enable-coverage

15 months agoci: tweak build dir's ACL when collecting coverage
Frantisek Sumsal [Tue, 20 Jun 2023 14:25:07 +0000 (16:25 +0200)] 
ci: tweak build dir's ACL when collecting coverage

So gcov can create necessary directories/.gcda files even with dropped
privileges.

15 months agohwclock: add --vl-read, --vl-clear documentation and bash-completion
Rasmus Villemoes [Wed, 21 Jun 2023 20:18:23 +0000 (22:18 +0200)] 
hwclock: add --vl-read, --vl-clear documentation and bash-completion

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
15 months agohwclock: add support for RTC_VL_READ/RTC_VL_CLR ioctls
Rasmus Villemoes [Tue, 13 Jun 2023 10:14:28 +0000 (12:14 +0200)] 
hwclock: add support for RTC_VL_READ/RTC_VL_CLR ioctls

Implement a way for userspace to query the status of the backup
battery, if supported by the hardware and driver.

The RTC_VL_* bits are a somewhat recent addition (3431ca4837bf, but
really only from b0efe0281234) to the uapi header,
so provide our own definition if the build host's header doesn't.

Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
15 months agolsfd.1.adoc: fix a typo
Masatake YAMATO [Thu, 22 Jun 2023 06:07:49 +0000 (15:07 +0900)] 
lsfd.1.adoc: fix a typo

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
15 months agolsfd: use ARRAY_STRING and ARRAY_NUMBER json types in some columns
Masatake YAMATO [Thu, 22 Jun 2023 05:42:34 +0000 (14:42 +0900)] 
lsfd: use ARRAY_STRING and ARRAY_NUMBER json types in some columns

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
15 months agolsfd: use \n as the separator in INOTIFY.INODES and INOTIFY.INODES.RAW columns
Masatake YAMATO [Sun, 18 Jun 2023 21:40:50 +0000 (06:40 +0900)] 
lsfd: use \n as the separator in INOTIFY.INODES and INOTIFY.INODES.RAW columns

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
15 months agolsfd: use \n as the separator in EVENTPOLL.TFDS column
Masatake YAMATO [Sun, 18 Jun 2023 21:25:37 +0000 (06:25 +0900)] 
lsfd: use \n as the separator in EVENTPOLL.TFDS column

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
15 months agolsfd: (filter) weakly support ARRAY_STRING and ARRAY_NUMBER json types
Masatake YAMATO [Thu, 22 Jun 2023 02:28:47 +0000 (11:28 +0900)] 
lsfd: (filter) weakly support ARRAY_STRING and ARRAY_NUMBER json types

We will have operators for array types in the future.  Till having
them, we treat the types as STRING. So we can use string operators for
the column having types.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
15 months agolsfd: add 'D' flag for representing deleted files to XMODE column
Masatake YAMATO [Sun, 11 Jun 2023 07:36:03 +0000 (16:36 +0900)] 
lsfd: add 'D' flag for representing deleted files to XMODE column

Now NAME column doesn't print "(deleted)" markers at the end of
file name.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
15 months agolsfd: introduce XMODE column, extensible variant of MODE
Masatake YAMATO [Fri, 9 Jun 2023 12:35:55 +0000 (21:35 +0900)] 
lsfd: introduce XMODE column, extensible variant of MODE

The original MODE column comes from three letters (rwx) may not be
enough for representing various aspects of file descriptors and memory
mappings. We want to add more items in the future.

However, the description of MODE in lsfd(1) doesn't wrote about its
extensibility. Adding more letters to the column can break
compatibility in someone's use case.

This change introduces XMODE column. Unlike MODE, XMODE is declared as
an extensible column in lsfd(1). Currently, it shows the same items as
the MODE column does.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
15 months agotest: (lsfd) add a subcase for testing NAME column for a deleted file
Masatake YAMATO [Sun, 18 Jun 2023 14:40:01 +0000 (23:40 +0900)] 
test: (lsfd) add a subcase for testing NAME column for a deleted file

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
15 months agotest: (lsfd) add a case for testing DELETED column
Masatake YAMATO [Sun, 18 Jun 2023 09:08:47 +0000 (18:08 +0900)] 
test: (lsfd) add a case for testing DELETED column

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
15 months agotest: (mkfds) add "make-regular-file" factory
Masatake YAMATO [Sun, 18 Jun 2023 08:47:49 +0000 (17:47 +0900)] 
test: (mkfds) add "make-regular-file" factory

With "delete" boolean parameter, you can delete the file just
after making it.

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