]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
22 hours agolsclocks: use MAX_CLOCKS, improve indention master
Karel Zak [Thu, 14 Aug 2025 10:38:29 +0000 (12:38 +0200)] 
lsclocks: use MAX_CLOCKS, improve indention

Let's follow the kernel and use MAX_CLOCKS to define CLOCK_AUX.

Signed-off-by: Karel Zak <kzak@redhat.com>
22 hours agoMerge branch 'lsclocks/auxclocks' of https://github.com/t-8ch/util-linux
Karel Zak [Thu, 14 Aug 2025 10:18:50 +0000 (12:18 +0200)] 
Merge branch 'lsclocks/auxclocks' of https://github.com/t-8ch/util-linux

* 'lsclocks/auxclocks' of https://github.com/t-8ch/util-linux:
  lsclocks: add auxiliary clocks

22 hours agoMerge branch 'fix-logger-issue' of https://github.com/akappner/util-linux
Karel Zak [Thu, 14 Aug 2025 10:06:40 +0000 (12:06 +0200)] 
Merge branch 'fix-logger-issue' of https://github.com/akappner/util-linux

* 'fix-logger-issue' of https://github.com/akappner/util-linux:
  logger: fix incorrect warning message when both --file and a message are specified

22 hours agoMerge branch 'PR/swapon-fstab' of https://github.com/karelzak/util-linux-work
Karel Zak [Thu, 14 Aug 2025 10:05:22 +0000 (12:05 +0200)] 
Merge branch 'PR/swapon-fstab' of https://github.com/karelzak/util-linux-work

* 'PR/swapon-fstab' of https://github.com/karelzak/util-linux-work:
  swapon: (man page) add details about fstab configuration

45 hours agologger: fix incorrect warning message when both --file and a message are specified
Alexander Kappner [Wed, 13 Aug 2025 11:10:28 +0000 (04:10 -0700)] 
logger: fix incorrect warning message when both --file and a message are specified

Logger warns that when both --file and a message are given, the message is ignored.
It does the opposite. Fix the warning message to conform to the observed behavior.

Example:
echo "You will not see this file in the log" > file.txt
logger -f file.txt "You will see this message in the log"

Signed-off-by: Alexander Kappner <agk@godking.net>
46 hours agoswapon: (man page) add details about fstab configuration
Karel Zak [Tue, 12 Aug 2025 12:47:49 +0000 (14:47 +0200)] 
swapon: (man page) add details about fstab configuration

The fstab(5) man page already describes some basic aspects of "swap,"
but it makes sense to be more specific in the swapon man page and
describe everything in one place, serving as a normative reference for
what is expected on Linux in fstab for swap.

Fixes: https://github.com/util-linux/util-linux/issues/3667
Signed-off-by: Karel Zak <kzak@redhat.com>
2 days agolsclocks: add auxiliary clocks
Thomas Weißschuh [Mon, 2 Jun 2025 21:10:35 +0000 (23:10 +0200)] 
lsclocks: add auxiliary clocks

Add support for the auxiliary posix clocks introduced in Linux 6.17.

When auxiliary clocks are not supported, no output line is generated.
When an auxiliary clock is not enabled an output line without TIME
columns is generated.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
3 days agomount: add --beneath support
Karel Zak [Mon, 11 Aug 2025 11:08:13 +0000 (13:08 +0200)] 
mount: add --beneath support

Signed-off-by: Karel Zak <kzak@redhat.com>
3 days agolibmount: add MOVE_MOUNT_BENEATH support
Karel Zak [Mon, 11 Aug 2025 11:07:38 +0000 (13:07 +0200)] 
libmount: add MOVE_MOUNT_BENEATH support

Fixes: https://github.com/util-linux/util-linux/issues/2604
Signed-off-by: Karel Zak <kzak@redhat.com>
3 days agomount: (bash-completion) add --exclusive
Karel Zak [Mon, 11 Aug 2025 11:10:53 +0000 (13:10 +0200)] 
mount: (bash-completion) add --exclusive

Signed-off-by: Karel Zak <kzak@redhat.com>
3 days agoMerge branch 'PR/libmount-fanotify' of https://github.com/karelzak/util-linux-work
Karel Zak [Mon, 11 Aug 2025 09:22:10 +0000 (11:22 +0200)] 
Merge branch 'PR/libmount-fanotify' of https://github.com/karelzak/util-linux-work

* 'PR/libmount-fanotify' of https://github.com/karelzak/util-linux-work:
  libmount: ifdef for fanotify support on older systems
  libmount: (monitor) add fanotify_next_fs()
  libmount: (monitor) add basic fanotify support
  libmount: (monitor) rename public API to "mountinfo"
  libmount: (monitor) clean up mountinfo function names
  libmount: add mnt_fs_is_{moved,attached,detached} functions
  libmount: (monitor)  cleanup userspace_add_watch() exiting
  libmount: (monitor) check for utab delete
  libmount: (monitor) optimize inotify utab watch
  libmount: (monitor) cleanup op_process_event() return codes
  libmount: (monitor) add next-fs API
  libmount: (monitor) epoll_wait code consolidation
  libmount: (monitor) require entry-specific functions
  libmount: (monitor) clean up internal names
  libmount: (monitor) support type-specific data
  libmount: (monitor) support additional monitor identifiers
  libmount: split monitor code to more files

7 days agolibmount: ifdef for fanotify support on older systems
Karel Zak [Thu, 7 Aug 2025 11:15:32 +0000 (13:15 +0200)] 
libmount: ifdef for fanotify support on older systems

Signed-off-by: Karel Zak <kzak@redhat.com>
7 days agolibmount: (monitor) add fanotify_next_fs()
Karel Zak [Tue, 5 Aug 2025 13:39:53 +0000 (15:39 +0200)] 
libmount: (monitor) add fanotify_next_fs()

This function returns a unique filesystem ID to the caller.

Signed-off-by: Karel Zak <kzak@redhat.com>
7 days agochrt: (man,usage) put --pid first in synopses and examples, for clarity
Benno Schulenberg [Tue, 5 Aug 2025 09:24:43 +0000 (11:24 +0200)] 
chrt: (man,usage) put --pid first in synopses and examples, for clarity

When --pid is among the options, it is clearest when it is given as the
first option, because then it doesn't sit between the policy option and
the somewhat related priority value.  It creates some kind of symmetry:
the --pid option first, then other things, and the actual PID last.

CC: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
7 days agochrt: (man) improve wording and markup of some examples
Benno Schulenberg [Tue, 5 Aug 2025 09:24:42 +0000 (11:24 +0200)] 
chrt: (man) improve wording and markup of some examples

CC: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
7 days agochrt: (man,usage) mark the priority value as optional in the synopses
Benno Schulenberg [Tue, 5 Aug 2025 09:24:41 +0000 (11:24 +0200)] 
chrt: (man,usage) mark the priority value as optional in the synopses

The priority value is optional in some cases, so it cannot be listed
as required.

CC: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
7 days agochrt: produce better error message for missing priority with implied -r
Benno Schulenberg [Tue, 5 Aug 2025 09:24:40 +0000 (11:24 +0200)] 
chrt: produce better error message for missing priority with implied -r

Since commit 4c425142844d, the following two equivalent commands produce
different error messages:

  # chrt -r ls NEWS
  chrt: invalid priority argument: 'ls'
  # chrt ls NEWS
  chrt: unsupported priority value for the policy: 0: see --max for valid range

The latter error message is enigmatic: where did the user specify '0'?

Before the mentioned commit, the second command would produce the same
error message as the first.  Restore that behavior.

CC: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
8 days agolibmount: (monitor) add basic fanotify support
Karel Zak [Wed, 11 Jun 2025 11:49:05 +0000 (13:49 +0200)] 
libmount: (monitor) add basic fanotify support

* add mnt_monitor_enable_fanotify() to add the new monitor

* add MNT_MONITOR_TYPE_FANOTIFY to identify events

* add new monitor to the test

Signed-off-by: Karel Zak <kzak@redhat.com>
8 days agolibmount: (monitor) rename public API to "mountinfo"
Karel Zak [Wed, 6 Aug 2025 12:09:12 +0000 (14:09 +0200)] 
libmount: (monitor) rename public API to "mountinfo"

There will be more kernel monitors in the future. Ensure the API is
easy to understand.

* Rename MNT_MONITOR_TYPE_KERNEL to MNT_MONITOR_TYPE_MOUNTINFO

* Rename mnt_monitor_enable_kernel() to mnt_monitor_enable_mountinfo()

The change is backward compatible; the old names are still usable.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 days agolibmount: (monitor) clean up mountinfo function names
Karel Zak [Wed, 6 Aug 2025 11:48:27 +0000 (13:48 +0200)] 
libmount: (monitor) clean up mountinfo function names

There will be more kernel monitors in the future. It's better to use
names specific to the monitoring method rather than the generic
"kernel."

This commit renames only internal components.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 days agolibmount: add mnt_fs_is_{moved,attached,detached} functions
Karel Zak [Wed, 16 Jul 2025 11:52:07 +0000 (13:52 +0200)] 
libmount: add mnt_fs_is_{moved,attached,detached} functions

Let's use these simple functions to report what the last operation or
status detected by the library means to the filesystem. It will be
used by the fanotify monitor as well.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 days agolibmount: (monitor) cleanup userspace_add_watch() exiting
Karel Zak [Wed, 11 Jun 2025 09:38:10 +0000 (11:38 +0200)] 
libmount: (monitor)  cleanup userspace_add_watch() exiting

Signed-off-by: Karel Zak <kzak@redhat.com>
8 days agolibmount: (monitor) check for utab delete
Karel Zak [Tue, 10 Jun 2025 12:06:53 +0000 (14:06 +0200)] 
libmount: (monitor) check for utab delete

Also, monitor for "rm -rf /run/mount" to reinitialize the monitor.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 days agolibmount: (monitor) optimize inotify utab watch
Karel Zak [Tue, 10 Jun 2025 11:51:23 +0000 (13:51 +0200)] 
libmount: (monitor) optimize inotify utab watch

Don't repeat no-op inotify_add_watch() calls. This happens when we
monitor the /run[/mount] directory before the utab.event file exists.
The old version just tries to create a watch and ignores ENOENT
errors. It seems better to remember the path of the last created watch
and not repeat it.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 days agolibmount: (monitor) cleanup op_process_event() return codes
Karel Zak [Tue, 10 Jun 2025 10:15:28 +0000 (12:15 +0200)] 
libmount: (monitor) cleanup op_process_event() return codes

Let's use usual concept (<0 error; 0 success; 1 nothing).

Signed-off-by: Karel Zak <kzak@redhat.com>
8 days agolibmount: (monitor) add next-fs API
Karel Zak [Tue, 10 Jun 2025 09:05:20 +0000 (11:05 +0200)] 
libmount: (monitor) add next-fs API

Signed-off-by: Karel Zak <kzak@redhat.com>
8 days agolibmount: (monitor) epoll_wait code consolidation
Karel Zak [Wed, 28 May 2025 09:18:57 +0000 (11:18 +0200)] 
libmount: (monitor) epoll_wait code consolidation

The epoll_wait() and op_process_event() are called in two places. Move
the code to read_epoll_events() and process everything in one place

Signed-off-by: Karel Zak <kzak@redhat.com>
8 days agolibmount: (monitor) require entry-specific functions
Karel Zak [Tue, 27 May 2025 11:23:39 +0000 (13:23 +0200)] 
libmount: (monitor) require entry-specific functions

8 days agolibmount: (monitor) clean up internal names
Karel Zak [Tue, 27 May 2025 11:14:34 +0000 (13:14 +0200)] 
libmount: (monitor) clean up internal names

In future changes, we need to process active monitor entries in entry
type-specific code to return data from events.

This requires a slight change in the function's logic, so it makes
sense to rename the function according to the new logic, meaning
changes --> active, verify --> process.

The patch also replaces bit fields with booleans.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 days agolibmount: (monitor) support type-specific data
Karel Zak [Tue, 27 May 2025 10:04:24 +0000 (12:04 +0200)] 
libmount: (monitor) support type-specific data

Signed-off-by: Karel Zak <kzak@redhat.com>
8 days agolibmount: (monitor) support additional monitor identifiers
Karel Zak [Wed, 21 May 2025 10:39:17 +0000 (12:39 +0200)] 
libmount: (monitor) support additional monitor identifiers

This is necessary to support multiple monitors of the same type.
Currently, only one monitor per type is supported.

Signed-off-by: Karel Zak <kzak@redhat.com>
8 days agolibmount: split monitor code to more files
Karel Zak [Wed, 21 May 2025 09:43:57 +0000 (11:43 +0200)] 
libmount: split monitor code to more files

Signed-off-by: Karel Zak <kzak@redhat.com>
9 days agoMerge branch 'patch-1' of https://github.com/neheb/util-linux
Karel Zak [Tue, 5 Aug 2025 11:22:30 +0000 (13:22 +0200)] 
Merge branch 'patch-1' of https://github.com/neheb/util-linux

* 'patch-1' of https://github.com/neheb/util-linux:
  meson: use curses dep for ncurses

9 days agoMerge branch 'PR/libmount-excl' of https://github.com/karelzak/util-linux-work
Karel Zak [Tue, 5 Aug 2025 11:22:10 +0000 (13:22 +0200)] 
Merge branch 'PR/libmount-excl' of https://github.com/karelzak/util-linux-work

* 'PR/libmount-excl' of https://github.com/karelzak/util-linux-work:
  mount: add --exclusive command line option
  libmount: Add support for FSCONFIG_CMD_CREATE_EXCL
  lib: add FSCONFIG_CMD_CREATE_EXCL

9 days agosetpriv: improve landlock usage() output
Karel Zak [Tue, 5 Aug 2025 11:18:32 +0000 (13:18 +0200)] 
setpriv: improve landlock usage() output

* Add help for rights names
* Keep usage() output for Landlock more structured
* Add a note to the man page that "fs" is subject to change

Signed-off-by: Karel Zak <kzak@redhat.com>
12 days agosetpriv: Add support for LANDLOCK_ACCESS_FS_IOCTL_DEV
Günther Noack [Sat, 2 Aug 2025 15:43:05 +0000 (17:43 +0200)] 
setpriv: Add support for LANDLOCK_ACCESS_FS_IOCTL_DEV

The LANDLOCK_ACCESS_FS_IOCTL_DEV access right controls whether the
process may use IOCTL on opened device files.  It is available since
Linux 6.10.

Compatibility remark:
With this change, using the --landlock-access="fs" shortcut now
requires Linux 6.10+, where it previously required Linux 6.2+.

2 weeks agomount: add --exclusive command line option
Karel Zak [Thu, 31 Jul 2025 10:31:36 +0000 (12:31 +0200)] 
mount: add --exclusive command line option

The new option ensures that the kernel does not reuse existing
superblock.

The new option is available to non-root users as it does not affect
the superblock itself or any other aspects of the mount process. It
makes the current mounting more restrictive, so it makes sense to
allow it for non-root users.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolibmount: Add support for FSCONFIG_CMD_CREATE_EXCL
Karel Zak [Thu, 31 Jul 2025 10:28:33 +0000 (12:28 +0200)] 
libmount: Add support for FSCONFIG_CMD_CREATE_EXCL

* Add API functions mnt_context_enable_exclusive() and mnt_context_is_exclusive()

* Use the new flag when creating the superblock

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agolib: add FSCONFIG_CMD_CREATE_EXCL
Karel Zak [Thu, 31 Jul 2025 10:25:18 +0000 (12:25 +0200)] 
lib: add FSCONFIG_CMD_CREATE_EXCL

* add FSCONFIG_CMD_CREATE_EXCL to mount-api-utils.h

* (like libc) define FSCONFIG_ macros to be usable for #ifdefs

* add fallback for FSCONFIG_CMD_CREATE_EXCL as fsconfig_command enum
  in system headers may be without the flag

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agomeson: use curses dep for ncurses
Rosen Penev [Wed, 30 Jul 2025 21:40:53 +0000 (14:40 -0700)] 
meson: use curses dep for ncurses

curses is special in that it's able to find ncurses in a lot more locations that ncurses, which only looks at pkg-config and cmake. This is somewhat useful with exotic OSes like macOS.

2 weeks agochrt: Allow optional priority for non‑prio policies without --pid
Madadi Vineeth Reddy [Tue, 29 Jul 2025 09:47:03 +0000 (15:17 +0530)] 
chrt: Allow optional priority for non‑prio policies without --pid

This extends commit e7a2d62434c2
("chrt: Make priority optional for policies that don't use it")
so that priority arguments are optional even when --pid is not specified.

Before this patch:
$ chrt --other ls -lh
chrt: invalid priority argument: 'ls'
-> only "chrt --other 0 ls -lh" would work

After this patch:
$ chrt --other ls -lh
$ chrt --other 0 ls -lh
-> both now work

If an out‑of‑range priority is given, it reports an error:
$ chrt --other 1 ls -lh
unsupported priority value for the policy: 1 (see --max for valid range)

Changes in v2:
- Removed is_number() and used isdigit_string() (Karel Zak)
- used _() for translation (Karel Zak)

Fixes: e7a2d62434c2 ("chrt: Make priority optional for policies that don't use it")
Signed-off-by: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
2 weeks agoMerge branch 'master' of https://github.com/hongxu-jia/util-linux
Karel Zak [Tue, 29 Jul 2025 12:18:30 +0000 (14:18 +0200)] 
Merge branch 'master' of https://github.com/hongxu-jia/util-linux

* 'master' of https://github.com/hongxu-jia/util-linux:
  tests/helpers/test_sigstate.c: explicitly reset SIGINT to default action after trapping

2 weeks agoMerge branch 'ldattach_mtu' of https://github.com/SeppoTakalo/util-linux
Karel Zak [Tue, 29 Jul 2025 12:16:31 +0000 (14:16 +0200)] 
Merge branch 'ldattach_mtu' of https://github.com/SeppoTakalo/util-linux

* 'ldattach_mtu' of https://github.com/SeppoTakalo/util-linux:
  ldattach: Allow changing the MTU for GSM0710 framing

2 weeks agoMerge branch 'lsfd--packet-raw-protocol' of https://github.com/masatake/util-linux
Karel Zak [Tue, 29 Jul 2025 10:58:32 +0000 (12:58 +0200)] 
Merge branch 'lsfd--packet-raw-protocol' of https://github.com/masatake/util-linux

* 'lsfd--packet-raw-protocol' of https://github.com/masatake/util-linux:
  lsfd: add PACKET.PROTOCOL.RAW, a new column

2 weeks agolsfd: add PACKET.PROTOCOL.RAW, a new column
Masatake YAMATO [Sun, 5 Jan 2025 18:34:22 +0000 (03:34 +0900)] 
lsfd: add PACKET.PROTOCOL.RAW, a new column

Using sizeof for the calculating buffer size is suggested
by @karelzak.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 weeks agomkfs.cramfs: avoid uninitialized value [coverity scan]
Karel Zak [Tue, 29 Jul 2025 09:40:16 +0000 (11:40 +0200)] 
mkfs.cramfs: avoid uninitialized value [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
2 weeks agotests/helpers/test_sigstate.c: explicitly reset SIGINT to default action after trapping
Hongxu Jia [Mon, 28 Jul 2025 12:35:13 +0000 (20:35 +0800)] 
tests/helpers/test_sigstate.c: explicitly reset SIGINT to default action after trapping

After upgrading bash to 5.3 to contain commit [1], if SIGINT was trapped in
asynchronous subshell, bash called set_signal_async_ignored to make sure
processes that are created by this asynchronous subshell to ignore SIGINT.

And it caused test case `kill/decode' failed, the signal INT was existed in
both of Blocked and Ignored

$ ./tests/run.sh --use-system-commands --parsable --show-diff   kill/decode
...
diff-{{{
|--- /usr/lib/util-linux/ptest/tests/expected/kill/decode        2011-04-05 23:00:00.000000000 +0000
|+++ /usr/lib/util-linux/ptest/tests/output/kill/decode  2025-07-28 12:09:46.279000000 +0000
@@ -16,5 +16,5 @@
 Pending (thread): INT ILL
 Pending (process): USR1
 Blocked: INT ILL ABRT FPE USR1 SEGV TERM
-Ignored: HUP QUIT TRAP PIPE ALRM
+Ignored: HUP INT QUIT TRAP PIPE ALRM
 Caught: ILL USR1
}}}-diff
...

Explicitly reset SIGINT to default action after trapping, then the
test case `kill/decode' works on both of old (<5.3) and new (>=5.3) bash

[1] https://cgit.git.savannah.gnu.org/cgit/bash.git/commit/?h=devel&id=a5d2617c7a7e602ace1f4149987cdfd075c4e762

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
2 weeks agoldattach: Allow changing the MTU for GSM0710 framing
Seppo Takalo [Thu, 24 Jul 2025 11:38:59 +0000 (14:38 +0300)] 
ldattach: Allow changing the MTU for GSM0710 framing

Traditionally ldattach have hard coded MTU of 127 bytes
which differs from defaults proposed in 3GPP TS 27.010
which is 31 bytes when basic framing is used.

Add '-m <value>' parameter that is only GSM0710 specific
and already handled by the kernel. Use same value for both
MTU and MRU.

Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
2 weeks agoMerge branch 'PR/column-colors' of https://github.com/karelzak/util-linux-work
Karel Zak [Mon, 28 Jul 2025 09:51:43 +0000 (11:51 +0200)] 
Merge branch 'PR/column-colors' of https://github.com/karelzak/util-linux-work

* 'PR/column-colors' of https://github.com/karelzak/util-linux-work:
  column: add support for color scheme
  libsmartcols: add function to set/get header colors
  lib/strutils: add ul_optstr_get_value()
  lib/color-names: Fix color name canonicalization
  column: add --color[=<when>] to control colorization
  column: add basic colors support

2 weeks agolibblkid: (ext) reduce false positive
胡玮文 [Mon, 28 Jul 2025 06:32:13 +0000 (14:32 +0800)] 
libblkid: (ext) reduce false positive

Signed-off-by: 胡玮文 <huweiwen.hww@alibaba-inc.com>
3 weeks agoMerge branch 'PR/fsck.cramfs-memcpy' of https://github.com/karelzak/util-linux-work
Karel Zak [Thu, 24 Jul 2025 11:18:43 +0000 (13:18 +0200)] 
Merge branch 'PR/fsck.cramfs-memcpy' of https://github.com/karelzak/util-linux-work

* 'PR/fsck.cramfs-memcpy' of https://github.com/karelzak/util-linux-work:
  fsck.cramfs: check buffer size for memcpy()

3 weeks agoMerge branch 'PR/setpriv-getgroups' of https://github.com/karelzak/util-linux-work
Karel Zak [Thu, 24 Jul 2025 11:18:01 +0000 (13:18 +0200)] 
Merge branch 'PR/setpriv-getgroups' of https://github.com/karelzak/util-linux-work

* 'PR/setpriv-getgroups' of https://github.com/karelzak/util-linux-work:
  setpriv: Improve getgroups() Portability

3 weeks agosetpriv: Improve getgroups() Portability
Karel Zak [Mon, 21 Jul 2025 06:16:25 +0000 (08:16 +0200)] 
setpriv: Improve getgroups() Portability

setpriv(1) is Linux-only, and on Linux, getgroups() returns at least one group.
However, it's better to use more portable and generic code patterns and assume
that getgroups() can return zero.

Fixes: https://github.com/util-linux/util-linux/issues/3654
Reported-by: Alejandro Colomar <alx@kernel.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
3 weeks agolibblkid: improve UUID_SUB= description
Karel Zak [Thu, 24 Jul 2025 10:48:00 +0000 (12:48 +0200)] 
libblkid: improve UUID_SUB= description

Fixes: https://github.com/util-linux/util-linux/issues/3657
Signed-off-by: Karel Zak <kzak@redhat.com>
3 weeks agofsck.cramfs: check buffer size for memcpy()
Karel Zak [Mon, 21 Jul 2025 07:48:06 +0000 (09:48 +0200)] 
fsck.cramfs: check buffer size for memcpy()

- reuse MAX_INPUT_NAMELEN
- check path buffer size before memcpy() to the buffer
- check for zero path before use it

Signed-off-by: Karel Zak <kzak@redhat.com>
4 weeks agocolumn: add support for color scheme
Karel Zak [Tue, 15 Jul 2025 13:38:46 +0000 (15:38 +0200)] 
column: add support for color scheme

Signed-off-by: Karel Zak <kzak@redhat.com>
4 weeks agolibsmartcols: add function to set/get header colors
Karel Zak [Tue, 15 Jul 2025 13:37:56 +0000 (15:37 +0200)] 
libsmartcols: add function to set/get header colors

Signed-off-by: Karel Zak <kzak@redhat.com>
4 weeks agolib/strutils: add ul_optstr_get_value()
Karel Zak [Tue, 15 Jul 2025 13:36:22 +0000 (15:36 +0200)] 
lib/strutils: add ul_optstr_get_value()

Signed-off-by: Karel Zak <kzak@redhat.com>
4 weeks agolib/color-names: Fix color name canonicalization
Karel Zak [Tue, 15 Jul 2025 13:35:05 +0000 (15:35 +0200)] 
lib/color-names: Fix color name canonicalization

Return NULL rather than a random string if it cannot be translated to
the color sequence.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 weeks agotextual: harmonize the messages for invalid count and timeout values
Benno Schulenberg [Wed, 9 Jul 2025 09:07:34 +0000 (11:07 +0200)] 
textual: harmonize the messages for invalid count and timeout values

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
4 weeks agotextual: harmonize the messages for an invalid size, length, and offset
Benno Schulenberg [Wed, 9 Jul 2025 09:07:33 +0000 (11:07 +0200)] 
textual: harmonize the messages for an invalid size, length, and offset

The added words "argument" or "value" or "specified" don't make things
clearer and are just unneeded verbosity.  Also, use all lowercase.

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
4 weeks agocolumn: call gettext() on an error message only when it gets printed
Benno Schulenberg [Wed, 9 Jul 2025 09:07:32 +0000 (11:07 +0200)] 
column: call gettext() on an error message only when it gets printed

Just mark error messages for translation, with gettext_noop(), and pass
them untranslated to the subroutines.  Then call gettext() on such a
message only when an error occurs and the message gets printed.

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
4 weeks agoMerge branch 'cpulist-stride' of https://github.com/jmr/util-linux
Karel Zak [Mon, 14 Jul 2025 11:45:06 +0000 (13:45 +0200)] 
Merge branch 'cpulist-stride' of https://github.com/jmr/util-linux

* 'cpulist-stride' of https://github.com/jmr/util-linux:
  cpuset: Use stride in cpulist_create

5 weeks agocolumn: add --color[=<when>] to control colorization
Karel Zak [Tue, 8 Jul 2025 15:02:52 +0000 (17:02 +0200)] 
column: add --color[=<when>] to control colorization

This implements terminal-colors.d(5) behavior.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 weeks agocpuset: Use stride in cpulist_create
Jesse Rosenstock [Tue, 1 Jul 2025 10:38:24 +0000 (12:38 +0200)] 
cpuset: Use stride in cpulist_create

Format cpu lists for `taskset -c`, `lscpu`, etc. using stride.  This
usually produces shorter output.

Now:
% ./taskset -c 0-24:2,25-47:4 ./taskset -pc 0
pid 3937653's current affinity list: 0-24:2,25-45:4

Previously:
% ./taskset -c 0-23:2,24-47:4 ./taskset -pc 0
pid 3933321's current affinity list: 0,2,4,6,8,10,12,14,16,18,20,22,24,28,32,36,40,44

The ranges are constructed greedily; in general it is difficult to
construct a minimal list.
% ./taskset -c 0-63:3,0-63:4 ./taskset -pc 0
pid 3926213's current affinity list: 0,3,4-8:2,9-15:3,16-20:2,21-27:3,28-32:2,33-39:3,40-44:2,45

Signed-off-by: Jesse Rosenstock <jmr@google.com>
5 weeks agocolumn: add basic colors support
Karel Zak [Mon, 7 Jul 2025 13:10:52 +0000 (15:10 +0200)] 
column: add basic colors support

Signed-off-by: Karel Zak <kzak@redhat.com>
5 weeks agochrt: do not try to interpret any other option as a PID either
Benno Schulenberg [Thu, 3 Jul 2025 14:47:52 +0000 (16:47 +0200)] 
chrt: do not try to interpret any other option as a PID either

When doing, for example, `chrt --pid --max`, it would report:

  chrt: invalid PID argument: '--max'

This mistakenly gave the impression that the PID argument has to follow
directly after the --pid option.

Avoid this by delaying the parsing of a PID until after all options have
been parsed.  Temporarily set 'ctl->pid' to zero to indicate that a PID
needs to be read.

After this change, `chrt --pid --max` will simply report the minimum and
maximum valid priorities.  And `chrt --pid -v`:

  chrt: too few arguments

Also, add a missing call of gettext() for the other error message.

CC: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
5 weeks agochrt: simplify the other check for too few arguments
Benno Schulenberg [Thu, 3 Jul 2025 14:47:51 +0000 (16:47 +0200)] 
chrt: simplify the other check for too few arguments

Without option --pid, always at least two arguments are needed:
the <priority> value and a <command>.  (The 'need_prio' variable
is relevant only for the --pid case.)

Also, make the error message more informative.

CC: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
5 weeks agochrt: do not try to interpret the --pid option itself as a PID
Benno Schulenberg [Thu, 3 Jul 2025 14:47:50 +0000 (16:47 +0200)] 
chrt: do not try to interpret the --pid option itself as a PID

When not specifying a PID with --pid, `chrt` would report:

  chrt: invalid PID argument: '--pid'

That was silly.  After this change, `chrt --pid` will report:

  chrt: too few arguments

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
5 weeks agochrt: with more than one argument, interpret first argument as priority
Benno Schulenberg [Thu, 3 Jul 2025 14:47:49 +0000 (16:47 +0200)] 
chrt: with more than one argument, interpret first argument as priority

The first argument is a priority not only for `chrt --pid <prio> <pid>`
but also for `chrt <prio> <command> [<argument>...]`.

This fixes an oversight in recent commit e7a2d62434.

Reviewed-by: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Tested-by: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
6 weeks agotaskset: Accept 0 pid for current process
Jesse Rosenstock [Fri, 27 Jun 2025 07:47:35 +0000 (09:47 +0200)] 
taskset: Accept 0 pid for current process

This is useful to print the current mask without using `$$`: `taskset -p 0`.

It is also helpful to test taskset: `taskset -c 1-4 taskset -p 0`.
This is not easy with `$$`.

sched_setaffinity(2)/sched_getaffinity(2) accept 0 for the calling
thread, so this seems consistent.

As an implementation detail, we replace 0 with getpid(), so the existing
pid != 0 <==> "will exec" logic continues to work unchanged.

A reasonable alternative would be to interpret just `taskset` (currently
an error) as printing the current mask.  This seems less orthogonal,
and a better use may be found for plain `taskset` in the future.

Signed-off-by: Jesse Rosenstock <jmr@google.com>
6 weeks agolib/path: avoid double free() for cpusets
Karel Zak [Wed, 2 Jul 2025 10:25:45 +0000 (12:25 +0200)] 
lib/path: avoid double free() for cpusets

Addresses: https://github.com/util-linux/util-linux/issues/3641
Signed-off-by: Karel Zak <kzak@redhat.com>
6 weeks agolsblk: fix possible use-after-free
Karel Zak [Wed, 2 Jul 2025 09:48:22 +0000 (11:48 +0200)] 
lsblk: fix possible use-after-free

Signed-off-by: Karel Zak <kzak@redhat.com>
6 weeks agoMerge branch 'bash-completion-enosys' of https://github.com/akinomyoga/util-linux
Karel Zak [Wed, 2 Jul 2025 09:15:01 +0000 (11:15 +0200)] 
Merge branch 'bash-completion-enosys' of https://github.com/akinomyoga/util-linux

* 'bash-completion-enosys' of https://github.com/akinomyoga/util-linux:
  bash-completion: fix function name of enosys completion

6 weeks agoMerge branch 'man-exit-status' of https://github.com/jmr/util-linux
Karel Zak [Wed, 2 Jul 2025 09:06:43 +0000 (11:06 +0200)] 
Merge branch 'man-exit-status' of https://github.com/jmr/util-linux

* 'man-exit-status' of https://github.com/jmr/util-linux:
  man: Replace RETURN VALUE with EXIT STATUS in section 1

6 weeks agorename: change "expression" to "substring"
Haelwenn (lanodan) Monnier [Tue, 1 Jul 2025 16:01:05 +0000 (18:01 +0200)] 
rename: change "expression" to "substring"

As rename(1) doesn't uses an expression (like regex or glob) but rather a substring.

6 weeks agobash-completion: fix function name of enosys completion
Koichi Murase [Tue, 1 Jul 2025 13:39:23 +0000 (22:39 +0900)] 
bash-completion: fix function name of enosys completion

The function "_enosys_module" referenced by the completion setting on
the last line of "bash-completion/enosys" is not defined in the
current master.  As reported in Ref. [1], this causes the following
error on an attempt at argument completion for the "enosys" command:

  bash: _enosys_module: command not found

[1] https://www.reddit.com/r/Fedora/comments/1llmu0w/comment/n00y98k/

Also, the function "_waitpid_module" defined in
"bash-completion/enosys" overwrites another completion function of the
same name defined in "bash-completion/waitpid".  This patch renames
the function in "bash-completion/enosys" to the correct one,
"_enosys_module".

6 weeks agomore: Use ul_strtou16() in a robust way
Karel Zak [Tue, 1 Jul 2025 08:09:46 +0000 (10:09 +0200)] 
more: Use ul_strtou16() in a robust way

Signed-off-by: Karel Zak <kzak@redhat.com>
6 weeks agolsblk: fix memory leak [coverity scan]
Karel Zak [Tue, 1 Jul 2025 08:00:19 +0000 (10:00 +0200)] 
lsblk: fix memory leak [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
6 weeks agoMerge branch 'PR/Benno-27Jun' of https://github.com/karelzak/util-linux-work
Karel Zak [Tue, 1 Jul 2025 07:57:25 +0000 (09:57 +0200)] 
Merge branch 'PR/Benno-27Jun' of https://github.com/karelzak/util-linux-work

* 'PR/Benno-27Jun' of https://github.com/karelzak/util-linux-work:
  lsclocks: (man) remove stray backslash, and correct short form of --time
  script: (man,usage) correct the markup of the synopsis
  chrt: (man) mark "argument" as optional, and unabbreviate it in usage
  chrt: (man) correct the short form of --ext, from -d to -e

6 weeks agoMerge branch 'PR/more-busy-loop' of https://github.com/karelzak/util-linux-work
Karel Zak [Tue, 1 Jul 2025 07:56:51 +0000 (09:56 +0200)] 
Merge branch 'PR/more-busy-loop' of https://github.com/karelzak/util-linux-work

* 'PR/more-busy-loop' of https://github.com/karelzak/util-linux-work:
  more: temporarily ignore stdin when waiting for stderr

6 weeks agoMerge branch 'PR/strv-prefix' of https://github.com/karelzak/util-linux-work
Karel Zak [Tue, 1 Jul 2025 07:56:22 +0000 (09:56 +0200)] 
Merge branch 'PR/strv-prefix' of https://github.com/karelzak/util-linux-work

* 'PR/strv-prefix' of https://github.com/karelzak/util-linux-work:
  lib/strutils: add ul_ prefix to strrep() and strrem() functions
  lib/strutils: add ul_ prefix to split() function
  lib/strutils: add ul_ prefix to strappend() functions
  lib/strutils: add ul_ prefix to strconcat() functions
  lib/strutils: add ul_ prefix to startswith() and endswith()
  lib/strv: use ul_ prefix for strv functions

6 weeks agoman: Replace RETURN VALUE with EXIT STATUS in section 1
Jesse Rosenstock [Mon, 30 Jun 2025 18:32:49 +0000 (20:32 +0200)] 
man: Replace RETURN VALUE with EXIT STATUS in section 1

According to man-pages(7), sections 1 and 8 should normally use
EXIT STATUS, while sections 2 and 3 should use RETURN VALUE.

https://man7.org/linux/man-pages/man7/man-pages.7.html

Signed-off-by: Jesse Rosenstock <jmr@google.com>
6 weeks agolsclocks: (man) remove stray backslash, and correct short form of --time
Benno Schulenberg [Fri, 27 Jun 2025 12:04:08 +0000 (14:04 +0200)] 
lsclocks: (man) remove stray backslash, and correct short form of --time

This fixes commits 98f4e4833c and e9ddea7912.

CC: Thomas Weißschuh <thomas@t-8ch.de>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
6 weeks agoscript: (man,usage) correct the markup of the synopsis
Benno Schulenberg [Fri, 27 Jun 2025 12:04:07 +0000 (14:04 +0200)] 
script: (man,usage) correct the markup of the synopsis

Also, use the word "command", to match the wording for the --command
option, and improve the wording of the description of that option.

This fixes 7268e79bc5.

CC: WanBingjiang <wanbingjiang@webray.com.cn>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
6 weeks agochrt: (man) mark "argument" as optional, and unabbreviate it in usage
Benno Schulenberg [Wed, 25 Jun 2025 08:09:48 +0000 (10:09 +0200)] 
chrt: (man) mark "argument" as optional, and unabbreviate it in usage

Also, consistently uppercase "PID", to indicate it is an abbreviation,
and align the strings properly.

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
6 weeks agochrt: (man) correct the short form of --ext, from -d to -e
Benno Schulenberg [Wed, 25 Jun 2025 08:09:47 +0000 (10:09 +0200)] 
chrt: (man) correct the short form of --ext, from -d to -e

This fixes 3e667cf7ed from last month.

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
6 weeks agomore: temporarily ignore stdin when waiting for stderr
Karel Zak [Mon, 30 Jun 2025 10:20:13 +0000 (12:20 +0200)] 
more: temporarily ignore stdin when waiting for stderr

more waits for user commands on stderr, but at the same time, it
monitors sigalfd and stdin (for data and POLLHUP|POLLNVAL). We need to
temporarily ignore stdin if there is new data waiting for read()
(e.g., dmesg | more); otherwise, more_key_command() will end in a busy
loop.

Fixes: https://github.com/util-linux/util-linux/issues/3634
Signed-off-by: Karel Zak <kzak@redhat.com>
6 weeks agoMerge branch 'fix-lsblk-empty-type' of https://github.com/codefiles/util-linux
Karel Zak [Mon, 30 Jun 2025 09:34:36 +0000 (11:34 +0200)] 
Merge branch 'fix-lsblk-empty-type' of https://github.com/codefiles/util-linux

* 'fix-lsblk-empty-type' of https://github.com/codefiles/util-linux:
  lsblk: use md as fallback TYPE when md/level empty

6 weeks agolib/strutils: add ul_ prefix to strrep() and strrem() functions
Karel Zak [Mon, 30 Jun 2025 09:15:30 +0000 (11:15 +0200)] 
lib/strutils: add ul_ prefix to strrep() and strrem() functions

Addresses: https://github.com/util-linux/util-linux/issues/3626
Signed-off-by: Karel Zak <kzak@redhat.com>
6 weeks agolib/strutils: add ul_ prefix to split() function
Karel Zak [Mon, 30 Jun 2025 09:15:30 +0000 (11:15 +0200)] 
lib/strutils: add ul_ prefix to split() function

Addresses: https://github.com/util-linux/util-linux/issues/3626
Signed-off-by: Karel Zak <kzak@redhat.com>
6 weeks agolib/strutils: add ul_ prefix to strappend() functions
Karel Zak [Mon, 30 Jun 2025 09:15:30 +0000 (11:15 +0200)] 
lib/strutils: add ul_ prefix to strappend() functions

Addresses: https://github.com/util-linux/util-linux/issues/3626
Signed-off-by: Karel Zak <kzak@redhat.com>
6 weeks agolib/strutils: add ul_ prefix to strconcat() functions
Karel Zak [Mon, 30 Jun 2025 09:15:30 +0000 (11:15 +0200)] 
lib/strutils: add ul_ prefix to strconcat() functions

Addresses: https://github.com/util-linux/util-linux/issues/3626
Signed-off-by: Karel Zak <kzak@redhat.com>
6 weeks agolib/strutils: add ul_ prefix to startswith() and endswith()
Karel Zak [Mon, 30 Jun 2025 09:15:30 +0000 (11:15 +0200)] 
lib/strutils: add ul_ prefix to startswith() and endswith()

Addresses: https://github.com/util-linux/util-linux/issues/3626
Signed-off-by: Karel Zak <kzak@redhat.com>
6 weeks agolsblk: use md as fallback TYPE when md/level empty
codefiles [Sat, 28 Jun 2025 00:53:16 +0000 (20:53 -0400)] 
lsblk: use md as fallback TYPE when md/level empty

7 weeks agogitignore: Ignore tests/diff/ and test/output/
Jesse Rosenstock [Fri, 27 Jun 2025 08:27:25 +0000 (10:27 +0200)] 
gitignore: Ignore tests/diff/ and test/output/

These are auto-generated and clutter git status.
It's even worse with jj, which will auto-add them.

Signed-off-by: Jesse Rosenstock <jmr@google.com>
7 weeks agolib/strv: use ul_ prefix for strv functions
Karel Zak [Thu, 26 Jun 2025 11:47:00 +0000 (13:47 +0200)] 
lib/strv: use ul_ prefix for strv functions

The functions are originally from systemd/udev, so it's possible that
during static linking, they may collide with other systemd-based
components.

Fixes: https://github.com/util-linux/util-linux/issues/3626
Signed-off-by: Karel Zak <kzak@redhat.com>
7 weeks agobash-completion: add choom and coresched
Karel Zak [Thu, 26 Jun 2025 09:14:11 +0000 (11:14 +0200)] 
bash-completion: add choom and coresched

Addresses: https://github.com/util-linux/util-linux/issues/3469
Signed-off-by: Karel Zak <kzak@redhat.com>
7 weeks agoMerge branch 'master' of https://github.com/ndrake/util-linux
Karel Zak [Thu, 26 Jun 2025 09:02:59 +0000 (11:02 +0200)] 
Merge branch 'master' of https://github.com/ndrake/util-linux

* 'master' of https://github.com/ndrake/util-linux:
  Add missing ;; to -m case (#1)

7 weeks agoAdd missing ;; to -m case (#1)
Nate Drake [Wed, 25 Jun 2025 22:39:05 +0000 (18:39 -0400)] 
Add missing ;; to -m case (#1)