Util-Linux package development
 help / color / mirror / Atom feed
* [PATCH] man: Replace RETURN VALUE with EXIT STATUS in section 1
From: Jesse Rosenstock @ 2025-06-30 18:59 UTC (permalink / raw)
  To: util-linux

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

https://github.com/util-linux/util-linux/pull/3638

Signed-off-by: Jesse Rosenstock <jmr@google.com>
---
 schedutils/coresched.1.adoc | 2 +-
 schedutils/taskset.1.adoc   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/schedutils/coresched.1.adoc b/schedutils/coresched.1.adoc
index 997b6ab36e..483fff9929 100644
--- a/schedutils/coresched.1.adoc
+++ b/schedutils/coresched.1.adoc
@@ -96,7 +96,7 @@
 Retrieving or modifying the core scheduling cookie of a process
requires *PTRACE_MODE_READ_REALCREDS* ptrace access to that process.
 See the section "Ptrace access mode checking" in *ptrace*(2) for more
information.

-== RETURN VALUE
+== EXIT STATUS
 On success, *{command}* returns 0.
 If *{command}* fails, it will print an error and return 1.

diff --git a/schedutils/taskset.1.adoc b/schedutils/taskset.1.adoc
index 9773303f73..9384347372 100644
--- a/schedutils/taskset.1.adoc
+++ b/schedutils/taskset.1.adoc
@@ -106,7 +106,7 @@

 A user can change the CPU affinity of a process belonging to the same
user. A user must possess *CAP_SYS_NICE* to change the CPU affinity of
a process belonging to another user. A user can retrieve the affinity
mask of any process.

-== RETURN VALUE
+== EXIT STATUS

 *taskset* returns 0 in its affinity-getting mode as long as the
provided PID exists.

^ permalink raw reply related

* [PATCH] taskset: Accept 0 pid for current process
From: Jesse Rosenstock @ 2025-06-30 18:28 UTC (permalink / raw)
  To: util-linux

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.

https://github.com/util-linux/util-linux/pull/3637

Signed-off-by: Jesse Rosenstock <jmr@google.com>
---
 schedutils/taskset.1.adoc |  8 ++++++++
 schedutils/taskset.c      | 10 +++++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/schedutils/taskset.1.adoc b/schedutils/taskset.1.adoc
index 9773303f73..ebd9fdafe8 100644
--- a/schedutils/taskset.1.adoc
+++ b/schedutils/taskset.1.adoc
@@ -77,6 +77,7 @@

 *-p*, *--pid*::
 Operate on an existing PID and do not launch a new task.
+If PID is zero, then operate on the *taskset* process.

 include::man-common/help-version.adoc[]

@@ -134,6 +135,13 @@
 $ echo $? +
 1 +

+== EXAMPLES
+
+Print the current CPU affinity.
+
+$ taskset -pc 0 +
+pid 1355988's current affinity list: 0-47 +
+
 == AUTHORS

 Written by Robert M. Love.
diff --git a/schedutils/taskset.c b/schedutils/taskset.c
index b52cd4338b..40ccbb7342 100644
--- a/schedutils/taskset.c
+++ b/schedutils/taskset.c
@@ -186,7 +186,15 @@
                        all_tasks = 1;
                        break;
                case 'p':
-                       pid = strtopid_or_err(argv[argc - 1],
_("invalid PID argument"));
+                       // Like strtopid_or_err() but accept 0 for this process,
+                       // like sched_getaffinity()/sched_setaffinity() do.
+                       pid = (pid_t) str2num_or_err(
+                               argv[argc - 1], 10, _("invalid PID argument"),
+                               0, SINT_MAX(pid_t));
+                       if (pid == 0)
+                               pid = getpid();
+                       // After this point, pid == 0 means "no pid" and that
+                       // we will exec a command.
                        break;
                case 'c':
                        ts.use_list = 1;

^ permalink raw reply related

* Feature Request allow using chsh unattended
From: james smith @ 2025-06-30 18:14 UTC (permalink / raw)
  To: util-linux

if I do chsh -s /bin/zsh --unattended, it uses the previous
sudo/privilege escalation  used in a command, ie sudo apt update, then
chsh -s /bin/zsh --unattended it will not ask me for the password

^ permalink raw reply

* Re: [PATCH] rename: change "expression" to "original"
From: Karel Zak @ 2025-06-30 12:08 UTC (permalink / raw)
  To: Benno Schulenberg; +Cc: util-linux, Haelwenn (lanodan) Monnier
In-Reply-To: <00bb2e9d-cf47-489c-a881-81ab2edc2fe3@telfort.nl>

On Sun, Jun 22, 2025 at 05:51:39PM +0200, Benno Schulenberg wrote:
> 
> Op 22-06-2025 om 01:26 schreef Haelwenn (lanodan) Monnier:
> >   == SYNOPSIS
> > -*rename* [options] _expression replacement file_...
> > +*rename* [options] _original replacement file_...

Yes, the current situation ("expression") is unreadable.

> >   == DESCRIPTION
> > -*rename* will rename the specified files by replacing the first occurrence of _expression_ in their name by _replacement_.
> > +*rename* will rename the specified files by replacing the first occurrence of the _original_ substring in their name by _replacement_.
> 
> Instead of using the word "original" (where I would first think: original
> what?), why not use "substring"?  It describes what the thing actually is,
> and fits better in the rest of the existing wording.

It seems that in documentation for replace-like functions, it's common  
to use "substring", sometimes the function itself uses "substring" in its name  
(e.g., awk gsub()).
 
Haelwenn, do you want to update the patch?

    Karel




-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com


^ permalink raw reply

* Re: [PATCH] gitignore: Ignore tests/diff/ and test/output/
From: Karel Zak @ 2025-06-30 11:56 UTC (permalink / raw)
  To: Jesse Rosenstock; +Cc: util-linux
In-Reply-To: <CAMZQ0r+p--qJmjEFSTby67Rmb364A48gH9W_4RQrr+wwkJkdRw@mail.gmail.com>

On Fri, Jun 27, 2025 at 12:38:54PM +0200, Jesse Rosenstock wrote:
> https://github.com/util-linux/util-linux/pull/3630

Applied, thanks.

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com


^ permalink raw reply

* [PATCH 4/4] chrt: do not try to interpret any other option as a PID either
From: Benno Schulenberg @ 2025-06-30  8:40 UTC (permalink / raw)
  To: util-linux; +Cc: Madadi Vineeth Reddy
In-Reply-To: <20250630084052.11041-1-bensberg@telfort.nl>

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>
---
 schedutils/chrt.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/schedutils/chrt.c b/schedutils/chrt.c
index f5ecae6e1..f358bb273 100644
--- a/schedutils/chrt.c
+++ b/schedutils/chrt.c
@@ -474,11 +474,7 @@ int main(int argc, char **argv)
 			policy_given = true;
 			break;
 		case 'p':
-			if (argc - optind == 0)
-				errx(EXIT_FAILURE, _("too few arguments"));
-			errno = 0;
-			/* strtopid_or_err() is not suitable here; 0 can be passed.*/
-			ctl->pid = strtos32_or_err(argv[argc - 1], _("invalid PID argument"));
+			ctl->pid = 0;  /* indicate that a PID is expected */
 			break;
 		case 'r':
 			ctl->policy = SCHED_RR;
@@ -507,18 +503,20 @@ int main(int argc, char **argv)
 		}
 	}
 
-	if (argc - optind < (ctl->pid > -1 ? 1 : 2))
+	if (argc - optind < (ctl->pid == 0 ? 1 : 2))
 		errx(EXIT_FAILURE, _("too few arguments"));
 
-	/* pid exists but priority not given */
-	if (ctl->pid > -1 && argc - optind == 1) {
-		/* Error if priority is missing for a policy that requires it */
-		if (policy_given && need_prio)
-			errx(EXIT_FAILURE, ("policy %s requires a priority argument"),
+	/* If option --pid was given, parse the very last argument as a PID. */
+	if (ctl->pid == 0) {
+		if (need_prio && argc - optind < 2)
+			errx(EXIT_FAILURE, _("policy %s requires a priority argument"),
 						get_policy_name(ctl->policy));
+		errno = 0;
+		/* strtopid_or_err() is not suitable here, as 0 can be passed. */
+		ctl->pid = strtos32_or_err(argv[argc - 1], _("invalid PID argument"));
 
-		/* If no policy specified, show current settings */
-		if (!policy_given) {
+		/* If no policy nor priority was given, show current settings. */
+		if (!policy_given && argc - optind == 1) {
 			show_sched_info(ctl);
 			return EXIT_SUCCESS;
 		}
-- 

Dobjátok a Dunába a kis diktátort.

2.48.1


^ permalink raw reply related

* [PATCH 3/4] chrt: simplify the other check for too few arguments
From: Benno Schulenberg @ 2025-06-30  8:40 UTC (permalink / raw)
  To: util-linux; +Cc: Madadi Vineeth Reddy
In-Reply-To: <20250630084052.11041-1-bensberg@telfort.nl>

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, and do not annoyingly
suggest that the user try `chrt --help`.

CC: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
---
 schedutils/chrt.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/schedutils/chrt.c b/schedutils/chrt.c
index 8ed4d69f3..f5ecae6e1 100644
--- a/schedutils/chrt.c
+++ b/schedutils/chrt.c
@@ -507,11 +507,8 @@ int main(int argc, char **argv)
 		}
 	}
 
-	if (((ctl->pid > -1) && argc - optind < (need_prio ? 1 : 0)) ||
-	    ((ctl->pid == -1) && argc - optind < (need_prio ? 2 : 1))) {
-		warnx(_("bad usage"));
-		errtryhelp(EXIT_FAILURE);
-	}
+	if (argc - optind < (ctl->pid > -1 ? 1 : 2))
+		errx(EXIT_FAILURE, _("too few arguments"));
 
 	/* pid exists but priority not given */
 	if (ctl->pid > -1 && argc - optind == 1) {
@@ -530,11 +527,10 @@ int main(int argc, char **argv)
 	if (ctl->verbose)
 		show_sched_info(ctl);
 
-	errno = 0;
-
-	if (need_prio || argc - optind > 1)
+	if (argc - optind > 1) {
+		errno = 0;
 		ctl->priority = strtos32_or_err(argv[optind], _("invalid priority argument"));
-	else
+	} else
 		ctl->priority = 0;
 
 	if (ctl->runtime && !supports_runtime_param(ctl->policy))
-- 

Dobjátok a Dunába a kis diktátort.

2.48.1


^ permalink raw reply related

* [PATCH 2/4] chrt: do not try to interpret the --pid option itself as a PID
From: Benno Schulenberg @ 2025-06-30  8:40 UTC (permalink / raw)
  To: util-linux; +Cc: Madadi Vineeth Reddy
In-Reply-To: <20250630084052.11041-1-bensberg@telfort.nl>

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

CC: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
---
 schedutils/chrt.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/schedutils/chrt.c b/schedutils/chrt.c
index 4c45eae80..8ed4d69f3 100644
--- a/schedutils/chrt.c
+++ b/schedutils/chrt.c
@@ -474,6 +474,8 @@ int main(int argc, char **argv)
 			policy_given = true;
 			break;
 		case 'p':
+			if (argc - optind == 0)
+				errx(EXIT_FAILURE, _("too few arguments"));
 			errno = 0;
 			/* strtopid_or_err() is not suitable here; 0 can be passed.*/
 			ctl->pid = strtos32_or_err(argv[argc - 1], _("invalid PID argument"));
-- 

Dobjátok a Dunába a kis diktátort.

2.48.1


^ permalink raw reply related

* [PATCH 1/4] chrt: with more than one argument, interpret first argument as priority
From: Benno Schulenberg @ 2025-06-30  8:40 UTC (permalink / raw)
  To: util-linux; +Cc: Madadi Vineeth Reddy

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.

CC: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
---
 schedutils/chrt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/schedutils/chrt.c b/schedutils/chrt.c
index 0bcdd1a1e..4c45eae80 100644
--- a/schedutils/chrt.c
+++ b/schedutils/chrt.c
@@ -530,7 +530,7 @@ int main(int argc, char **argv)
 
 	errno = 0;
 
-	if (need_prio || argc - optind == 2)
+	if (need_prio || argc - optind > 1)
 		ctl->priority = strtos32_or_err(argv[optind], _("invalid priority argument"));
 	else
 		ctl->priority = 0;
-- 

Dobjátok a Dunába a kis diktátort.

2.48.1


^ permalink raw reply related

* [PATCH 1/2] script: (man,usage) correct the markup of the synopsis
From: Benno Schulenberg @ 2025-06-27 12:04 UTC (permalink / raw)
  To: util-linux; +Cc: WanBingjiang

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>
---
 term-utils/script.1.adoc | 5 +++--
 term-utils/script.c      | 8 ++++----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/term-utils/script.1.adoc b/term-utils/script.1.adoc
index 688ec5e2d..b4bec0c02 100644
--- a/term-utils/script.1.adoc
+++ b/term-utils/script.1.adoc
@@ -49,7 +49,7 @@ script - make typescript of terminal session
 
 == SYNOPSIS
 
-*script* [options] [_file_] [ -- program [arguments]]
+*script* [options] [_file_] [*--* _command_ [_argument_...]]
 
 == DESCRIPTION
 
@@ -69,7 +69,8 @@ Below, the _size_ argument may be followed by the multiplicative suffixes KiB (=
 Append the output to _file_ or to _typescript_, retaining the prior contents.
 
 *-c*, *--command* _command_::
-Run the _command_ rather than an interactive shell. This makes it easy for a script to capture the output of a program that behaves differently when its stdout is not a tty. It's possible to specify the command after '--' too.
+Run the _command_ rather than an interactive shell. This makes it easy for a script to capture the output of a program that behaves differently when its stdout is not a tty.
+Instead of using option *-c*, the _command_ may also be specified after a double dash (*--*).
 
 *-E*, *--echo* _when_::
 This option controls the *ECHO* flag for the slave end of the session's pseudoterminal. The supported modes are _always_, _never_, or _auto_.
diff --git a/term-utils/script.c b/term-utils/script.c
index 80ea477ab..7ba57a6a6 100644
--- a/term-utils/script.c
+++ b/term-utils/script.c
@@ -191,7 +191,7 @@ static void __attribute__((__noreturn__)) usage(void)
 {
 	FILE *out = stdout;
 	fputs(USAGE_HEADER, out);
-	fprintf(out, _(" %s [options] [file] [-- program [arguments]]\n"), program_invocation_short_name);
+	fprintf(out, _(" %s [options] [<file>] [-- <command> [<argument>...]]\n"), program_invocation_short_name);
 
 	fputs(USAGE_SEPARATOR, out);
 	fputs(_("Make a typescript of a terminal session.\n"), out);
@@ -208,8 +208,8 @@ static void __attribute__((__noreturn__)) usage(void)
 	fputs(USAGE_SEPARATOR, out);
 
 	fputs(_(" -a, --append                  append to the log file\n"), out);
-	fputs(_(" -c, --command <command>       run command rather than interactive shell\n"
-		"                                 (alternative to '-- program [arguments]')\n"), out);
+	fputs(_(" -c, --command <command>       run <command> rather than an interactive shell\n"
+		"                                 (alternative to '-- <command> [<argument...>]')\n"), out);
 	fputs(_(" -e, --return                  return exit code of the child process\n"), out);
 	fputs(_(" -f, --flush                   run flush after each write\n"), out);
 	fputs(_("     --force                   use output file even when it is a link\n"), out);
@@ -930,7 +930,7 @@ int main(int argc, char **argv)
 	/* concat non-option arguments as command */
 	if (argc > 0 && strcmp(argv[-1], "--") == 0) {
 		if (ctl.command != NULL) {
-			warnx(_("option --command and '-- program' are mutually exclusive"));
+			warnx(_("option --command and a command after '--' cannot be combined"));
 			errtryhelp(EXIT_FAILURE);
 		}
 
-- 
2.48.1


^ permalink raw reply related

* [PATCH 2/2] lsclocks: (man) remove stray backslash, and correct short form of --time
From: Benno Schulenberg @ 2025-06-27 12:04 UTC (permalink / raw)
  To: util-linux; +Cc: Thomas Weißschuh
In-Reply-To: <20250627120408.11036-1-bensberg@telfort.nl>

This fixes commits 98f4e4833c and e9ddea7912.

CC: Thomas Weißschuh <thomas@t-8ch.de>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
---
 misc-utils/lsclocks.1.adoc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/misc-utils/lsclocks.1.adoc b/misc-utils/lsclocks.1.adoc
index cfe984d5e..ffd3c4049 100644
--- a/misc-utils/lsclocks.1.adoc
+++ b/misc-utils/lsclocks.1.adoc
@@ -21,7 +21,7 @@ lsclocks - display system clocks
 It allows to display information like current time and resolution of clocks.
 Different kinds of clocks are supported.
 
-* POSIX clocks: *CLOCK_MONOTONIC*, *CLOCK_REALTIME*, *CLOCK_BOOTTIME*\, etc.
+* POSIX clocks: *CLOCK_MONOTONIC*, *CLOCK_REALTIME*, *CLOCK_BOOTTIME*, etc.
 * CPU clocks: *clock_getcpuclockid()*.
 * PTP clocks: */dev/ptp0*.
 * RTC clocks: */dev/rtc0*.
@@ -44,7 +44,7 @@ Output all columns.
 *-r*, *--raw*::
 Use raw output format.
 
-*-r*, *--time* _clock_::
+*-t*, *--time* _clock_::
 Show current time of one specific clock.
 
 *--no-discover-dynamic*::
-- 
2.48.1


^ permalink raw reply related

* Re: [PATCH] chrt: when more than one argument, interpret first argument as priority
From: Benno Schulenberg @ 2025-06-27 11:32 UTC (permalink / raw)
  To: Madadi Vineeth Reddy, util-linux
In-Reply-To: <9a721a20-0836-44db-b0cc-7d48f853318c@linux.ibm.com>


[-- Attachment #1.1: Type: text/plain, Size: 1260 bytes --]


Op 27-06-2025 om 10:38 schreef Madadi Vineeth Reddy:
> On 26/06/25 16:57, Benno Schulenberg wrote:
>> The first argument is a priority not only for `chrt --pid <prio> <pid>`
>> but also for `chrt <prio> <command> [<argument>...]`.
> 
> Good catch. SCHED_RR is indeed taken by default when no policy is given.
> 
> We could address this by initializing `need_prio` to `true` by default,
> and then setting it to `false` in the corresponding switch cases for
> policies that don't require a priority.

Well, that change is redundant with my proposed change.

Also, setting 'need_prio' to true by default gives a somewhat wrong
impression, because no priority is needed when only option --pid is
given.

What your proposed change accomplishes is that the error message
for the mistaken `./chrt somecommand` changes from:

   chrt: unsupported priority value for the policy: 0: see --max for valid range

to:

   chrt: bad usage
   Try 'chrt --help' for more information.

I think both error messages are equally poor -- the first is puzzling,
the second too unspecific.  It would be better to combine your change
with more specific feedback, depending on whether --pid was given.  I'll
send a better patch next week.


Benno


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply

* [PATCH] gitignore: Ignore tests/diff/ and test/output/
From: Jesse Rosenstock @ 2025-06-27 10:38 UTC (permalink / raw)
  To: util-linux

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

https://github.com/util-linux/util-linux/pull/3630

Signed-off-by: Jesse Rosenstock <jmr@google.com>
---
 .gitignore | 2 ++
 1 file changed, 2 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore
index 8764bbe3f4..305e651532 100644
--- a/.gitignore
+++ b/.gitignore
@@ -66,7 +66,9 @@
 syscalls.h
 tags
 test-suite.log
+tests/diff/
 tests/failures
+tests/output/
 tests/run.sh.log
 tests/run.sh.trs
 update.log

^ permalink raw reply related

* Re: [PATCH] chrt: when more than one argument, interpret first argument as priority
From: Madadi Vineeth Reddy @ 2025-06-27  8:38 UTC (permalink / raw)
  To: Benno Schulenberg, util-linux; +Cc: Madadi Vineeth Reddy
In-Reply-To: <20250626112743.9862-1-bensberg@telfort.nl>

Hi Benno,

On 26/06/25 16:57, Benno Schulenberg wrote:
> The first argument is a priority not only for `chrt --pid <prio> <pid>`
> but also for `chrt <prio> <command> [<argument>...]`.
> 

Good catch. SCHED_RR is indeed taken by default when no policy is given.

We could address this by initializing `need_prio` to `true` by default,
and then setting it to `false` in the corresponding switch cases for
policies that don't require a priority.  

This change could be added to your patch like below:

diff --git a/schedutils/chrt.c b/schedutils/chrt.c
index 0bcdd1a1e..02b202ff4 100644
--- a/schedutils/chrt.c
+++ b/schedutils/chrt.c
@@ -399,7 +399,7 @@ int main(int argc, char **argv)
 {
        struct chrt_ctl _ctl = { .pid = -1, .policy = SCHED_RR }, *ctl = &_ctl;
        int c;
-       bool policy_given = false, need_prio = false;
+       bool policy_given = false, need_prio = true;
 
        static const struct option longopts[] = {
                { "all-tasks",  no_argument, NULL, 'a' },
@@ -437,6 +437,7 @@ int main(int argc, char **argv)
 #ifdef SCHED_BATCH
                        ctl->policy = SCHED_BATCH;
                        policy_given = true;
+                       need_prio = false;
 #endif
                        break;
 
@@ -444,18 +445,19 @@ int main(int argc, char **argv)
 #ifdef SCHED_DEADLINE
                        ctl->policy = SCHED_DEADLINE;
                        policy_given = true;
+                       need_prio = false;
 #endif
                        break;
                case 'e':
 #ifdef SCHED_EXT
                        ctl->policy = SCHED_EXT;
                        policy_given = true;
+                       need_prio = false;
 #endif
                        break;
                case 'f':
                        ctl->policy = SCHED_FIFO;
                        policy_given = true;
-                       need_prio = true;
                        break;
                case 'R':
                        ctl->reset_on_fork = 1;
@@ -464,6 +466,7 @@ int main(int argc, char **argv)
 #ifdef SCHED_IDLE
                        ctl->policy = SCHED_IDLE;
                        policy_given = true;
+                       need_prio = false;
 #endif
                        break;
                case 'm':
@@ -472,6 +475,7 @@ int main(int argc, char **argv)
                case 'o':
                        ctl->policy = SCHED_OTHER;
                        policy_given = true;
+                       need_prio = false;
                        break;
                case 'p':
                        errno = 0;
@@ -481,7 +485,6 @@ int main(int argc, char **argv)
                case 'r':
                        ctl->policy = SCHED_RR;
                        policy_given = true;
-                       need_prio = true;
                        break;
                case 'v':
                        ctl->verbose = 1;
@@ -530,7 +533,7 @@ int main(int argc, char **argv)
 
        errno = 0;
 
-       if (need_prio || argc - optind == 2)
+       if (need_prio || argc - optind > 1)
                ctl->priority = strtos32_or_err(argv[optind], _("invalid priority argument"));
        else
                ctl->priority = 0;

Let me know if I am missing anything.

Thanks,
Madadi Vineeth Reddy

> This fixes an oversight in recent commit e7a2d62434.
> 
> CC: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
> Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
> ---
>  schedutils/chrt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/schedutils/chrt.c b/schedutils/chrt.c
> index 0bcdd1a1e..4c45eae80 100644
> --- a/schedutils/chrt.c
> +++ b/schedutils/chrt.c
> @@ -530,7 +530,7 @@ int main(int argc, char **argv)
>  
>  	errno = 0;
>  
> -	if (need_prio || argc - optind == 2)
> +	if (need_prio || argc - optind > 1)
>  		ctl->priority = strtos32_or_err(argv[optind], _("invalid priority argument"));
>  	else
>  		ctl->priority = 0;


^ permalink raw reply related

* [PATCH] chrt: when more than one argument, interpret first argument as priority
From: Benno Schulenberg @ 2025-06-26 11:27 UTC (permalink / raw)
  To: util-linux; +Cc: Madadi Vineeth Reddy

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.

CC: Madadi Vineeth Reddy <vineethr@linux.ibm.com>
Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
---
 schedutils/chrt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/schedutils/chrt.c b/schedutils/chrt.c
index 0bcdd1a1e..4c45eae80 100644
--- a/schedutils/chrt.c
+++ b/schedutils/chrt.c
@@ -530,7 +530,7 @@ int main(int argc, char **argv)
 
 	errno = 0;
 
-	if (need_prio || argc - optind == 2)
+	if (need_prio || argc - optind > 1)
 		ctl->priority = strtos32_or_err(argv[optind], _("invalid priority argument"));
 	else
 		ctl->priority = 0;
-- 
2.48.1


^ permalink raw reply related

* behavior of `chrt` changed when specifying a command
From: Benno Schulenberg @ 2025-06-25 14:42 UTC (permalink / raw)
  To: util-linux; +Cc: Madadi Vineeth Reddy


[-- Attachment #1.1: Type: text/plain, Size: 668 bytes --]


Before the recent changes to chrt.c (commit e7a2d62434 and earlier),
one could let `chrt` run a command while specifying only a priority,
leaving `chrt` to pick SCHED_RR as the default policy:

   chrt 12 grep boo README

This would print one line from the README.

But running that command in current git gives:

   chrt: unsupported priority value for the policy: 0: see --max for valid range

One has to specify the policy explicitly for the command to work:

   chrt -r 12 grep boo README

If that is intentional, then the synopsis needs to be adjusted to show the need
for a policy option when wanting to run a command with `chrt`.


Benno

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply

* [PATCH 2/2] chrt: (man) mark "argument" as optional, and unabbreviate it in usage
From: Benno Schulenberg @ 2025-06-25  8:09 UTC (permalink / raw)
  To: util-linux
In-Reply-To: <20250625080948.6064-1-bensberg@telfort.nl>

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

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
---
 schedutils/chrt.1.adoc | 2 +-
 schedutils/chrt.c      | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/schedutils/chrt.1.adoc b/schedutils/chrt.1.adoc
index 17d683ba7..3f67b13bb 100644
--- a/schedutils/chrt.1.adoc
+++ b/schedutils/chrt.1.adoc
@@ -38,7 +38,7 @@ chrt - manipulate the real-time attributes of a process
 
 == SYNOPSIS
 
-*chrt* [options] _priority command argument_ ...
+*chrt* [options] _priority command_ [_argument_...]
 
 *chrt* [options] *--pid* [_priority_] _PID_
 
diff --git a/schedutils/chrt.c b/schedutils/chrt.c
index 0bcdd1a1e..550cefe4d 100644
--- a/schedutils/chrt.c
+++ b/schedutils/chrt.c
@@ -60,11 +60,11 @@ static void __attribute__((__noreturn__)) usage(void)
 	fputs(_("Show or change the real-time scheduling attributes of a process.\n"), out);
 	fputs(USAGE_SEPARATOR, out);
 	fputs(_("Set policy:\n"
-	" chrt [options] <priority> <command> [<arg>...]\n"
-	" chrt [options] --pid <priority> <pid>\n"), out);
+		" chrt [options] <priority> <command> [<argument>...]\n"
+		" chrt [options] --pid <priority> <PID>\n"), out);
 	fputs(USAGE_SEPARATOR, out);
 	fputs(_("Get policy:\n"
-	" chrt --pid <pid>\n"), out);
+		" chrt --pid <PID>\n"), out);
 
 	fputs(USAGE_SEPARATOR, out);
 	fputs(_("Policy options:\n"), out);
-- 
2.48.1


^ permalink raw reply related

* [PATCH 1/2] chrt: (man) correct the short form of --ext, from -d to -e
From: Benno Schulenberg @ 2025-06-25  8:09 UTC (permalink / raw)
  To: util-linux

This fixes 3e667cf7ed from last month.

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
---
 schedutils/chrt.1.adoc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/schedutils/chrt.1.adoc b/schedutils/chrt.1.adoc
index 5b8d7e832..17d683ba7 100644
--- a/schedutils/chrt.1.adoc
+++ b/schedutils/chrt.1.adoc
@@ -66,7 +66,7 @@ Set scheduling policy to *SCHED_IDLE* (scheduling very low priority jobs). Linux
 *-d*, *--deadline*::
 Set scheduling policy to *SCHED_DEADLINE* (sporadic task model deadline scheduling). Linux-specific, supported since 3.14. Since util-linux v2.42, the priority argument is optional; if specified, it must be set to zero. See also *--sched-runtime*, *--sched-deadline* and *--sched-period*. The relation between the options required by the kernel is runtime <= deadline <= period. *chrt* copies _period_ to _deadline_ if *--sched-deadline* is not specified and _deadline_ to _runtime_ if *--sched-runtime* is not specified. It means that at least *--sched-period* has to be specified. See *sched*(7) for more details.
 
-*-d*, *--ext*::
+*-e*, *--ext*::
 Set scheduling policy to *SCHED_EXT* (BPF program-defined scheduling). Linux-specific, supported since 6.12. Since util-linux v2.42, the priority argument is optional; if specified, it must be set to zero.
 
 == SCHEDULING OPTIONS
-- 
2.48.1


^ permalink raw reply related

* Re: [PATCH v4 0/3] chrt: Improve argument handling and allow optional priority
From: Karel Zak @ 2025-06-24  9:21 UTC (permalink / raw)
  To: Madadi Vineeth Reddy; +Cc: util-linux, Benno Schulenberg
In-Reply-To: <20250621195048.24900-1-vineethr@linux.ibm.com>

On Sun, Jun 22, 2025 at 01:20:45AM +0530, Madadi Vineeth Reddy wrote:
> Changes in v4:
> - Rectified my mistake of not giving proper space in a comment in v3
> 
> Changes in v3: 
> - Made --pid consistent throughout (Karel Zak)
> - Change get policy to not have policy options (Karel Zak and Benno Schulenberg)
> 
> Changes in v2:
> - Updated the man page to reflect the optional priority behavior (Karel Zak)
> - Renamed variable to 'need_prio' (Karel Zak)
> 
> Madadi Vineeth Reddy (3):
>   chrt: Make minor cleanups in chrt
>   chrt: Only display current settings when no policy is specified
>   chrt: Make priority optional for policies that don't use it
> 
>  schedutils/chrt.1.adoc | 24 +++++++++++++----------
>  schedutils/chrt.c      | 43 +++++++++++++++++++++++++++++++++---------
>  2 files changed, 48 insertions(+), 19 deletions(-)

Applied, thanks!

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com


^ permalink raw reply

* [ANNOUNCE] util-linux v2.41.1
From: Karel Zak @ 2025-06-24  8:19 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel, util-linux


The util-linux stable release 2.41.1 is now available at
                                  
  http://www.kernel.org/pub/linux/utils/util-linux/v2.41/
                                  
Feedback and bug reports, as always, are welcomed.
                                  
  Karel         


util-linux 2.41.1 Release Notes
===============================

autotools:
    - don't use wide-character ncurses if --disable-widechar (by Karel Zak)

cfdisk:
    - fix memory leak and possible NULL dereference [gcc-analyzer] (by Karel Zak)

column:
    - fix compiler warning for non-widechar compilation (by Karel Zak)

fdformat:
    - use size_t and ssize_t (by Karel Zak)

fdisk:
    - fix possible memory leak (by Karel Zak)

fdisk,partx:
    - avoid strcasecmp() for ASCII-only strings (by Karel Zak)

findmnt:
    - fix -k option parsing regression (by Karel Zak)

hardlink:
    - define more function as inline (by Karel Zak)
    - fix performance regression (inefficient signal evaluation) (by Karel Zak)
    - Use macro for verbose output (by Karel Zak)

include/cctype:
    - fix string comparison (by Karel Zak)

include/mount-api-utils:
    - include linux/unistd.h (by Thomas Weißschuh)

libblkid:
    - Fix crash while parsing config with libeconf (by Stanislav Brabec)
    - befs fix underflow (by Milan Broz)
    - avoid strcasecmp() for ASCII-only strings (by Karel Zak)

libblkid/src/topology/dm:
    - fix fscanf return value check to match expected number of parsed items (by Mingjie Shen)

libfdisk:
    - avoid strcasecmp() for ASCII-only strings (by Karel Zak)

libmount:
    - (subdir) restrict for real mounts only (by Karel Zak)
    - (subdir) remove unused code (by Karel Zak)
    - avoid calling memset() unnecessarily (by Karel Zak)
    - avoid strcasecmp() for ASCII-only strings (by Karel Zak)
    - fix --no-canonicalize regression (by Karel Zak)

libuuid:
    - fix uuid_time on macOS without attribute((alias)) (by Eugene Gershnik)

lsblk:
    - use ID_PART_ENTRY_SCHEME as fallback for PTTYPE (by Karel Zak)
    - avoid strcasecmp() for ASCII-only strings (by Karel Zak)

lscpu:
    - fix possible buffer overflow in cpuinfo parser (by Karel Zak)
    - Fix loongarch op-mode output with recent kernel (by Xi Ruoyao)

lsfd:
    - (bug fix) scan the protocol field of /proc/net/packet as a hex number (by Masatake YAMATO)
    - fix the description for PACKET.PROTOCOL column (by Masatake YAMATO)

lsns:
    - enhance compilation without USE_NS_GET_API (by Karel Zak)
    - fix undefined reference to add_namespace_for_nsfd #3483 (by Thomas Devoogdt)

meson:
    - add feature for translated documentation (by Thomas Weißschuh)
    - remove tinfo dependency from 'more' (by Thomas Weißschuh)
    - fix manadocs for libsmartcols and libblkid (by Karel Zak)
    - fix po-man installation (by Karel Zak)

misc:
    - never include wchar.h (by Karel Zak)

more:
    - fix broken ':!command' command key (by cgoesche)
    - fix implicit previous shell_line execution #3508 (by cgoesche)

mount:
    - (man) add missing word (by Jakub Wilk)

namespace.h:
    - fix compilation on Linux < 4.10 (by Thomas Devoogdt)

po:
    - update uk.po (from translationproject.org) (by Yuri Chornoivan)
    - update sr.po (from translationproject.org) (by Мирослав Николић)
    - update ro.po (from translationproject.org) (by Remus-Gabriel Chelu)
    - update pt.po (from translationproject.org) (by Pedro Albuquerque)
    - update pl.po (from translationproject.org) (by Jakub Bogusz)
    - update nl.po (from translationproject.org) (by Benno Schulenberg)
    - update ja.po (from translationproject.org) (by YOSHIDA Hideki)
    - update hr.po (from translationproject.org) (by Božidar Putanec)
    - update fr.po (from translationproject.org) (by Frédéric Marchal)
    - update es.po (from translationproject.org) (by Antonio Ceballos Roa)
    - update de.po (from translationproject.org) (by Mario Blättermann)
    - update cs.po (from translationproject.org) (by Petr Písař)

po-man:
    - merge changes (by Karel Zak)
    - update sr.po (from translationproject.org) (by Мирослав Николић)
    - update de.po (from translationproject.org) (by Mario Blättermann)

tests:
    - (test_mkfds::mapped-packet-socket) add a new parameter, protocol (by Masatake YAMATO)

treewide:
    - add ul_ to parse_timestamp() function name (by Karel Zak)
    - add ul_ to parse_switch() function name (by Stanislav Brabec)
    - add ul_ to parse_size() function name (by Karel Zak)
    - add ul_ to parse_range() function name (by Karel Zak)
    - fix optional arguments usage (by Karel Zak)
    - avoid strcasecmp() for ASCII-only strings (by Karel Zak)

Wipefs:
    - improve --all descriptions for whole-disks (by Karel Zak)

Misc:
    - Do not call exit() on code ending in shared libraries (by Cristian Rodríguez)
    - remove two leftover license lines from colors.{c,h} (by Benno Schulenberg)
    - remove "Copyright (C) ...." notes from files that claim no copyright (by Benno Schulenberg)
    - correct the full name of the GPL in various files (by Benno Schulenberg)
    - Make scols_column_set_data_func docs visible (by FeRD (Frank Dana))
    - Do not use strerror on shared libraries (by Cristian Rodríguez)
    - Fix typo in blkdiscard docs (by pls-no-hack)
    - lib/fileeq.c Fix a typo in message. (by Masanari Iida)

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com


^ permalink raw reply

* Re: [PATCH] rename: change "expression" to "original"
From: Haelwenn (lanodan) Monnier @ 2025-06-22 21:34 UTC (permalink / raw)
  To: Nuno Silva; +Cc: util-linux
In-Reply-To: <87cyawp26b.fsf@ist.utl.pt>

[2025-06-22 10:23:12+0100] Nuno Silva:
>(Resending via mail only because the mailing list post with Cc hit an
>issue with Gmane, but was successfully delivered to the list.)

Ack, CC'd back the mailing-list so trail isn't lost

>On 2025-06-22, Haelwenn (lanodan) Monnier wrote:
>
>> As rename(1) doesn't uses an expression (like regex or glob) but
>> rather a substring.
>[...]
>> -*rename* [options] _expression replacement file_...
>> +*rename* [options] _original replacement file_...
>[...]
>
>Oh. I was aware of there being at least two different "rename" utilities
>on Linux systems, this one from util-linux and a perl-based one using
>regexes, but I hadn't noticed this wording in the online manual and
>usage output.
>
>Yes, this change probably helps telling it apart from the perl-based
>rename.
>
>(I don't recall what made confusion more prone in the case of this
>utility, was it that some distributions installed the perl one as
>"rename"?)

I know FreeBSD rename(1) is the perl one, and it seems like Debian
changed perl rename from `rename` to `file-rename` in bookworm:
Before: https://packages.debian.org/bullseye/rename
After: https://packages.debian.org/bookworm/rename

And has util-linux rename as `rename.ul`: https://packages.debian.org/bookworm/amd64/util-linux/filelist

Best regards

^ permalink raw reply

* Re: [PATCH] rename: change "expression" to "original"
From: Benno Schulenberg @ 2025-06-22 15:51 UTC (permalink / raw)
  To: util-linux; +Cc: Haelwenn (lanodan) Monnier
In-Reply-To: <20250621232642.17613-2-contact@hacktivis.me>


[-- Attachment #1.1: Type: text/plain, Size: 713 bytes --]


Op 22-06-2025 om 01:26 schreef Haelwenn (lanodan) Monnier:
>   == SYNOPSIS
>   
> -*rename* [options] _expression replacement file_...
> +*rename* [options] _original replacement file_...
>   
>   == DESCRIPTION
>   
> -*rename* will rename the specified files by replacing the first occurrence of _expression_ in their name by _replacement_.
> +*rename* will rename the specified files by replacing the first occurrence of the _original_ substring in their name by _replacement_.

Instead of using the word "original" (where I would first think: original
what?), why not use "substring"?  It describes what the thing actually is,
and fits better in the rest of the existing wording.


Benno


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]

^ permalink raw reply

* Re: [PATCH] rename: change "expression" to "original"
From: Dirk Gouders @ 2025-06-22 10:36 UTC (permalink / raw)
  To: util-linux; +Cc: Haelwenn (lanodan) Monnier
In-Reply-To: <1038hjr$5nr$1@ciao.gmane.io>

Resend with Cc address from original posting:

Nuno Silva <nunojsilva@ist.utl.pt> writes:

> On 2025-06-22, Haelwenn (lanodan) Monnier wrote:
>
>> As rename(1) doesn't uses an expression (like regex or glob) but
>> rather a substring.
> [...]
>> -*rename* [options] _expression replacement file_...
>> +*rename* [options] _original replacement file_...
> [...]
>
> Oh. I was aware of there being at least two different "rename" utilities
> on Linux systems, this one from util-linux and a perl-based one using
> regexes, but I hadn't noticed this wording in the online manual and
> usage output.
>
> Yes, this change probably helps telling it apart from the perl-based
> rename.

In case this change will be accepted, how about using other terms for
both, "expression / original" and "replacement"?  Could be that it is my
individual difficulty but I would way better understand something like:

*rename* [options] _string_1 string_2 file_...


Anyway, I guess the following should be fixed, regardless:

+If the _original_ is empty, then by default _replacement_ will...

=>

+If _original_ is empty, then by default _replacement_ will...

Regards,

Dirk

^ permalink raw reply

* Re: [PATCH] rename: change "expression" to "original"
From: Dirk Gouders @ 2025-06-22  9:49 UTC (permalink / raw)
  To: util-linux; +Cc: Haelwenn (lanodan) Monnier
In-Reply-To: <1038hjr$5nr$1@ciao.gmane.io>

Nuno Silva <nunojsilva@ist.utl.pt> writes:

> On 2025-06-22, Haelwenn (lanodan) Monnier wrote:
>
>> As rename(1) doesn't uses an expression (like regex or glob) but
>> rather a substring.
> [...]
>> -*rename* [options] _expression replacement file_...
>> +*rename* [options] _original replacement file_...
> [...]
>
> Oh. I was aware of there being at least two different "rename" utilities
> on Linux systems, this one from util-linux and a perl-based one using
> regexes, but I hadn't noticed this wording in the online manual and
> usage output.
>
> Yes, this change probably helps telling it apart from the perl-based
> rename.

In case this change will be accepted, how about using other terms for
both, "expression / original" and "replacement"?  Could be that it is my
individual difficulty but I would way better understand something like:

*rename* [options] _string_1 string_2 file_...


Anyway, I guess the following should be fixed, regardless:

+If the _original_ is empty, then by default _replacement_ will...

=>

+If _original_ is empty, then by default _replacement_ will...

Regards,

Dirk

^ permalink raw reply

* Re: [PATCH] rename: change "expression" to "original"
From: Nuno Silva @ 2025-06-22  9:15 UTC (permalink / raw)
  To: util-linux; +Cc: Haelwenn (lanodan) Monnier
In-Reply-To: <20250621232642.17613-2-contact@hacktivis.me>

On 2025-06-22, Haelwenn (lanodan) Monnier wrote:

> As rename(1) doesn't uses an expression (like regex or glob) but
> rather a substring.
[...]
> -*rename* [options] _expression replacement file_...
> +*rename* [options] _original replacement file_...
[...]

Oh. I was aware of there being at least two different "rename" utilities
on Linux systems, this one from util-linux and a perl-based one using
regexes, but I hadn't noticed this wording in the online manual and
usage output.

Yes, this change probably helps telling it apart from the perl-based
rename.

(I don't recall what made confusion more prone in the case of this
utility, was it that some distributions installed the perl one as
"rename"?)

-- 
Nuno Silva
Who hopes the Cc works properly.


^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox