Util-Linux package development
 help / color / mirror / Atom feed
* Re: bug in `more -c` when using . to repeat <enter>
From: Karel Zak @ 2025-03-17 10:58 UTC (permalink / raw)
  To: Benno Schulenberg; +Cc: util-linux
In-Reply-To: <b354fc17-f706-4a56-a271-592cd44a7b5d@telfort.nl>

On Sun, Mar 16, 2025 at 04:45:42PM GMT, Benno Schulenberg wrote:
> 
> To reproduce, run `./more -c README`.  Type <enter> a few times,
> and see that for each <enter> the screen scrolls one line to show
> another line of the README.  (Except when there is a blank line:
> then it scrolls two lines and shows two blank lines -- that is
> probably a separate bug.)
> 
> Now type . instead, which should repeat the last command, in this
> case <enter>.  See how the screen is cleared and just one line of
> the README is shown.  Keep typing . and see that each time just
> one line is displayed.  Typing . here behaves as if the user had
> typed 1 <enter>, not just <enter>.
> 
> Bug was found while using `./page README` after `ln -s more page`.
> But `./page` does not do the doubling of blank lines.

 Fixed, thanks for your report!

    Karel

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


^ permalink raw reply

* Re: [PATCH 1/3] irqtop,lsirq: set up locale path, so messages get actually translated
From: Karel Zak @ 2025-03-17 10:10 UTC (permalink / raw)
  To: Benno Schulenberg; +Cc: util-linux
In-Reply-To: <20250316152040.44163-3-bensberg@telfort.nl>

On Sun, Mar 16, 2025 at 04:20:37PM GMT, Benno Schulenberg wrote:
>  sys-utils/irqtop.c | 3 +++
>  sys-utils/lsirq.c  | 3 +++
>  2 files changed, 6 insertions(+)

On Sun, Mar 16, 2025 at 04:20:38PM GMT, Benno Schulenberg wrote:
>  text-utils/more.c | 1 -
>  1 file changed, 1 deletion(-)

On Sun, Mar 16, 2025 at 04:20:39PM GMT, Benno Schulenberg wrote:
>  disk-utils/cfdisk.8.adoc    | 4 ++--
>  disk-utils/fdisk.8.adoc     | 5 +----
>  disk-utils/swaplabel.8.adoc | 4 ++--
>  misc-utils/hardlink.1.adoc  | 3 +--
>  misc-utils/look.1.adoc      | 2 ++
>  misc-utils/lsblk.8.adoc     | 4 ++--
>  misc-utils/uuidgen.1.adoc   | 4 ++--
>  sys-utils/eject.1.adoc      | 4 ++--
>  sys-utils/lsmem.1.adoc      | 4 ++--
>  text-utils/bits.1.adoc      | 4 ++--
>  text-utils/rev.1.adoc       | 4 ++--
>  11 files changed, 20 insertions(+), 22 deletions(-)

All applied, thanks!

    Karel


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


^ permalink raw reply

* Re: [PATCH] swapon: make options --help and --version override --summary
From: Karel Zak @ 2025-03-17 10:08 UTC (permalink / raw)
  To: Benno Schulenberg; +Cc: util-linux
In-Reply-To: <20250313145149.10323-1-bensberg@telfort.nl>

On Thu, Mar 13, 2025 at 03:51:49PM GMT, Benno Schulenberg wrote:
>  sys-utils/swapon.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)

 Applied, thanks. 

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


^ permalink raw reply

* Re: [PATCH v2] lscpu: RISC-V: Print ISA information in summary
From: Karel Zak @ 2025-03-17 10:07 UTC (permalink / raw)
  To: Sunil V L
  Cc: util-linux, Andrew Jones, Anup Patel, Conor Dooley,
	Palmer Dabbelt, Alexandre Ghiti, Samuel Holland,
	Björn Töpel, Paul Walmsley, Atish Patra
In-Reply-To: <20250311160646.1257131-1-sunilvl@ventanamicro.com>

On Tue, Mar 11, 2025 at 09:36:46PM GMT, Sunil V L wrote:
>  sys-utils/Makemodule.am   |  1 +
>  sys-utils/lscpu-cputype.c |  1 +
>  sys-utils/lscpu-riscv.c   | 57 +++++++++++++++++++++++++++++++++++++++
>  sys-utils/lscpu.c         |  5 ++++
>  sys-utils/lscpu.h         |  2 ++
>  sys-utils/meson.build     |  1 +
>  6 files changed, 67 insertions(+)
>  create mode 100644 sys-utils/lscpu-riscv.c

Thank you, it looks good. I have created a PR from this patch to test
it with our tests: https://github.com/util-linux/util-linux/pull/3465

I have also updated the tests/expected/lscpu/lscpu-rv64-* files:
https://github.com/util-linux/util-linux/pull/3465/commits/659dcaa76fae256de9323b00d40cd6b0df61ff6d

    Karel

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


^ permalink raw reply

* bug in `more -c` when using . to repeat <enter>
From: Benno Schulenberg @ 2025-03-16 15:45 UTC (permalink / raw)
  To: util-linux


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


To reproduce, run `./more -c README`.  Type <enter> a few times,
and see that for each <enter> the screen scrolls one line to show
another line of the README.  (Except when there is a blank line:
then it scrolls two lines and shows two blank lines -- that is
probably a separate bug.)

Now type . instead, which should repeat the last command, in this
case <enter>.  See how the screen is cleared and just one line of
the README is shown.  Keep typing . and see that each time just
one line is displayed.  Typing . here behaves as if the user had
typed 1 <enter>, not just <enter>.

Bug was found while using `./page README` after `ln -s more page`.
But `./page` does not do the doubling of blank lines.

Versions: 2.37.2 and 2.41-rc2.


Benno

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

^ permalink raw reply

* [PATCH 1/3] irqtop,lsirq: set up locale path, so messages get actually translated
From: Benno Schulenberg @ 2025-03-16 15:20 UTC (permalink / raw)
  To: util-linux

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
---
 sys-utils/irqtop.c | 3 +++
 sys-utils/lsirq.c  | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/sys-utils/irqtop.c b/sys-utils/irqtop.c
index 6d001cb10..99f2f6041 100644
--- a/sys-utils/irqtop.c
+++ b/sys-utils/irqtop.c
@@ -456,6 +456,9 @@ int main(int argc, char **argv)
 	};
 
 	setlocale(LC_ALL, "");
+	bindtextdomain(PACKAGE, LOCALEDIR);
+	textdomain(PACKAGE);
+	close_stdout_atexit();
 
 	parse_args(&ctl, &out, argc, argv);
 
diff --git a/sys-utils/lsirq.c b/sys-utils/lsirq.c
index fa2dcaaf3..0b3e4c241 100644
--- a/sys-utils/lsirq.c
+++ b/sys-utils/lsirq.c
@@ -109,6 +109,9 @@ int main(int argc, char **argv)
 	char *input_file = NULL;
 
 	setlocale(LC_ALL, "");
+	bindtextdomain(PACKAGE, LOCALEDIR);
+	textdomain(PACKAGE);
+	close_stdout_atexit();
 
 	while ((c = getopt_long(argc, argv, "i:no:s:t:C:ShJPV", longopts, NULL)) != -1) {
 		err_exclusive_options(c, longopts, excl, excl_st);
-- 
2.48.1


^ permalink raw reply related

* [PATCH 3/3] various: (man) list --help and --version last among the options
From: Benno Schulenberg @ 2025-03-16 15:20 UTC (permalink / raw)
  To: util-linux
In-Reply-To: <20250316152040.44163-1-bensberg@telfort.nl>

Almost all util-linux man pages mention -h/--help and -V/--version
last in the list of options.  Make the few deviant pages conform.

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
---
 disk-utils/cfdisk.8.adoc    | 4 ++--
 disk-utils/fdisk.8.adoc     | 5 +----
 disk-utils/swaplabel.8.adoc | 4 ++--
 misc-utils/hardlink.1.adoc  | 3 +--
 misc-utils/look.1.adoc      | 2 ++
 misc-utils/lsblk.8.adoc     | 4 ++--
 misc-utils/uuidgen.1.adoc   | 4 ++--
 sys-utils/eject.1.adoc      | 4 ++--
 sys-utils/lsmem.1.adoc      | 4 ++--
 text-utils/bits.1.adoc      | 4 ++--
 text-utils/rev.1.adoc       | 4 ++--
 11 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/disk-utils/cfdisk.8.adoc b/disk-utils/cfdisk.8.adoc
index 5ab560a4a..0075fd472 100644
--- a/disk-utils/cfdisk.8.adoc
+++ b/disk-utils/cfdisk.8.adoc
@@ -44,8 +44,6 @@ If you want to remove an old partition table from a device, use *wipefs*(8).
 
 == OPTIONS
 
-include::man-common/help-version.adoc[]
-
 *-L*, *--color*[**=**__when__]::
 Colorize the output. The optional argument _when_ can be *auto*, *never* or *always*. If the _when_ argument is omitted, it defaults to *auto*. The colors can be disabled, for the current built-in default see *--help* output. See also the *COLORS* section.
 
@@ -61,6 +59,8 @@ Specify the sector size of the disk. Valid values are 512, 1024, 2048, and 4096.
 *-z*, *--zero*::
 Start with an in-memory zeroed partition table. This option does not zero the partition table on the disk; rather, it simply starts the program without reading the existing partition table. This option allows you to create a new partition table from scratch or from an *sfdisk*(8)-compatible script.
 
+include::man-common/help-version.adoc[]
+
 == COMMANDS
 
 The commands for *cfdisk* can be entered by pressing the corresponding key (pressing _Enter_ after the command is not necessary). Here is a list of the available commands:
diff --git a/disk-utils/fdisk.8.adoc b/disk-utils/fdisk.8.adoc
index 1644f7bd9..c18c38273 100644
--- a/disk-utils/fdisk.8.adoc
+++ b/disk-utils/fdisk.8.adoc
@@ -48,8 +48,6 @@ Don't erase the beginning of the first disk sector when creating a new disk labe
 *-c*, *--compatibility*[**=**_mode_]::
 Specify the compatibility mode, 'dos' or 'nondos'. The default is non-DOS mode. For backward compatibility, it is possible to use the option without the _mode_ argument -- then the default is used. Note that the optional _mode_ argument cannot be separated from the *-c* option by a space, the correct form is for example *-c*=_dos_.
 
-include::man-common/help-version.adoc[]
-
 *-L*, *--color*[**=**_when_]::
 Colorize the output. The optional argument _when_ can be *auto*, *never* or *always*. If the _when_ argument is omitted, it defaults to *auto*. The colors can be disabled; for the current built-in default see the *--help* output. See also the *COLORS* section.
 
@@ -97,8 +95,7 @@ Wipe filesystem, RAID and partition-table signatures from the device, in order t
 *-W*, *--wipe-partitions* _when_::
 Wipe filesystem, RAID and partition-table signatures from a newly created partitions, in order to avoid possible collisions. The argument _when_ can be *auto*, *never* or *always*. When this option is not given, the default is *auto*, in which case signatures are wiped only when in interactive mode and after confirmation by user. In all cases detected signatures are reported by warning messages before a new partition is created. See also *wipefs*(8) command.
 
-*-V*, *--version*::
-Display version information and exit.
+include::man-common/help-version.adoc[]
 
 == DEVICES
 
diff --git a/disk-utils/swaplabel.8.adoc b/disk-utils/swaplabel.8.adoc
index de440d394..0a1a1136f 100644
--- a/disk-utils/swaplabel.8.adoc
+++ b/disk-utils/swaplabel.8.adoc
@@ -28,14 +28,14 @@ If an optional argument is present, then *swaplabel* will change the appropriate
 
 == OPTIONS
 
-include::man-common/help-version.adoc[]
-
 *-L*, *--label* _label_::
   Specify a new _label_ for the device. Swap partition labels can be at most 16 characters long. If _label_ is longer than 16 characters, *swaplabel* will truncate it and print a warning message.
 
 *-U*, *--uuid* _UUID_::
   Specify a new _UUID_ for the device. The _UUID_ must be in the standard 8-4-4-4-12 character format, such as is output by *uuidgen*(1).
 
+include::man-common/help-version.adoc[]
+
 == ENVIRONMENT
 
 LIBBLKID_DEBUG=all::
diff --git a/misc-utils/hardlink.1.adoc b/misc-utils/hardlink.1.adoc
index 98b29a3b3..e09572f6c 100644
--- a/misc-utils/hardlink.1.adoc
+++ b/misc-utils/hardlink.1.adoc
@@ -40,8 +40,6 @@ are very often different from the beginning.
 
 == OPTIONS
 
-include::man-common/help-version.adoc[]
-
 *-c*, *--content*::
 Consider only file content, not attributes, when determining whether two files are equal. Same as *-pot*.
 
@@ -146,6 +144,7 @@ only reflinks are allowed.
 *--skip-reflinks*::
 Ignore already cloned files. This option may be used without *--reflink* when creating classic hardlinks.
 
+include::man-common/help-version.adoc[]
 
 == ARGUMENTS
 
diff --git a/misc-utils/look.1.adoc b/misc-utils/look.1.adoc
index 35b8978bc..0ef71ece3 100644
--- a/misc-utils/look.1.adoc
+++ b/misc-utils/look.1.adoc
@@ -72,6 +72,8 @@ Specify a string termination character, i.e., only the characters in _string_ up
 
 include::man-common/help-version.adoc[]
 
+== EXIT STATUS
+
 The *look* utility exits 0 if one or more lines were found and displayed, 1 if no lines were found, and >1 if an error occurred.
 
 == ENVIRONMENT
diff --git a/misc-utils/lsblk.8.adoc b/misc-utils/lsblk.8.adoc
index a67eb292e..7a0a15d3a 100644
--- a/misc-utils/lsblk.8.adoc
+++ b/misc-utils/lsblk.8.adoc
@@ -166,8 +166,6 @@ Output info about block-device topology. This option is equivalent to
 +
 *-o NAME,ALIGNMENT,MIN-IO,OPT-IO,PHY-SEC,LOG-SEC,ROTA,SCHED,RQ-SIZE,RA,WSAME*.
 
-include::man-common/help-version.adoc[]
-
 *-w*, *--width* _number_::
 Specifies output width as a number of characters. The default is the number of the terminal columns, and if not executed on a terminal, then output width is not restricted at all by default. This option also forces *lsblk* to assume that terminal control characters and unsafe characters are not allowed. The expected use-case is for example when *lsblk* is used by the *watch*(1) command.
 
@@ -197,6 +195,8 @@ Reads data from a file. This method is only used if the --sysroot option is spec
 *none*;;
 Does not probe. This method always stops probing.
 
+include::man-common/help-version.adoc[]
+
 == EXIT STATUS
 
 0::
diff --git a/misc-utils/uuidgen.1.adoc b/misc-utils/uuidgen.1.adoc
index 1d89fe43d..e061d8a94 100644
--- a/misc-utils/uuidgen.1.adoc
+++ b/misc-utils/uuidgen.1.adoc
@@ -34,8 +34,6 @@ Generate a random-based UUID. This method creates a UUID consisting mostly of ra
 *-t*, *--time*::
 Generate a time-based UUID. This method creates a UUID based on the system clock plus the system's ethernet hardware address, if present.
 
-include::man-common/help-version.adoc[]
-
 *-m*, *--md5*::
 Use MD5 as the hash algorithm.
 
@@ -60,6 +58,8 @@ Generate multiple UUIDs using the enhanced capability of the libuuid to cache ti
 *-x*, *--hex*::
 Interpret name _name_ as a hexadecimal string.
 
+include::man-common/help-version.adoc[]
+
 == CONFORMING TO
 
 OSF DCE 1.1
diff --git a/sys-utils/eject.1.adoc b/sys-utils/eject.1.adoc
index dd99ae524..52988601d 100644
--- a/sys-utils/eject.1.adoc
+++ b/sys-utils/eject.1.adoc
@@ -79,8 +79,6 @@ With this option the drive is given a CD-ROM tray close command if it's opened,
 *-t*, *--trayclose*::
 With this option the drive is given a CD-ROM tray close command. Not all devices support this command.
 
-include::man-common/help-version.adoc[]
-
 *-v*, *--verbose*::
 Run in verbose mode; more information is displayed about what the command is doing.
 
@@ -90,6 +88,8 @@ With this option the CD-ROM drive will be probed to detect the available speeds.
 *-x*, *--cdspeed* _speed_::
 With this option the drive is given a CD-ROM select speed command. The _speed_ argument is a number indicating the desired speed (e.g., 8 for 8X speed), or 0 for maximum data rate. Not all devices support this command and you can only specify speeds that the drive is capable of. Every time the media is changed this option is cleared. This option can be used alone, or with the *-t* and *-c* options.
 
+include::man-common/help-version.adoc[]
+
 == EXIT STATUS
 
 Returns 0 if operation was successful, 1 if operation failed or command syntax was not valid.
diff --git a/sys-utils/lsmem.1.adoc b/sys-utils/lsmem.1.adoc
index 3e5577ee7..337c8b4b7 100644
--- a/sys-utils/lsmem.1.adoc
+++ b/sys-utils/lsmem.1.adoc
@@ -60,11 +60,11 @@ Specify which columns (attributes) use to split memory blocks to ranges. The sup
 *-s*, *--sysroot* _directory_::
 Gather memory data for a Linux instance other than the instance from which the *lsmem* command is issued. The specified _directory_ is the system root of the Linux instance to be inspected.
 
-include::man-common/help-version.adoc[]
-
 *--summary*[**=**_when_]::
 This option controls summary lines output. The optional argument _when_ can be *never*, *always* or *only*. If the _when_ argument is omitted, it defaults to *"only"*. The summary output is suppressed for *--raw*, *--pairs* and *--json*.
 
+include::man-common/help-version.adoc[]
+
 == AUTHORS
 
 *lsmem* was originally written by Gerald Schaefer for s390-tools in Perl. The C version for util-linux was written by Clemens von Mann, Heiko Carstens and Karel Zak.
diff --git a/text-utils/bits.1.adoc b/text-utils/bits.1.adoc
index 8501bd19c..0a55583ec 100644
--- a/text-utils/bits.1.adoc
+++ b/text-utils/bits.1.adoc
@@ -67,12 +67,12 @@ groups so far.
 
 == OPTIONS
 
-include::man-common/help-version.adoc[]
-
 *-w* __<NUM>__, *--width* __<NUM>__::
 Maximum number of bits in the masks handled by *bits* (default __8192__). Any
 bit larger than this number will be truncated.
 
+include::man-common/help-version.adoc[]
+
 == CONVERSION MODE
 
 One of the following conversion modes can be specified. If not specified, it
diff --git a/text-utils/rev.1.adoc b/text-utils/rev.1.adoc
index 3d4027390..1cf375c27 100644
--- a/text-utils/rev.1.adoc
+++ b/text-utils/rev.1.adoc
@@ -56,11 +56,11 @@ This utility is a line-oriented tool and it uses in-memory allocated buffer for
 
 == OPTIONS
 
-include::man-common/help-version.adoc[]
-
 *-0*, *--zero*::
 _Zero termination_. Use the byte '\0' as line separator.
 
+include::man-common/help-version.adoc[]
+
 == SEE ALSO
 
 *tac*(1)
-- 
2.48.1


^ permalink raw reply related

* [PATCH 2/3] more: remove a duplicate call of setlocale()
From: Benno Schulenberg @ 2025-03-16 15:20 UTC (permalink / raw)
  To: util-linux
In-Reply-To: <20250316152040.44163-1-bensberg@telfort.nl>

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
---
 text-utils/more.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/text-utils/more.c b/text-utils/more.c
index e39fe724c..48f27f9e9 100644
--- a/text-utils/more.c
+++ b/text-utils/more.c
@@ -2094,9 +2094,8 @@ int main(int argc, char **argv)
 	setlocale(LC_ALL, "");
 	bindtextdomain(PACKAGE, LOCALEDIR);
 	textdomain(PACKAGE);
 	close_stdout_atexit();
-	setlocale(LC_ALL, "");
 
 	/* Auto set no scroll on when binary is called page */
 	if (!(strcmp(program_invocation_short_name, "page")))
 		ctl.no_scroll++;
-- 
2.48.1


^ permalink raw reply related

* hexdump.1: Some remarks about this man page
From: Bjarni Ingi Gislason @ 2025-03-15 20:02 UTC (permalink / raw)
  To: util-linux

[-- Attachment #1: Type: text/plain, Size: 1477 bytes --]

Package: bsdextrautils
Version: 2.40.4-5
Severity: minor
Tags: upstream

   * What led up to the situation?

     Checking for defects with a new version

test-[g|n]roff -mandoc -t -K utf8 -rF0 -rHY=0 -rCHECKSTYLE=10 -ww -z < "man page"

  [Use "groff -e ' $' -e '\\~$' <file>" to find obvious trailing spaces.]

  ["test-groff" is a script in the repository for "groff"; is not shipped]
(local copy and "troff" slightly changed by me).

  [The fate of "test-nroff" was decided in groff bug #55941.]

   * What was the outcome of this action?


<stdin>:1: warning: table wider than line length minus indentation
an.tmac:<stdin>:366: warning: .l = 1584u = 66n = 66m, .i = 192u, TW (table width) = 1440u = 60n = 60m


   * What outcome did you expect instead?

     No output (no warnings).

-.-

  General remarks and further material, if a diff-file exist, are in the
attachments.


-- System Information:
Debian Release: trixie/sid
  APT prefers testing
  APT policy: (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 6.12.17-amd64 (SMP w/2 CPU threads; PREEMPT)
Locale: LANG=is_IS.iso88591, LC_CTYPE=is_IS.iso88591 (charmap=ISO-8859-1), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: sysvinit (via /sbin/init)

Versions of packages bsdextrautils depends on:
ii  libc6          2.41-4
ii  libsmartcols1  2.40.4-5
ii  libtinfo6      6.5+20250216-2

bsdextrautils recommends no packages.

bsdextrautils suggests no packages.

-- no debconf information

[-- Attachment #2: chk_man.err.hexdump.1 --]
[-- Type: text/plain, Size: 5801 bytes --]

Output from "mandoc -T lint  hexdump.1": (shortened list)

      1 input text line longer than 80 bytes: A byte count or fiel...
[...]
      1 skipping insecure request: mso
      2 skipping paragraph macro: br after sp
     10 skipping paragraph macro: sp after SH
      3 skipping paragraph macro: sp after SS
      1 skipping unknown macro:  LINKSTYLE blue R < >

-.-.

Output from "test-nroff -mandoc -t -ww -z hexdump.1": (shortened list)

      1 .l = 1584u = 66n = 66m, .i = 192u, TW (table width) = 1440u = 60n = 60m
      1 table wider than line length minus indentation

-.-.

Lines containing '\c':

501:For bug reports, use the issue tracker at \c
502-.URL "https://github.com/util\-linux/util\-linux/issues" "" "."
--
505:The \fBhexdump\fP command is part of the util\-linux package which can be downloaded from \c
506-.URL "https://www.kernel.org/pub/linux/utils/util\-linux/" "Linux Kernel Archive" "."

  Are not needed!

-.-.

Show if asciidoctor generated this.

Who is actually generating this man page?  Debian or upstream?

Is the generating software out of date?

4:.\" Generator: Asciidoctor 2.0.20

N.B. Outdated version, current is 2.0.23.

-.-.

Change a HYPHEN-MINUS (code 0x2D) to a minus(-dash) (\-),
if it
is in front of a name for an option,
is a symbol for standard input,
is a single character used to indicate an option,
or is in the NAME section (man-pages(7)).
N.B. - (0x2D), processed as a UTF-8 file, is changed to a hyphen
(0x2010, groff \[u2010] or \[hy]) in the output.

153:.ll -.6i
247:.ll -.6i
478:.ll -.6i
487:.ll -.6i

Output line gets shorter with each call.
What is the purpose?
Comments are missing!

  Generators of man pages should not change the line length in any way!

-.-.

Wrong distance (not two spaces) between sentences in the input file.

  Separate the sentences and subordinate clauses; each begins on a new
line.  See man-pages(7) ("Conventions for source file layout") and
"info groff" ("Input Conventions").

  The best procedure is to always start a new sentence on a new line,
at least, if you are typing on a computer.

Remember coding: Only one command ("sentence") on each (logical) line.

E-mail: Easier to quote exactly the relevant lines.

Generally: Easier to edit the sentence.

Patches: Less unaffected text.

Search for two adjacent words is easier, when they belong to the same line,
and the same phrase.

  The amount of space between sentences in the output can then be
controlled with the ".ss" request.

Mark a final abbreviation point as such by suffixing it with "\&".

Some sentences (etc.) do not begin on a new line.

Split (sometimes) lines after a punctuation mark; before a conjunction.

  Lines with only one (or two) space(s) between sentences could be split,
so latter sentences begin on a new line.

Use

#!/usr/bin/sh

sed -e '/^\./n' \
-e 's/\([[:alpha:]]\)\.  */\1.\n/g' $1

to split lines after a sentence period.
Check result with the difference between the formatted outputs.
See also the attachment "general.bugs"

[List of affected lines removed.]

-.-

Split lines longer than 80 characters into two or more lines.
Appropriate break points are the end of a sentence and a subordinate
clause; after punctuation marks.
Add "\:" to split the string for the output, "\<newline>" in the source.  

[List of affected lines removed.]

Longest line is: 474 characters.

-.-.

Put a parenthetical sentence, phrase on a separate line,
if not part of a code.
See man-pages(7), item "semantic newline".

[List of affected lines removed.]

-.-

No space is needed before a quote (") at the end of a line

445:   "%06.6_ao "  12/1 "%3_u "
446:   "\(rst" "%_p "

-.-.

Only one space character after a possible end of sentence
(after a punctuation, that can end a sentence).

[List of affected lines removed.]

-.-

Put a subordinate sentence (after a comma) on a new line.

[List of affected lines removed.]


-.-.

Remove quotes when there is a printable
but no space character between them
and the quotes are not for emphasis (markup),
for example as an argument to a macro.

hexdump.1:10:.TH "HEXDUMP" "1" "2024-12-16" "util\-linux 2.40.4" "User Commands"
hexdump.1:31:.SH "NAME"
hexdump.1:33:.SH "SYNOPSIS"
hexdump.1:38:.SH "DESCRIPTION"
hexdump.1:41:.SH "OPTIONS"
hexdump.1:121:.SH "FORMATS"
hexdump.1:371:.SS "Colors"
hexdump.1:400:.SS "Counters"
hexdump.1:438:.SH "EXAMPLES"
hexdump.1:473:.SH "COLORS"
hexdump.1:502:.URL "https://github.com/util\-linux/util\-linux/issues" "" "."
hexdump.1:503:.SH "AVAILABILITY"
hexdump.1:506:.URL "https://www.kernel.org/pub/linux/utils/util\-linux/" "Linux Kernel Archive" "."

-.-.

Use ".na" (no adjustment) instead of ".ad l" (and ".ad" to begin the
same adjustment again as before).

15:.ad l
23:.    ad l
26:.    ad l

-.-.

Section headings (.SH and .SS) do not need quoting their arguments.

31:.SH "NAME"
33:.SH "SYNOPSIS"
38:.SH "DESCRIPTION"
41:.SH "OPTIONS"
121:.SH "FORMATS"
218:.SS "Conversion strings"
371:.SS "Colors"
400:.SS "Counters"
432:.SH "EXIT STATUS"
435:.SH "CONFORMING TO"
438:.SH "EXAMPLES"
473:.SH "COLORS"
499:.SH "REPORTING BUGS"
503:.SH "AVAILABILITY"

-.-.

Put a (long) web address on a new line to reduce the posibility of
splitting the address between two output lines.
Or inhibit hyphenation with "\%" in front of the name.


502:.URL "https://github.com/util\-linux/util\-linux/issues" "" "."
506:.URL "https://www.kernel.org/pub/linux/utils/util\-linux/" "Linux Kernel Archive" "."

-.-.

Output from "test-groff  -mandoc -t -K utf8 -rF0 -rHY=0 -rCHECKSTYLE=10 -ww -z ":

<stdin>:1: warning: table wider than line length minus indentation
an.tmac:<stdin>:366: warning: .l = 1584u = 66n = 66m, .i = 192u, TW (table width) = 1440u = 60n = 60m

-.-.

Generally:

Split (sometimes) lines after a punctuation mark; before a conjunction.

[-- Attachment #3: general.bugs --]
[-- Type: text/plain, Size: 1922 bytes --]

  Any program (person), that produces man pages, should check the output
for defects by using (both groff and nroff)

[gn]roff -mandoc -t -ww -b -z -K utf8 <man page>

  The same goes for man pages that are used as an input.

  For a style guide use

  mandoc -T lint

-.-

  Any "autogenerator" should check its products with the above mentioned
'groff', 'mandoc', and additionally with 'nroff ...'.

  It should also check its input files for too long (> 80) lines.

  This is just a simple quality control measure.

  The "autogenerator" may have to be corrected to get a better man page,
the source file may, and any additional file may.

  Common defects:

  Not removing trailing spaces (in in- and output).
  The reason for these trailing spaces should be found and eliminated.

  "git" has a "tool" to point out whitespace,
see for example "git-apply(1)" and git-config(1)")

  Not beginning each input sentence on a new line.
Line length and patch size should thus be reduced.

  The script "reportbug" uses 'quoted-printable' encoding when a line is
longer than 1024 characters in an 'ascii' file.

  See man-pages(7), item "semantic newline".

-.-

The difference between the formatted output of the original and patched file
can be seen with:

  nroff -mandoc <file1> > <out1>
  nroff -mandoc <file2> > <out2>
  diff -d -u <out1> <out2>

and for groff, using

\"printf '%s\n%s\n' '.kern 0' '.ss 12 0' | groff -mandoc -Z - \"

instead of 'nroff -mandoc'

  Add the option '-t', if the file contains a table.

  Read the output from 'diff -d -u ...' with 'less -R' or similar.

-.-.

  If 'man' (man-db) is used to check the manual for warnings,
the following must be set:

  The option \"-warnings=w\"

  The environmental variable:

export MAN_KEEP_STDERR=yes (or any non-empty value)

  or

  (produce only warnings):

export MANROFFOPT=\"-ww -b -z\"

export MAN_KEEP_STDERR=yes (or any non-empty value)

-.-

^ permalink raw reply

* [PATCH] swapon: make options --help and --version override --summary
From: Benno Schulenberg @ 2025-03-13 14:51 UTC (permalink / raw)
  To: util-linux

When -h or --help is among the given options, most utilities
print a help text, ignoring all other options and arguments.
Make `swapon --summary --help` conform to this general pattern.

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
---
 sys-utils/swapon.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/sys-utils/swapon.c b/sys-utils/swapon.c
index 419155d67..f7f82bbfb 100644
--- a/sys-utils/swapon.c
+++ b/sys-utils/swapon.c
@@ -145,6 +145,7 @@ struct swapon_ctl {
 		no_heading,		/* toggle --show headers */
 		raw,			/* toggle --show alignment */
 		show,			/* display --show information */
+		summarize,		/* display summary of swap use */
 		verbose;		/* be chatty */
 };
 
@@ -965,8 +966,8 @@ int main(int argc, char *argv[])
 			ctl.fix_page_size = 1;
 			break;
 		case 's':		/* status report */
-			status = display_summary();
-			return status;
+			ctl.summarize = 1;
+			break;
 		case 'v':		/* be chatty */
 			ctl.verbose = 1;
 			break;
@@ -1007,6 +1008,11 @@ int main(int argc, char *argv[])
 	}
 	argv += optind;
 
+	if (ctl.summarize) {
+		status = display_summary();
+		return status;
+	}
+
 	if (ctl.show || (!ctl.all && !numof_labels() && !numof_uuids() && *argv == NULL)) {
 		if (!ctl.ncolumns) {
 			/* default columns */
-- 
2.48.1


^ permalink raw reply related

* Re: [PATCH v2] lscpu: RISC-V: Print ISA information in summary
From: Andrew Jones @ 2025-03-11 16:19 UTC (permalink / raw)
  To: Sunil V L
  Cc: util-linux, Anup Patel, Conor Dooley, Palmer Dabbelt,
	Alexandre Ghiti, Samuel Holland, Björn Töpel,
	Paul Walmsley, Atish Patra, Karel Zak
In-Reply-To: <20250311160646.1257131-1-sunilvl@ventanamicro.com>

On Tue, Mar 11, 2025 at 09:36:46PM +0530, Sunil V L wrote:
> The ISA information for RISC-V is important for understanding the
> different extensions supported by the CPU. Print the ISA information in
> the summary, with the Base ISA and single-letter extensions at the
> beginning, followed by multi-letter extensions sorted in alphabetical
> order. The information is the same as the cpuinfo information, except
> that underscores are replaced by spaces and multi-letter extensions are
> simply sorted instead of following any ISA string ordering rule.
> 
> The sample output below shows the difference between cpuinfo and lscpu.
> 
> cpuinfo output:
> isa             : rv64imafdch_zicbom_zicboz_zicntr_zicsr_zifencei_zihintntl_zihintpause_zihpm_zawrs_zfa_zba_zbb_zbc_zbs_smaia_ssaia_sstc
> 
> lscpu output:
> ISA:                rv64imafdch smaia ssaia sstc zawrs zba zbb zbc zbs zfa zicbom zicboz zicntr zicsr zifencei zihintntl zihintpause zihpm
> 
> Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
> ---
> Changes in v2:
> 	1) Format the ISA string instead of simply printing the same
> 	   from cpuinfo. (Feedback from Andrew Jones).
> ---
>  sys-utils/Makemodule.am   |  1 +
>  sys-utils/lscpu-cputype.c |  1 +
>  sys-utils/lscpu-riscv.c   | 57 +++++++++++++++++++++++++++++++++++++++
>  sys-utils/lscpu.c         |  5 ++++
>  sys-utils/lscpu.h         |  2 ++
>  sys-utils/meson.build     |  1 +
>  6 files changed, 67 insertions(+)
>  create mode 100644 sys-utils/lscpu-riscv.c
>

Reviewed-by: Andrew Jones <ajones@ventanamicro.com>

^ permalink raw reply

* [PATCH v2] lscpu: RISC-V: Print ISA information in summary
From: Sunil V L @ 2025-03-11 16:06 UTC (permalink / raw)
  To: util-linux
  Cc: Andrew Jones, Anup Patel, Conor Dooley, Palmer Dabbelt,
	Alexandre Ghiti, Samuel Holland, Björn Töpel,
	Paul Walmsley, Atish Patra, Karel Zak, Sunil V L

The ISA information for RISC-V is important for understanding the
different extensions supported by the CPU. Print the ISA information in
the summary, with the Base ISA and single-letter extensions at the
beginning, followed by multi-letter extensions sorted in alphabetical
order. The information is the same as the cpuinfo information, except
that underscores are replaced by spaces and multi-letter extensions are
simply sorted instead of following any ISA string ordering rule.

The sample output below shows the difference between cpuinfo and lscpu.

cpuinfo output:
isa             : rv64imafdch_zicbom_zicboz_zicntr_zicsr_zifencei_zihintntl_zihintpause_zihpm_zawrs_zfa_zba_zbb_zbc_zbs_smaia_ssaia_sstc

lscpu output:
ISA:                rv64imafdch smaia ssaia sstc zawrs zba zbb zbc zbs zfa zicbom zicboz zicntr zicsr zifencei zihintntl zihintpause zihpm

Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
---
Changes in v2:
	1) Format the ISA string instead of simply printing the same
	   from cpuinfo. (Feedback from Andrew Jones).
---
 sys-utils/Makemodule.am   |  1 +
 sys-utils/lscpu-cputype.c |  1 +
 sys-utils/lscpu-riscv.c   | 57 +++++++++++++++++++++++++++++++++++++++
 sys-utils/lscpu.c         |  5 ++++
 sys-utils/lscpu.h         |  2 ++
 sys-utils/meson.build     |  1 +
 6 files changed, 67 insertions(+)
 create mode 100644 sys-utils/lscpu-riscv.c

diff --git a/sys-utils/Makemodule.am b/sys-utils/Makemodule.am
index 922cce5c5..1055312db 100644
--- a/sys-utils/Makemodule.am
+++ b/sys-utils/Makemodule.am
@@ -461,6 +461,7 @@ lscpu_SOURCES = sys-utils/lscpu.c \
 		sys-utils/lscpu-virt.c \
 		sys-utils/lscpu-arm.c \
 		sys-utils/lscpu-dmi.c \
+		sys-utils/lscpu-riscv.c \
 		sys-utils/lscpu.h
 lscpu_LDADD = $(LDADD) libcommon.la libsmartcols.la $(RTAS_LIBS)
 lscpu_CFLAGS = $(AM_CFLAGS) -I$(ul_libsmartcols_incdir)
diff --git a/sys-utils/lscpu-cputype.c b/sys-utils/lscpu-cputype.c
index 739dd99c5..bdb33ac78 100644
--- a/sys-utils/lscpu-cputype.c
+++ b/sys-utils/lscpu-cputype.c
@@ -233,6 +233,7 @@ static const struct cpuinfo_pattern type_patterns[] =
 	DEF_PAT_CPUTYPE( "family",		PAT_FAMILY,	family),
 	DEF_PAT_CPUTYPE( "features",		PAT_FEATURES,	flags),		/* s390 */
 	DEF_PAT_CPUTYPE( "flags",		PAT_FLAGS,	flags),		/* x86 */
+	DEF_PAT_CPUTYPE( "isa",			PAT_ISA,	isa),		/* riscv */
 	DEF_PAT_CPUTYPE( "marchid",		PAT_FAMILY,	family),	/* riscv */
 	DEF_PAT_CPUTYPE( "max thread id",	PAT_MAX_THREAD_ID, mtid),	/* s390 */
 	DEF_PAT_CPUTYPE( "mimpid",		PAT_MODEL,	model),		/* riscv */
diff --git a/sys-utils/lscpu-riscv.c b/sys-utils/lscpu-riscv.c
new file mode 100644
index 000000000..62f1ad7ab
--- /dev/null
+++ b/sys-utils/lscpu-riscv.c
@@ -0,0 +1,57 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Copyright (C) 2025 Ventana Micro Systems Inc.
+ *
+ */
+#include "lscpu.h"
+#include "strutils.h"
+#include "strv.h"
+
+static int riscv_cmp_func(const void *a, const void *b)
+{
+	return strcmp(*(const char **)a, *(const char **)b);
+}
+
+bool is_riscv(struct lscpu_cputype *ct)
+{
+	const char *base_isa[] = {"rv32", "rv64", "rv128"};
+	size_t i;
+
+	for (i = 0; i < ARRAY_SIZE(base_isa); i++) {
+		if (!strncasecmp(ct->isa, base_isa[i], strlen(base_isa[i])))
+			return true;
+	}
+
+	return false;
+}
+
+/*
+ * Reformat the isa string, but the length stays the same.
+ */
+void lscpu_format_isa_riscv(struct lscpu_cputype *ct)
+{
+	char **split;
+	size_t i;
+
+	split = strv_split(ct->isa, "_");
+
+	/* Sort multi-letter extensions alphabetically */
+	if (strv_length(split) > 1)
+		qsort(&split[1], strv_length(split) - 1, sizeof(char *), riscv_cmp_func);
+
+	/* Keep Base ISA and single-letter extensions at the start */
+	strcpy(ct->isa, split[0]);
+
+	for (i = 1; i < strv_length(split); i++) {
+		strcat(ct->isa, " ");
+		strcat(ct->isa, split[i]);
+	}
+
+	strv_free(split);
+}
diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
index ffec37206..7b2f28e5e 100644
--- a/sys-utils/lscpu.c
+++ b/sys-utils/lscpu.c
@@ -954,6 +954,11 @@ print_summary_cputype(struct lscpu_cxt *cxt,
 
 	if (ct->flags)
 		add_summary_s(tb, sec, _("Flags:"), ct->flags);
+
+	if (ct->isa && is_riscv(ct)) {
+		lscpu_format_isa_riscv(ct);
+		add_summary_s(tb, sec, _("ISA:"), ct->isa);
+	}
 }
 
 /*
diff --git a/sys-utils/lscpu.h b/sys-utils/lscpu.h
index 459fea84d..bd7b64cc5 100644
--- a/sys-utils/lscpu.h
+++ b/sys-utils/lscpu.h
@@ -278,6 +278,7 @@ struct lscpu_cxt {
 		 CPU_ISSET_S((_cpu)->logical_id, (_cxt)->setsize, (_cxt)->present))
 
 int is_arm(struct lscpu_cxt *cxt);
+bool is_riscv(struct lscpu_cputype *ct);
 
 struct lscpu_cputype *lscpu_new_cputype(void);
 void lscpu_ref_cputype(struct lscpu_cputype *ct);
@@ -320,6 +321,7 @@ int lscpu_create_cpus(struct lscpu_cxt *cxt, cpu_set_t *cpuset, size_t setsize);
 struct lscpu_cpu *lscpu_cpus_loopup_by_type(struct lscpu_cxt *cxt, struct lscpu_cputype *ct);
 
 void lscpu_decode_arm(struct lscpu_cxt *cxt);
+void lscpu_format_isa_riscv(struct lscpu_cputype *ct);
 
 int lookup(char *line, char *pattern, char **value);
 
diff --git a/sys-utils/meson.build b/sys-utils/meson.build
index 2fdcc6393..d9817f922 100644
--- a/sys-utils/meson.build
+++ b/sys-utils/meson.build
@@ -184,6 +184,7 @@ lscpu_sources = files(
   'lscpu-virt.c',
   'lscpu-arm.c',
   'lscpu-dmi.c',
+  'lscpu-riscv.c',
 )
 lscpu_manadocs = files('lscpu.1.adoc')
 
-- 
2.43.0


^ permalink raw reply related

* Re: [RFC PATCH 0/2]lsirq,irqtop: Add filter support
From: Joe Jin @ 2025-03-10 15:27 UTC (permalink / raw)
  To: Karel Zak; +Cc: Zhenwei Pi, Sami Kerola, util-linux
In-Reply-To: <qdiia2fmgfxwgr75qjdgxuiitaoo66tsthajqxs6mrtca6oqh4@irpn3e44w4sw>

On 3/10/25 05:14, Karel Zak wrote:
> On Thu, Mar 06, 2025 at 06:51:59PM GMT, Joe Jin wrote:
>> Sometimes people may only be interested in a specific IRQ, adding regular
>> expression support can help engineers find/monitor IRQs easily.
> Ah, the libsmartcols provides a filter. See, for example, misc-utils/lsblk.c and
> the "-Q" command line option, and also "man scols-filter".
>
> scols_new_filter()
> scols_line_apply_filter()
> scols_line_is_filled()
> ... etc.
>
> https://www.kernel.org/pub/linux/utils/util-linux/v2.41/libsmartcols-docs/libsmartcols-Filters-and-counters.html
>
> The filter allows the creation of complex queries, so if we integrate
> it into lsirq and irqtop, it will be possible to use things like:
>
>     irqtop -Q 'NAME ~= "PCI\-.*" && TOTAL > 100'

This looks more powerful, thanks for your suggestions.

Best Regards,
Joe
>
>
>   Karel
>


^ permalink raw reply

* Re: [RFC PATCH 0/2]lsirq,irqtop: Add filter support
From: Karel Zak @ 2025-03-10 12:14 UTC (permalink / raw)
  To: Joe Jin; +Cc: Zhenwei Pi, Sami Kerola, util-linux
In-Reply-To: <20250307025201.92541-1-joe.jin@oracle.com>

On Thu, Mar 06, 2025 at 06:51:59PM GMT, Joe Jin wrote:
> Sometimes people may only be interested in a specific IRQ, adding regular
> expression support can help engineers find/monitor IRQs easily.

Ah, the libsmartcols provides a filter. See, for example, misc-utils/lsblk.c and
the "-Q" command line option, and also "man scols-filter".

scols_new_filter()
scols_line_apply_filter()
scols_line_is_filled()
... etc.

https://www.kernel.org/pub/linux/utils/util-linux/v2.41/libsmartcols-docs/libsmartcols-Filters-and-counters.html

The filter allows the creation of complex queries, so if we integrate
it into lsirq and irqtop, it will be possible to use things like:

    irqtop -Q 'NAME ~= "PCI\-.*" && TOTAL > 100'


  Karel

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


^ permalink raw reply

* Re: [RFC PATCH 2/2] irqtop: add filter support
From: Benno Schulenberg @ 2025-03-09 11:39 UTC (permalink / raw)
  To: Joe Jin; +Cc: util-linux
In-Reply-To: <20250307025201.92541-3-joe.jin@oracle.com>


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


Op 07-03-2025 om 03:52 schreef Joe Jin:
> --- a/sys-utils/irqtop.1.adoc
> +++ b/sys-utils/irqtop.1.adoc
> @@ -12,7 +12,7 @@ irqtop - utility to display kernel interrupt information
>   
>   == SYNOPSIS
>   
> -*irqtop* [options]
> +*irqtop* [options]... [IRQ] [PATTERN] ...

Oh -- I failed to notice that this change is for the man page,
not for the usage help text.

In a man page, the convention is to put placeholder words in
lowercase italics.  That is: mark them with underscores:

   *irqtop* [options] [_irq_] [_pattern_] ...

If, however, it is possible to specify multiple irq numbers and
irq names, and one can mix them, then I would write:

   *irqtop* [options] [_irq_|_pattern_]...


> +Displays interrupt counter information only for the specified _IRQ_ or for irqnames matching _PATTERN_ when given.

Here, lowercase the underscored words, and "irq names" is better
as two separate words.


Benno

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

^ permalink raw reply

* Re: [RFC PATCH 2/2] irqtop: add filter support
From: Joe Jin @ 2025-03-07 15:30 UTC (permalink / raw)
  To: Benno Schulenberg; +Cc: util-linux
In-Reply-To: <c64a9a6a-8f8e-44d5-9ceb-f9dab99a3ad7@telfort.nl>

On 3/7/25 03:45, Benno Schulenberg wrote:
>
> Op 07-03-2025 om 03:52 schreef Joe Jin:
>
>> -*irqtop* [options]
>> +*irqtop* [options]... [IRQ] [PATTERN] ...
>
> There should be no dots after "[options]", as the "options"
> word already implies that it can be multiple ones.
>
> (True, it's not fully precise -- better would have been:
> "[option...]".  But don't use that.  Please use what all
> the other synopses use: "[options]", sans dots.)
>
> Also, the convention nowadays is to put placeholder words
> in lower case and between angular brackets:
> "[<irq>] [<pattern>]..."

Thanks for your suggestion, I'll make the change.

Bests,
Joe
>
>
> Benno
>


^ permalink raw reply

* Re: [RFC PATCH 2/2] irqtop: add filter support
From: Benno Schulenberg @ 2025-03-07 11:45 UTC (permalink / raw)
  To: Joe Jin; +Cc: util-linux
In-Reply-To: <20250307025201.92541-3-joe.jin@oracle.com>


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


Op 07-03-2025 om 03:52 schreef Joe Jin:

> -*irqtop* [options]
> +*irqtop* [options]... [IRQ] [PATTERN] ...

There should be no dots after "[options]", as the "options"
word already implies that it can be multiple ones.

(True, it's not fully precise -- better would have been:
"[option...]".  But don't use that.  Please use what all
the other synopses use: "[options]", sans dots.)

Also, the convention nowadays is to put placeholder words
in lower case and between angular brackets:
"[<irq>] [<pattern>]..."


Benno


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

^ permalink raw reply

* [RFC PATCH 1/2] lsirq: add filter support
From: Joe Jin @ 2025-03-07  2:52 UTC (permalink / raw)
  To: Karel Zak, Zhenwei Pi, Sami Kerola; +Cc: util-linux, Joe Jin
In-Reply-To: <20250307025201.92541-1-joe.jin@oracle.com>

Signed-off-by: Joe Jin <joe.jin@oracle.com>
Cc: Zhenwei Pi <pizhenwei@bytedance.com>
Cc: Sami Kerola <kerolasa@iki.fi>
Cc: Karel Zak <kzak@redhat.com>
---
 sys-utils/irq-common.c | 88 ++++++++++++++++++++++++++++++++++++++++--
 sys-utils/irq-common.h |  3 +-
 sys-utils/irqtop.c     |  2 +-
 sys-utils/lsirq.1.adoc |  4 +-
 sys-utils/lsirq.c      | 29 ++++++++++++--
 5 files changed, 116 insertions(+), 10 deletions(-)

diff --git a/sys-utils/irq-common.c b/sys-utils/irq-common.c
index 560dd4b82..059f57e3a 100644
--- a/sys-utils/irq-common.c
+++ b/sys-utils/irq-common.c
@@ -21,6 +21,7 @@
 #include <string.h>
 #include <sys/types.h>
 #include <unistd.h>
+#include <regex.h>
 
 #include <libsmartcols.h>
 
@@ -230,11 +231,67 @@ static bool cpu_in_list(int cpu, size_t setsize, cpu_set_t *cpuset)
 	return CPU_ISSET_S(cpu, setsize, cpuset);
 }
 
+static bool match_irqname_by_regex(char *regex_str, const char *irqname)
+{
+	regex_t re;
+	int ret;
+	char *expr = NULL;
+	int i, j;
+
+	/* Exactly matches the string */
+	if (strcmp(regex_str, irqname) == 0 || strcmp(regex_str, "*") == 0)
+	       return true;
+
+	/*
+	 * To generate ls-style regex we need:
+	 *   - Add '^' at the beginning.
+	 *   - Replace '*' with '.*'
+	 *   - Append '$' to the end.
+	 */
+	expr = xmalloc(strlen(regex_str) + 3);
+	memset(expr, 0, strlen(regex_str) + 3);
+	/* Add '^' at the beginning */
+	expr[0] = '^';
+
+	/* Replace '*' with '.*' */
+	for (i = 0, j = 1; regex_str[i] != '\0'; i++, j++) {
+		if (regex_str[i] == '*') {
+			if ((i > 0 && regex_str[i-1] != '.') || i == 0) {
+				expr = realloc(expr, strlen(regex_str) + (j - i) + 1);
+				expr[j] = '.';
+				expr[++j] = '*';
+			} else {
+				expr[j] = regex_str[i];
+			}
+		} else {
+			expr[j] = regex_str[i];
+		}
+	}
+
+	/* Append '$' to the end if necessary */
+	if (regex_str[strlen(regex_str)-1] != '$') {
+		expr[j] = '$';
+		expr[j+1] = '\0';
+	} else {
+		expr[j] = '\0';
+	}
+
+	/* Try regex */
+	if (regcomp(&re, expr, REG_NOSUB|REG_EXTENDED) != 0)
+		return false;
+
+	ret = regexec(&re, irqname, 0, NULL, 0) == 0 ? true : false;
+	regfree(&re);
+
+	free(expr);
+	return ret;
+}
+
 /*
  * irqinfo - parse the system's interrupts
  */
 static struct irq_stat *get_irqinfo(const char *input_file, int softirq,
-				    size_t setsize, cpu_set_t *cpuset)
+				    size_t setsize, cpu_set_t *cpuset, char **filters)
 {
 	FILE *irqfile;
 	char *line = NULL, *tmp;
@@ -280,7 +337,7 @@ static struct irq_stat *get_irqinfo(const char *input_file, int softirq,
 
 		length = strlen(line);
 
-		curr = stat->irq_info + stat->nr_irq++;
+		curr = stat->irq_info + stat->nr_irq;
 		memset(curr, 0, sizeof(*curr));
 		*tmp = '\0';
 		curr->irq = xstrdup(line);
@@ -316,6 +373,28 @@ static struct irq_stat *get_irqinfo(const char *input_file, int softirq,
 				curr->name = xstrdup("");
 		}
 
+		/* Match filter */
+		if (filters) {
+			int matched = 0;
+			char **saved = filters;
+
+			while (*saved) {
+				if (strcmp(curr->irq, *saved) == 0 ||
+				    match_irqname_by_regex(*saved, curr->name) == true) {
+					matched = 1;
+					break;
+				}
+				saved++;
+			}
+
+			if (!matched) {
+				memset(curr, 0, sizeof(*curr));
+				continue;
+			}
+		}
+
+		stat->nr_irq++;
+
 		if (stat->nr_irq == stat->nr_irq_info) {
 			stat->nr_irq_info *= 2;
 			stat->irq_info = xreallocarray(stat->irq_info, stat->nr_irq_info,
@@ -532,7 +611,8 @@ struct libscols_table *get_scols_table(const char *input_file,
 					      int softirq,
 					      uintmax_t threshold,
 					      size_t setsize,
-					      cpu_set_t *cpuset)
+					      cpu_set_t *cpuset,
+					      char **filters)
 {
 	struct libscols_table *table;
 	struct irq_info *result;
@@ -541,7 +621,7 @@ struct libscols_table *get_scols_table(const char *input_file,
 	size_t i;
 
 	/* the stats */
-	stat = get_irqinfo(input_file, softirq, setsize, cpuset);
+	stat = get_irqinfo(input_file, softirq, setsize, cpuset, filters);
 	if (!stat)
 		return NULL;
 
diff --git a/sys-utils/irq-common.h b/sys-utils/irq-common.h
index b9cf72d2a..ec6c89d01 100644
--- a/sys-utils/irq-common.h
+++ b/sys-utils/irq-common.h
@@ -80,7 +80,8 @@ struct libscols_table *get_scols_table(const char *input_file,
                                               int softirq,
                                               uintmax_t threshold,
                                               size_t setsize,
-                                              cpu_set_t *cpuset);
+                                              cpu_set_t *cpuset,
+                                              char **filters);
 
 struct libscols_table *get_scols_cpus_table(struct irq_output *out,
                                         struct irq_stat *prev,
diff --git a/sys-utils/irqtop.c b/sys-utils/irqtop.c
index 6d001cb10..dc59f4829 100644
--- a/sys-utils/irqtop.c
+++ b/sys-utils/irqtop.c
@@ -140,7 +140,7 @@ static int update_screen(struct irqtop_ctl *ctl, struct irq_output *out)
 
 	table = get_scols_table(input_file, out, ctl->prev_stat, &stat,
 				ctl->softirq, ctl->threshold, ctl->setsize,
-				ctl->cpuset);
+				ctl->cpuset, NULL);
 	free(input_file);
 	if (!table) {
 		ctl->request_exit = 1;
diff --git a/sys-utils/lsirq.1.adoc b/sys-utils/lsirq.1.adoc
index dd265710c..7a3bfb69e 100644
--- a/sys-utils/lsirq.1.adoc
+++ b/sys-utils/lsirq.1.adoc
@@ -12,7 +12,7 @@ lsirq - utility to display kernel interrupt information
 
 == SYNOPSIS
 
-*lsirq* [options]
+*lsirq* [options]... [IRQ] [PATTERN] ...
 
 == DESCRIPTION
 
@@ -20,6 +20,8 @@ Display kernel interrupt counter information.
 
 The default output is subject to change. So whenever possible, you should avoid using default outputs in your scripts. Always explicitly define expected columns by using *--output*.
 
+Displays interrupt counter information only for the specified _IRQ_ or for irqnames matching _PATTERN_ when given.
+
 == OPTIONS
 
 *-n*, *--noheadings*::
diff --git a/sys-utils/lsirq.c b/sys-utils/lsirq.c
index fa2dcaaf3..a6528889f 100644
--- a/sys-utils/lsirq.c
+++ b/sys-utils/lsirq.c
@@ -35,11 +35,11 @@
 
 static int print_irq_data(const char *input_file, struct irq_output *out,
 			  int softirq, unsigned long threshold,
-			  size_t setsize, cpu_set_t *cpuset)
+			  size_t setsize, cpu_set_t *cpuset, char **filters)
 {
 	struct libscols_table *table;
 
-	table = get_scols_table(input_file, out, NULL, NULL, softirq, threshold, setsize, cpuset);
+	table = get_scols_table(input_file, out, NULL, NULL, softirq, threshold, setsize, cpuset, filters);
 	if (!table)
 		return -1;
 
@@ -78,6 +78,8 @@ static void __attribute__((__noreturn__)) usage(void)
 
 int main(int argc, char **argv)
 {
+	char **filters = NULL;
+	int filters_len;
 	struct irq_output out = {
 		.ncolumns = 0
 	};
@@ -171,6 +173,18 @@ int main(int argc, char **argv)
 			input_file = xstrdup(_PATH_PROC_INTERRUPTS);
 	}
 
+	if (optind < argc) {
+		int i;
+
+		filters_len = argc - optind + 1;
+		filters = (char **)xmalloc(filters_len * sizeof(void *));
+		memset(filters, 0, filters_len * sizeof(void *));
+
+		for (i = optind; i < argc; i++)
+			filters[i - optind] = xstrdup(argv[i]);
+		filters[i - optind] = NULL;
+	}
+
 	/* default */
 	if (!out.ncolumns) {
 		out.columns[out.ncolumns++] = COL_IRQ;
@@ -185,9 +199,18 @@ int main(int argc, char **argv)
 				irq_column_name_to_id) < 0)
 		exit(EXIT_FAILURE);
 
-	if (print_irq_data(input_file, &out, softirq, threshold, setsize, cpuset) < 0)
+	if (print_irq_data(input_file, &out, softirq, threshold, setsize, cpuset, filters) < 0)
 		return EXIT_FAILURE;
 
+	if (filters) {
+		char **saved = filters;
+
+		while(*filters) {
+			free(*filters);
+			filters++;
+		}
+		free(saved);
+	}
 	free(input_file);
 
 	return EXIT_SUCCESS;
-- 
2.43.5


^ permalink raw reply related

* [RFC PATCH 2/2] irqtop: add filter support
From: Joe Jin @ 2025-03-07  2:52 UTC (permalink / raw)
  To: Karel Zak, Zhenwei Pi, Sami Kerola; +Cc: util-linux, Joe Jin
In-Reply-To: <20250307025201.92541-1-joe.jin@oracle.com>

Signed-off-by: Joe Jin <joe.jin@oracle.com>
Cc: Zhenwei Pi <pizhenwei@bytedance.com>
Cc: Sami Kerola <kerolasa@iki.fi>
Cc: Karel Zak <kzak@redhat.com>
---
 sys-utils/irqtop.1.adoc |  4 +++-
 sys-utils/irqtop.c      | 29 +++++++++++++++++++++++++++--
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/sys-utils/irqtop.1.adoc b/sys-utils/irqtop.1.adoc
index 880ee1906..b9962ce1c 100644
--- a/sys-utils/irqtop.1.adoc
+++ b/sys-utils/irqtop.1.adoc
@@ -12,7 +12,7 @@ irqtop - utility to display kernel interrupt information
 
 == SYNOPSIS
 
-*irqtop* [options]
+*irqtop* [options]... [IRQ] [PATTERN] ...
 
 == DESCRIPTION
 
@@ -20,6 +20,8 @@ Display kernel interrupt counter information in *top*(1) style view.
 
 The default output is subject to change. So whenever possible, you should avoid using default outputs in your scripts. Always explicitly define expected columns by using *--output*.
 
+Displays interrupt counter information only for the specified _IRQ_ or for irqnames matching _PATTERN_ when given.
+
 == OPTIONS
 
 *-o*, *--output* _list_::
diff --git a/sys-utils/irqtop.c b/sys-utils/irqtop.c
index dc59f4829..c5deb840b 100644
--- a/sys-utils/irqtop.c
+++ b/sys-utils/irqtop.c
@@ -87,6 +87,8 @@ struct irqtop_ctl {
 	bool	batch;
 	bool	request_exit,
 		softirq;
+
+	char	**filters;
 };
 
 static inline int irqtop_printf(struct irqtop_ctl *ctl, const char *fmt, ...)
@@ -140,7 +142,7 @@ static int update_screen(struct irqtop_ctl *ctl, struct irq_output *out)
 
 	table = get_scols_table(input_file, out, ctl->prev_stat, &stat,
 				ctl->softirq, ctl->threshold, ctl->setsize,
-				ctl->cpuset, NULL);
+				ctl->cpuset, ctl->filters);
 	free(input_file);
 	if (!table) {
 		ctl->request_exit = 1;
@@ -426,6 +428,19 @@ static void parse_args(	struct irqtop_ctl *ctl,
 		}
 	}
 
+	if (optind < argc) {
+		int i;
+		int filters_len;
+
+		filters_len = argc - optind + 1;
+		ctl->filters = (char **)xmalloc(filters_len * sizeof(void *));
+		memset(ctl->filters, 0, filters_len * sizeof(void *));
+
+		for (i = optind; i < argc; i++)
+			ctl->filters[i - optind] = xstrdup(argv[i]);
+		ctl->filters[i - optind] = NULL;
+	}
+
 	/* default */
 	if (!out->ncolumns) {
 		out->columns[out->ncolumns++] = COL_IRQ;
@@ -452,7 +467,8 @@ int main(int argc, char **argv)
 	struct irqtop_ctl ctl = {
 		.timer.it_interval = {3, 0},
 		.timer.it_value = {3, 0},
-		.iter = -1
+		.iter = -1,
+		.filters = NULL
 	};
 
 	setlocale(LC_ALL, "");
@@ -478,6 +494,15 @@ int main(int argc, char **argv)
 	free_irqstat(ctl.prev_stat);
 	free(ctl.hostname);
 	cpuset_free(ctl.cpuset);
+	if (ctl.filters) {
+		char **saved = ctl.filters;
+
+		while(*(ctl.filters)) {
+			free(*(ctl.filters));
+			(ctl.filters)++;
+		}
+		free(saved);
+	}
 
 	if (!ctl.batch) {
 		if (is_tty)
-- 
2.43.5


^ permalink raw reply related

* [RFC PATCH 0/2]lsirq,irqtop: Add filter support
From: Joe Jin @ 2025-03-07  2:51 UTC (permalink / raw)
  To: Karel Zak, Zhenwei Pi, Sami Kerola; +Cc: util-linux, Joe Jin

Sometimes people may only be interested in a specific IRQ, adding regular
expression support can help engineers find/monitor IRQs easily.

Joe Jin (2):
  lsirq: Add filter support
  irqtop: add filter support

 sys-utils/irq-common.c  | 88 +++++++++++++++++++++++++++++++++++++++--
 sys-utils/irq-common.h  |  3 +-
 sys-utils/irqtop.1.adoc |  4 +-
 sys-utils/irqtop.c      | 29 +++++++++++++-
 sys-utils/lsirq.1.adoc  |  4 +-
 sys-utils/lsirq.c       | 29 ++++++++++++--
 6 files changed, 145 insertions(+), 12 deletions(-)

-- 
2.43.5


^ permalink raw reply

* Re: [PATCH 1/2] lsmem: increase the available width for the summary text labels
From: Karel Zak @ 2025-03-06 17:52 UTC (permalink / raw)
  To: Benno Schulenberg; +Cc: util-linux
In-Reply-To: <20250304160806.10374-1-bensberg@telfort.nl>

On Tue, Mar 04, 2025 at 05:08:05PM GMT, Benno Schulenberg wrote:
>  sys-utils/lsmem.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)

 Applied, thanks.

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


^ permalink raw reply

* [ANNOUNCE] util-linux v2.41-rc2
From: Karel Zak @ 2025-03-06 11:53 UTC (permalink / raw)
  To: linux-kernel, linux-fsdevel, util-linux


The util-linux release v2.41-rc2 is now available at

  https://www.kernel.org/pub/linux/utils/util-linux/v2.41/util-linux-2.41-rc2.tar.xz

Feedback and bug reports, as always, are welcomed.

  Karel

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


^ permalink raw reply

* Re: [PATCH] lscpu: Print ISA information in summary
From: Sunil V L @ 2025-03-05 12:29 UTC (permalink / raw)
  To: util-linux; +Cc: Andrew Jones, Anup Patel
In-Reply-To: <20250304144210.182961-1-sunilvl@ventanamicro.com>

On Tue, Mar 04, 2025 at 08:12:10PM +0530, Sunil V L wrote:
> The ISA information for RISC-V is an important information to understand
> the different extensions supported by the CPU. Print this information in
> the summary.
> 

Hi,

I had some offline conversation with Drew and Anup regarding the
formatting of the ISA. I will send v2 of this patch to address the
feedback from them. So, please ignore this version for now.

Thanks,
Sunil

^ permalink raw reply

* Re: [PATCH V2 0/4] irqtop,lsirq: Miscellaneous enhancements
From: Joe Jin @ 2025-03-05  2:23 UTC (permalink / raw)
  To: Karel Zak; +Cc: Zhenwei Pi, Sami Kerola, util-linux
In-Reply-To: <slmym5tvcnf5evhcbgydkhnfhexmoqrv5wsmzrpg2uafdicxcw@2akbzvezgsam>

On 3/4/25 02:58, Karel Zak wrote:
> On Fri, Feb 28, 2025 at 08:13:30AM GMT, Joe Jin wrote:
>> v2:
>>   - Removed macro irqtop_batch_mode.
>>   - Replaced macro irqtop_printf() to inline function
>>   - Changed option '--number' to '--iter'
>>   - Replace strdup() to xstrdup()
>>   - Added json output format for irqtop.
>>   - Remove irqtop input file support.
>>
>> Joe Jin (4):
>>   irqtop: add batch mode support
>>   irqtop: add max iteration support
>>   irqtop: support json output format
>>   lsirq: add support for reading data from given file
>>
>>  bash-completion/irqtop  |  12 +++-
>>  bash-completion/lsirq   |   4 ++
>>  sys-utils/irq-common.c  |  19 +++---
>>  sys-utils/irq-common.h  |   3 +-
>>  sys-utils/irqtop.1.adoc |   9 +++
>>  sys-utils/irqtop.c      | 124 +++++++++++++++++++++++++++++++---------
>>  sys-utils/lsirq.1.adoc  |   3 +
>>  sys-utils/lsirq.c       |  24 ++++++--
>>  8 files changed, 155 insertions(+), 43 deletions(-)
>  Applied, thanks.

Thanks so much!


>
>     Karel
>


^ permalink raw reply

* [PATCH 2/2] hardlink: replace a strange word in an error message
From: Benno Schulenberg @ 2025-03-04 16:08 UTC (permalink / raw)
  To: util-linux
In-Reply-To: <20250304160806.10374-1-bensberg@telfort.nl>

Signed-off-by: Benno Schulenberg <bensberg@telfort.nl>
---
 misc-utils/hardlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/misc-utils/hardlink.c b/misc-utils/hardlink.c
index 6ac4a3306..ae8215901 100644
--- a/misc-utils/hardlink.c
+++ b/misc-utils/hardlink.c
@@ -1484,7 +1484,7 @@ int main(int argc, char *argv[])
 		rc = ul_fileeq_init(&fileeq, opts.method);
 	}
 	if (rc < 0)
-		err(EXIT_FAILURE, _("failed to initialize files comparior"));
+		err(EXIT_FAILURE, _("failed to initialize files comparer"));
 
 	/* default I/O size */
 	if (!opts.io_size) {
-- 
2.48.1


^ permalink raw reply related


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