From 1272be04be0cb803eec87f602edb2e3e6f111aea Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 21:33:34 +0200 Subject: Merging upstream version 2.40. Signed-off-by: Daniel Baumann --- sys-utils/Makemodule.am | 14 +- sys-utils/adjtime_config.5 | 6 +- sys-utils/blkdiscard.8 | 6 +- sys-utils/blkdiscard.c | 6 +- sys-utils/blkpr.8 | 6 +- sys-utils/blkpr.c | 4 +- sys-utils/blkzone.8 | 6 +- sys-utils/blkzone.c | 6 +- sys-utils/chcpu.8 | 8 +- sys-utils/chcpu.8.adoc | 2 + sys-utils/chcpu.c | 4 +- sys-utils/chmem.8 | 6 +- sys-utils/chmem.c | 4 +- sys-utils/choom.1 | 6 +- sys-utils/choom.c | 4 +- sys-utils/ctrlaltdel.8 | 6 +- sys-utils/ctrlaltdel.c | 24 +- sys-utils/dmesg.1 | 19 +- sys-utils/dmesg.1.adoc | 11 +- sys-utils/dmesg.c | 524 ++++++++++++++++++++++++++++++++----------- sys-utils/eject.1 | 6 +- sys-utils/eject.c | 4 +- sys-utils/fallocate.1 | 6 +- sys-utils/fallocate.c | 14 +- sys-utils/flock.1 | 6 +- sys-utils/flock.c | 10 +- sys-utils/fsfreeze.8 | 6 +- sys-utils/fsfreeze.c | 5 +- sys-utils/fstab.5 | 10 +- sys-utils/fstab.5.adoc | 4 + sys-utils/fstrim.8 | 6 +- sys-utils/fstrim.c | 6 +- sys-utils/hwclock-cmos.c | 6 + sys-utils/hwclock-rtc.c | 93 +++++++- sys-utils/hwclock.8 | 13 +- sys-utils/hwclock.8.adoc | 5 + sys-utils/hwclock.c | 76 +++++-- sys-utils/hwclock.h | 13 ++ sys-utils/ipcmk.1 | 6 +- sys-utils/ipcmk.c | 6 +- sys-utils/ipcrm.1 | 6 +- sys-utils/ipcrm.c | 15 +- sys-utils/ipcs.1 | 6 +- sys-utils/ipcs.c | 20 +- sys-utils/ipcutils.c | 11 + sys-utils/ipcutils.h | 11 + sys-utils/irq-common.c | 35 +-- sys-utils/irq-common.h | 11 + sys-utils/irqtop.1 | 8 +- sys-utils/irqtop.1.adoc | 2 +- sys-utils/irqtop.c | 15 +- sys-utils/ldattach.8 | 6 +- sys-utils/ldattach.c | 23 +- sys-utils/losetup.8 | 13 +- sys-utils/losetup.8.adoc | 5 +- sys-utils/losetup.c | 157 +++++++++---- sys-utils/lscpu-arm.c | 25 ++- sys-utils/lscpu-cpu.c | 12 +- sys-utils/lscpu-cputype.c | 29 ++- sys-utils/lscpu-dmi.c | 8 +- sys-utils/lscpu-topology.c | 18 +- sys-utils/lscpu-virt.c | 59 +++-- sys-utils/lscpu.1 | 6 +- sys-utils/lscpu.c | 46 ++-- sys-utils/lscpu.h | 11 + sys-utils/lsipc.1 | 6 +- sys-utils/lsipc.c | 15 +- sys-utils/lsirq.1 | 6 +- sys-utils/lsirq.c | 17 +- sys-utils/lsmem.1 | 6 +- sys-utils/lsmem.c | 17 +- sys-utils/lsns.8 | 6 +- sys-utils/lsns.c | 15 +- sys-utils/meson.build | 7 + sys-utils/mount.8 | 47 ++-- sys-utils/mount.8.adoc | 32 ++- sys-utils/mount.c | 49 ++-- sys-utils/mountpoint.1 | 6 +- sys-utils/mountpoint.c | 21 +- sys-utils/nsenter.1 | 25 ++- sys-utils/nsenter.1.adoc | 14 ++ sys-utils/nsenter.c | 150 +++++++++++-- sys-utils/pivot_root.8 | 6 +- sys-utils/pivot_root.c | 13 +- sys-utils/prlimit.1 | 44 ++-- sys-utils/prlimit.1.adoc | 38 ++-- sys-utils/prlimit.c | 44 ++-- sys-utils/readprofile.8 | 6 +- sys-utils/readprofile.c | 31 +-- sys-utils/renice.1 | 6 +- sys-utils/renice.c | 8 +- sys-utils/rfkill.8 | 6 +- sys-utils/rfkill.c | 5 +- sys-utils/rtcwake.8 | 6 +- sys-utils/rtcwake.c | 15 +- sys-utils/setarch.8 | 6 +- sys-utils/setarch.c | 14 +- sys-utils/setpgid.1 | 68 ++++++ sys-utils/setpgid.1.adoc | 49 ++++ sys-utils/setpgid.c | 91 ++++++++ sys-utils/setpriv-landlock.c | 214 ++++++++++++++++++ sys-utils/setpriv-landlock.h | 52 +++++ sys-utils/setpriv.1 | 36 ++- sys-utils/setpriv.1.adoc | 27 +++ sys-utils/setpriv.c | 24 +- sys-utils/setsid.1 | 6 +- sys-utils/setsid.c | 12 +- sys-utils/swapoff.c | 17 +- sys-utils/swapon-common.c | 18 +- sys-utils/swapon-common.h | 13 ++ sys-utils/swapon.8 | 8 +- sys-utils/swapon.8.adoc | 2 +- sys-utils/swapon.c | 31 ++- sys-utils/switch_root.8 | 6 +- sys-utils/switch_root.c | 5 +- sys-utils/tunelp.8 | 6 +- sys-utils/tunelp.c | 4 +- sys-utils/umount.8 | 6 +- sys-utils/umount.c | 5 +- sys-utils/unshare.1 | 14 +- sys-utils/unshare.1.adoc | 8 +- sys-utils/unshare.c | 414 +++++++++++++++++++--------------- sys-utils/wdctl.8 | 6 +- sys-utils/wdctl.c | 70 ++++-- sys-utils/zramctl.8 | 6 +- sys-utils/zramctl.c | 6 +- 126 files changed, 2485 insertions(+), 957 deletions(-) create mode 100644 sys-utils/setpgid.1 create mode 100644 sys-utils/setpgid.1.adoc create mode 100644 sys-utils/setpgid.c create mode 100644 sys-utils/setpriv-landlock.c create mode 100644 sys-utils/setpriv-landlock.h (limited to 'sys-utils') diff --git a/sys-utils/Makemodule.am b/sys-utils/Makemodule.am index 7c8d582..209b656 100644 --- a/sys-utils/Makemodule.am +++ b/sys-utils/Makemodule.am @@ -113,6 +113,13 @@ rfkill_LDADD = $(LDADD) libcommon.la libsmartcols.la rfkill_CFLAGS = $(AM_CFLAGS) -I$(ul_libsmartcols_incdir) endif +if BUILD_SETPGID +usrbin_exec_PROGRAMS += setpgid +MANPAGES += sys-utils/setpgid.1 +dist_noinst_DATA += sys-utils/setpgid.1.adoc +setpgid_SOURCES = sys-utils/setpgid.c +endif + if BUILD_SETSID usrbin_exec_PROGRAMS += setsid MANPAGES += sys-utils/setsid.1 @@ -524,7 +531,8 @@ if BUILD_NSENTER usrbin_exec_PROGRAMS += nsenter MANPAGES += sys-utils/nsenter.1 dist_noinst_DATA += sys-utils/nsenter.1.adoc -nsenter_SOURCES = sys-utils/nsenter.c lib/exec_shell.c +nsenter_SOURCES = sys-utils/nsenter.c lib/exec_shell.c \ + lib/caputils.c nsenter_LDADD = $(LDADD) libcommon.la $(SELINUX_LIBS) if HAVE_STATIC_NSENTER @@ -573,5 +581,9 @@ MANPAGES += sys-utils/setpriv.1 dist_noinst_DATA += sys-utils/setpriv.1.adoc setpriv_SOURCES = sys-utils/setpriv.c \ lib/caputils.c +dist_noinst_HEADERS += sys-utils/setpriv-landlock.h +if HAVE_LINUX_LANDLOCK_H +setpriv_SOURCES += sys-utils/setpriv-landlock.c +endif setpriv_LDADD = $(LDADD) -lcap-ng libcommon.la endif diff --git a/sys-utils/adjtime_config.5 b/sys-utils/adjtime_config.5 index d1bc519..e6e6edf 100644 --- a/sys-utils/adjtime_config.5 +++ b/sys-utils/adjtime_config.5 @@ -2,12 +2,12 @@ .\" Title: adjtime_config .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.20 -.\" Date: 2023-10-23 +.\" Date: 2024-01-31 .\" Manual: File formats -.\" Source: util-linux 2.39.3 +.\" Source: util-linux 2.40 .\" Language: English .\" -.TH "ADJTIME_CONFIG" "5" "2023-10-23" "util\-linux 2.39.3" "File formats" +.TH "ADJTIME_CONFIG" "5" "2024-01-31" "util\-linux 2.40" "File formats" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 diff --git a/sys-utils/blkdiscard.8 b/sys-utils/blkdiscard.8 index 2bd5c2f..62a9630 100644 --- a/sys-utils/blkdiscard.8 +++ b/sys-utils/blkdiscard.8 @@ -2,12 +2,12 @@ .\" Title: blkdiscard .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.20 -.\" Date: 2023-11-21 +.\" Date: 2024-01-31 .\" Manual: System Administration -.\" Source: util-linux 2.39.3 +.\" Source: util-linux 2.40 .\" Language: English .\" -.TH "BLKDISCARD" "8" "2023-11-21" "util\-linux 2.39.3" "System Administration" +.TH "BLKDISCARD" "8" "2024-01-31" "util\-linux 2.40" "System Administration" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 diff --git a/sys-utils/blkdiscard.c b/sys-utils/blkdiscard.c index ed8d6a0..16c32e6 100644 --- a/sys-utils/blkdiscard.c +++ b/sys-utils/blkdiscard.c @@ -105,12 +105,12 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" -z, --zeroout zero-fill rather than discard\n"), out); fputs(USAGE_SEPARATOR, out); - printf(USAGE_HELP_OPTIONS(21)); + fprintf(out, USAGE_HELP_OPTIONS(21)); fputs(USAGE_ARGUMENTS, out); - printf(USAGE_ARG_SIZE(_(""))); + fprintf(out, USAGE_ARG_SIZE(_(""))); - printf(USAGE_MAN_TAIL("blkdiscard(8)")); + fprintf(out, USAGE_MAN_TAIL("blkdiscard(8)")); exit(EXIT_SUCCESS); } diff --git a/sys-utils/blkpr.8 b/sys-utils/blkpr.8 index 9299392..f284183 100644 --- a/sys-utils/blkpr.8 +++ b/sys-utils/blkpr.8 @@ -2,12 +2,12 @@ .\" Title: blkpr .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.20 -.\" Date: 2023-11-21 +.\" Date: 2024-01-31 .\" Manual: System Administration -.\" Source: util-linux 2.39.3 +.\" Source: util-linux 2.40 .\" Language: English .\" -.TH "BLKPR" "8" "2023-11-21" "util\-linux 2.39.3" "System Administration" +.TH "BLKPR" "8" "2024-01-31" "util\-linux 2.40" "System Administration" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 diff --git a/sys-utils/blkpr.c b/sys-utils/blkpr.c index 90763db..7f88eba 100644 --- a/sys-utils/blkpr.c +++ b/sys-utils/blkpr.c @@ -223,7 +223,7 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" -t, --type command type\n"), out); fputs(USAGE_SEPARATOR, out); - printf(USAGE_HELP_OPTIONS(26)); + fprintf(out, USAGE_HELP_OPTIONS(26)); fputs(USAGE_ARGUMENTS, out); @@ -236,7 +236,7 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" is a command type, available types:\n"), out); print_pr_type(out); - printf(USAGE_MAN_TAIL("blkpr(8)")); + fprintf(out, USAGE_MAN_TAIL("blkpr(8)")); exit(EXIT_SUCCESS); } diff --git a/sys-utils/blkzone.8 b/sys-utils/blkzone.8 index f2be426..2a933e9 100644 --- a/sys-utils/blkzone.8 +++ b/sys-utils/blkzone.8 @@ -2,12 +2,12 @@ .\" Title: blkzone .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.20 -.\" Date: 2023-10-23 +.\" Date: 2024-01-31 .\" Manual: System Administration -.\" Source: util-linux 2.39.3 +.\" Source: util-linux 2.40 .\" Language: English .\" -.TH "BLKZONE" "8" "2023-10-23" "util\-linux 2.39.3" "System Administration" +.TH "BLKZONE" "8" "2024-01-31" "util\-linux 2.40" "System Administration" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 diff --git a/sys-utils/blkzone.c b/sys-utils/blkzone.c index 81191e1..9706d61 100644 --- a/sys-utils/blkzone.c +++ b/sys-utils/blkzone.c @@ -402,12 +402,12 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" -f, --force enforce on block devices used by the system\n"), out); fputs(_(" -v, --verbose display more details\n"), out); fputs(USAGE_SEPARATOR, out); - printf(USAGE_HELP_OPTIONS(24)); + fprintf(out, USAGE_HELP_OPTIONS(24)); fputs(USAGE_ARGUMENTS, out); - printf(USAGE_ARG_SIZE(_(" and "))); + fprintf(out, USAGE_ARG_SIZE(_(" and "))); - printf(USAGE_MAN_TAIL("blkzone(8)")); + fprintf(out, USAGE_MAN_TAIL("blkzone(8)")); exit(EXIT_SUCCESS); } diff --git a/sys-utils/chcpu.8 b/sys-utils/chcpu.8 index b8a02bf..25e1801 100644 --- a/sys-utils/chcpu.8 +++ b/sys-utils/chcpu.8 @@ -2,12 +2,12 @@ .\" Title: chcpu .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.20 -.\" Date: 2023-10-23 +.\" Date: 2024-03-20 .\" Manual: System Administration -.\" Source: util-linux 2.39.3 +.\" Source: util-linux 2.40 .\" Language: English .\" -.TH "CHCPU" "8" "2023-10-23" "util\-linux 2.39.3" "System Administration" +.TH "CHCPU" "8" "2024-03-20" "util\-linux 2.40" "System Administration" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 @@ -61,6 +61,8 @@ Enable the specified CPUs. Enabling a CPU means that the kernel sets it online. \fB\-g\fP, \fB\-\-deconfigure\fP \fIcpu\-list\fP .RS 4 Deconfigure the specified CPUs. Deconfiguring a CPU means that the hypervisor removes the CPU from the virtual hardware on which the Linux instance runs and returns it to the CPU pool. A CPU must be offline, see \fB\-d\fP, before it can be deconfigured. +.sp +\fBchcpu \-g\fP is not supported on IBM z/VM, CPUs are always in a configured. .RE .sp \fB\-p\fP, \fB\-\-dispatch\fP \fImode\fP diff --git a/sys-utils/chcpu.8.adoc b/sys-utils/chcpu.8.adoc index c5797df..80dfc5f 100644 --- a/sys-utils/chcpu.8.adoc +++ b/sys-utils/chcpu.8.adoc @@ -37,6 +37,8 @@ Enable the specified CPUs. Enabling a CPU means that the kernel sets it online. *-g*, *--deconfigure* _cpu-list_:: Deconfigure the specified CPUs. Deconfiguring a CPU means that the hypervisor removes the CPU from the virtual hardware on which the Linux instance runs and returns it to the CPU pool. A CPU must be offline, see *-d*, before it can be deconfigured. ++ +*chcpu -g* is not supported on IBM z/VM, CPUs are always in a configured. *-p*, *--dispatch* _mode_:: Set the CPU dispatching _mode_ (polarization). This option has an effect only if your hardware architecture and hypervisor support CPU polarization. Available _modes_ are: diff --git a/sys-utils/chcpu.c b/sys-utils/chcpu.c index 527bce5..ab765a6 100644 --- a/sys-utils/chcpu.c +++ b/sys-utils/chcpu.c @@ -253,9 +253,9 @@ static void __attribute__((__noreturn__)) usage(void) " -p, --dispatch set dispatching mode\n" " -r, --rescan trigger rescan of cpus\n" ), stdout); - printf(USAGE_HELP_OPTIONS(31)); + fprintf(stdout, USAGE_HELP_OPTIONS(31)); - printf(USAGE_MAN_TAIL("chcpu(8)")); + fprintf(stdout, USAGE_MAN_TAIL("chcpu(8)")); exit(EXIT_SUCCESS); } diff --git a/sys-utils/chmem.8 b/sys-utils/chmem.8 index 793e51c..79eccc4 100644 --- a/sys-utils/chmem.8 +++ b/sys-utils/chmem.8 @@ -2,12 +2,12 @@ .\" Title: chmem .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.20 -.\" Date: 2023-10-23 +.\" Date: 2024-01-31 .\" Manual: System Administration -.\" Source: util-linux 2.39.3 +.\" Source: util-linux 2.40 .\" Language: English .\" -.TH "CHMEM" "8" "2023-10-23" "util\-linux 2.39.3" "System Administration" +.TH "CHMEM" "8" "2024-01-31" "util\-linux 2.40" "System Administration" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 diff --git a/sys-utils/chmem.c b/sys-utils/chmem.c index 09d0af6..4e79859 100644 --- a/sys-utils/chmem.c +++ b/sys-utils/chmem.c @@ -348,13 +348,13 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" -b, --blocks use memory blocks\n"), out); fputs(_(" -z, --zone select memory zone (see below)\n"), out); fputs(_(" -v, --verbose verbose output\n"), out); - printf(USAGE_HELP_OPTIONS(20)); + fprintf(out, USAGE_HELP_OPTIONS(20)); fputs(_("\nSupported zones:\n"), out); for (i = 0; i < ARRAY_SIZE(zone_names); i++) fprintf(out, " %s\n", zone_names[i]); - printf(USAGE_MAN_TAIL("chmem(8)")); + fprintf(out, USAGE_MAN_TAIL("chmem(8)")); exit(EXIT_SUCCESS); } diff --git a/sys-utils/choom.1 b/sys-utils/choom.1 index 9645f75..11b1ff3 100644 --- a/sys-utils/choom.1 +++ b/sys-utils/choom.1 @@ -2,12 +2,12 @@ .\" Title: choom .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.20 -.\" Date: 2023-10-23 +.\" Date: 2024-01-31 .\" Manual: User Commands -.\" Source: util-linux 2.39.3 +.\" Source: util-linux 2.40 .\" Language: English .\" -.TH "CHOOM" "1" "2023-10-23" "util\-linux 2.39.3" "User Commands" +.TH "CHOOM" "1" "2024-01-31" "util\-linux 2.40" "User Commands" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 diff --git a/sys-utils/choom.c b/sys-utils/choom.c index b3d3e4d..4bf746b 100644 --- a/sys-utils/choom.c +++ b/sys-utils/choom.c @@ -47,8 +47,8 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" -n, --adjust specify the adjust score value\n"), out); fputs(_(" -p, --pid process ID\n"), out); fputs(USAGE_SEPARATOR, out); - printf(USAGE_HELP_OPTIONS(24)); - printf(USAGE_MAN_TAIL("choom(1)")); + fprintf(out, USAGE_HELP_OPTIONS(24)); + fprintf(out, USAGE_MAN_TAIL("choom(1)")); exit(EXIT_SUCCESS); } diff --git a/sys-utils/ctrlaltdel.8 b/sys-utils/ctrlaltdel.8 index bc4825a..fb1e64e 100644 --- a/sys-utils/ctrlaltdel.8 +++ b/sys-utils/ctrlaltdel.8 @@ -2,12 +2,12 @@ .\" Title: ctrlaltdel .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.20 -.\" Date: 2023-10-23 +.\" Date: 2024-01-31 .\" Manual: System Administration -.\" Source: util-linux 2.39.3 +.\" Source: util-linux 2.40 .\" Language: English .\" -.TH "CTRLALTDEL" "8" "2023-10-23" "util\-linux 2.39.3" "System Administration" +.TH "CTRLALTDEL" "8" "2024-01-31" "util\-linux 2.40" "System Administration" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 diff --git a/sys-utils/ctrlaltdel.c b/sys-utils/ctrlaltdel.c index 303d2dc..1601154 100644 --- a/sys-utils/ctrlaltdel.c +++ b/sys-utils/ctrlaltdel.c @@ -1,10 +1,16 @@ /* - * ctrlaltdel.c - Set the function of the Ctrl-Alt-Del combination - * Created 4-Jul-92 by Peter Orbaek - * 1999-02-22 Arkadiusz Miśkiewicz - * - added Native Language Support + * 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) 1992 Peter Orbaek + * Copyright (C) 1992-1993 Rickard E. Faith + * + * Set the function of the Ctrl-Alt-Del combination */ - #include #include #include @@ -31,8 +37,8 @@ static void __attribute__((__noreturn__)) usage(void) fprintf(out, _("Set the function of the Ctrl-Alt-Del combination.\n")); fputs(USAGE_OPTIONS, out); - printf(USAGE_HELP_OPTIONS(16)); - printf(USAGE_MAN_TAIL("ctrlaltdel(8)")); + fprintf(out, USAGE_HELP_OPTIONS(16)); + fprintf(out, USAGE_MAN_TAIL("ctrlaltdel(8)")); exit(EXIT_SUCCESS); } @@ -62,10 +68,6 @@ static int set_cad(const char *arg) { unsigned int cmd; - if (geteuid()) { - warnx(_("You must be root to set the Ctrl-Alt-Del behavior")); - return EXIT_FAILURE; - } if (!strcmp("hard", arg)) cmd = LINUX_REBOOT_CMD_CAD_ON; else if (!strcmp("soft", arg)) diff --git a/sys-utils/dmesg.1 b/sys-utils/dmesg.1 index f70633c..a66cf99 100644 --- a/sys-utils/dmesg.1 +++ b/sys-utils/dmesg.1 @@ -2,12 +2,12 @@ .\" Title: dmesg .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.20 -.\" Date: 2023-11-23 +.\" Date: 2024-03-20 .\" Manual: User Commands -.\" Source: util-linux 2.39.3 +.\" Source: util-linux 2.40 .\" Language: English .\" -.TH "DMESG" "1" "2023-11-23" "util\-linux 2.39.3" "User Commands" +.TH "DMESG" "1" "2024-03-20" "util\-linux 2.40" "User Commands" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 @@ -83,7 +83,7 @@ Display the local time and the delta in human\-readable format. Be aware that co .sp \fB\-F\fP, \fB\-\-file\fP \fIfile\fP .RS 4 -Read the syslog messages from the given \fIfile\fP. Note that \fB\-F\fP does not support messages in kmsg format. The old syslog format is supported only. +Read the syslog messages from the given \fIfile\fP. Note that \fB\-F\fP does not support messages in kmsg format. See \fB\-K\fP instead. .RE .sp \fB\-f\fP, \fB\-\-facility\fP \fIlist\fP @@ -105,6 +105,11 @@ Enable human\-readable output. See also \fB\-\-color\fP, \fB\-\-reltime\fP and \ Use JSON output format. The time output format is in "sec.usec" format only, log priority level is not decoded by default (use \fB\-\-decode\fP to split into facility and priority), the other options to control the output format or time format are silently ignored. .RE .sp +\fB\-K\fP, \fB\-\-kmsg\-file\fP \fIfile\fP +.RS 4 +Read the /dev/kmsg messages from the given \fIfile\fP. Different record as expected to be separated by a NULL byte. +.RE +.sp \fB\-k\fP, \fB\-\-kernel\fP .RS 4 Print kernel messages. @@ -195,9 +200,13 @@ Do not print kernel\(cqs timestamps. .sp \fB\-\-time\-format\fP \fIformat\fP .RS 4 -Print timestamps using the given \fIformat\fP, which can be \fBctime\fP, \fBreltime\fP, \fBdelta\fP or \fBiso\fP. The first three formats are aliases of the time\-format\-specific options. The \fBiso\fP format is a \fBdmesg\fP implementation of the ISO\-8601 timestamp format. The purpose of this format is to make the comparing of timestamps between two systems, and any other parsing, easy. The definition of the \fBiso\fP timestamp is: YYYY\-MM\-DDHH:MM:SS,\(<-+>. +Print timestamps using the given \fIformat\fP, which can be \fBctime\fP, \fBreltime\fP, \fBdelta\fP, \fBiso\fP or \fBraw\fP. The first three formats are aliases of the time\-format\-specific options. The \fBraw\fP format uses the default timestamp format showing seconds since boot. The \fBiso\fP format is a \fBdmesg\fP implementation of the ISO\-8601 timestamp format. The purpose of this format is to make the comparing of timestamps between two systems, and any other parsing, easy. The definition of the \fBiso\fP timestamp is: YYYY\-MM\-DDHH:MM:SS,\(<-+>. .sp The \fBiso\fP format has the same issue as \fBctime\fP: the time may be inaccurate when a system is suspended and resumed. +.sp +\fB\-\-time\-format\fP may be used multiple times with different values for \fIformat\fP to output each specified format. +.sp +The \fBdelta\fP always follows \fBctime\fP or \fBraw\fP if specified together. .RE .sp \fB\-u\fP, \fB\-\-userspace\fP diff --git a/sys-utils/dmesg.1.adoc b/sys-utils/dmesg.1.adoc index 6f4941e..ccdeefa 100644 --- a/sys-utils/dmesg.1.adoc +++ b/sys-utils/dmesg.1.adoc @@ -57,7 +57,7 @@ Enable printing messages to the console. Display the local time and the delta in human-readable format. Be aware that conversion to the local time could be inaccurate (see *-T* for more details). *-F*, *--file* _file_:: -Read the syslog messages from the given _file_. Note that *-F* does not support messages in kmsg format. The old syslog format is supported only. +Read the syslog messages from the given _file_. Note that *-F* does not support messages in kmsg format. See *-K* instead. *-f*, *--facility* _list_:: Restrict output to the given (comma-separated) _list_ of facilities. For example: @@ -72,6 +72,9 @@ Enable human-readable output. See also *--color*, *--reltime* and *--nopager*. *-J*, *--json*:: Use JSON output format. The time output format is in "sec.usec" format only, log priority level is not decoded by default (use *--decode* to split into facility and priority), the other options to control the output format or time format are silently ignored. +*-K*, *--kmsg-file* _file_:: +Read the /dev/kmsg messages from the given _file_. Different record as expected to be separated by a NULL byte. + *-k*, *--kernel*:: Print kernel messages. @@ -133,9 +136,13 @@ Display record until the specified time. Supported is the subsecond granularity. Do not print kernel's timestamps. *--time-format* _format_:: -Print timestamps using the given _format_, which can be *ctime*, *reltime*, *delta* or *iso*. The first three formats are aliases of the time-format-specific options. The *iso* format is a *dmesg* implementation of the ISO-8601 timestamp format. The purpose of this format is to make the comparing of timestamps between two systems, and any other parsing, easy. The definition of the *iso* timestamp is: YYYY-MM-DDHH:MM:SS,<-+>. +Print timestamps using the given _format_, which can be *ctime*, *reltime*, *delta*, *iso* or *raw*. The first three formats are aliases of the time-format-specific options. The *raw* format uses the default timestamp format showing seconds since boot. The *iso* format is a *dmesg* implementation of the ISO-8601 timestamp format. The purpose of this format is to make the comparing of timestamps between two systems, and any other parsing, easy. The definition of the *iso* timestamp is: YYYY-MM-DDHH:MM:SS,<-+>. + The *iso* format has the same issue as *ctime*: the time may be inaccurate when a system is suspended and resumed. ++ +*--time-format* may be used multiple times with different values for _format_ to output each specified format. ++ +The *delta* always follows *ctime* or *raw* if specified together. *-u*, *--userspace*:: Print userspace messages. diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c index 717cc58..25c674b 100644 --- a/sys-utils/dmesg.c +++ b/sys-utils/dmesg.c @@ -1,14 +1,21 @@ /* + * 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. + * * dmesg.c -- Print out the contents of the kernel ring buffer * * Copyright (C) 1993 Theodore Ts'o - * Copyright (C) 2011 Karel Zak - * - * This program comes with ABSOLUTELY NO WARRANTY. + * Copyright (C) 2011-2023 Karel Zak */ #include #include +#include #include +#include #include #include #include @@ -36,6 +43,7 @@ #include "mangle.h" #include "pager.h" #include "jsonwrt.h" +#include "pathnames.h" /* Close the log. Currently a NOP. */ #define SYSLOG_ACTION_CLOSE 0 @@ -60,6 +68,12 @@ /* Return size of the log buffer */ #define SYSLOG_ACTION_SIZE_BUFFER 10 +#define PID_CHARS_MAX sizeof(stringify_value(LONG_MAX)) +#define PID_CHARS_DEFAULT sizeof(stringify_value(INT_MAX)) +#define SYSLOG_DEFAULT_CALLER_ID_CHARS sizeof(stringify_value(SHRT_MAX))-1 +#define DMESG_CALLER_PREFIX "caller=" +#define DMESG_CALLER_PREFIXSZ (sizeof(DMESG_CALLER_PREFIX)-1) + /* * Color scheme */ @@ -125,6 +139,7 @@ static const struct dmesg_name level_names[] = * shifted code :-) */ #define FAC_BASE(f) ((f) >> 3) +#define LOG_RAW_FAC_PRI(fac, pri) ((fac << 3) | pri) static const struct dmesg_name facility_names[] = { @@ -140,6 +155,18 @@ static const struct dmesg_name facility_names[] = [FAC_BASE(LOG_CRON)] = { "cron", N_("clock daemon") }, [FAC_BASE(LOG_AUTHPRIV)] = { "authpriv", N_("security/authorization messages (private)") }, [FAC_BASE(LOG_FTP)] = { "ftp", N_("FTP daemon") }, + [FAC_BASE(LOG_FTP) + 1] = { "res0", N_("reserved 0") }, + [FAC_BASE(LOG_FTP) + 2] = { "res1", N_("reserved 1") }, + [FAC_BASE(LOG_FTP) + 3] = { "res2", N_("reserved 2") }, + [FAC_BASE(LOG_FTP) + 4] = { "res3", N_("reserved 3") }, + [FAC_BASE(LOG_LOCAL0)] = { "local0", N_("local use 0") }, + [FAC_BASE(LOG_LOCAL1)] = { "local1", N_("local use 1") }, + [FAC_BASE(LOG_LOCAL2)] = { "local2", N_("local use 2") }, + [FAC_BASE(LOG_LOCAL3)] = { "local3", N_("local use 3") }, + [FAC_BASE(LOG_LOCAL4)] = { "local4", N_("local use 4") }, + [FAC_BASE(LOG_LOCAL5)] = { "local5", N_("local use 5") }, + [FAC_BASE(LOG_LOCAL6)] = { "local6", N_("local use 6") }, + [FAC_BASE(LOG_LOCAL7)] = { "local7", N_("local use 7") }, }; /* supported methods to read message buffer @@ -158,9 +185,12 @@ enum { DMESG_TIMEFTM_RELTIME, /* [relative] */ DMESG_TIMEFTM_TIME, /* [time] */ DMESG_TIMEFTM_TIME_DELTA, /* [time ] */ - DMESG_TIMEFTM_ISO8601 /* 2013-06-13T22:11:00,123456+0100 */ + DMESG_TIMEFTM_ISO8601, /* 2013-06-13T22:11:00,123456+0100 */ + + __DMESG_TIMEFTM_COUNT }; -#define is_timefmt(c, f) ((c)->time_fmt == (DMESG_TIMEFTM_ ##f)) + +#define DMESG_TIMEFTM_DEFAULT DMESG_TIMEFTM_TIME struct dmesg_control { /* bit arrays -- see include/bitops.h */ @@ -198,7 +228,8 @@ struct dmesg_control { char *filename; char *mmap_buff; size_t pagesize; - unsigned int time_fmt; /* time format */ + size_t ntime_fmts; + unsigned int time_fmts[2 * __DMESG_TIMEFTM_COUNT]; /* time format */ struct ul_jsonwrt jfmt; /* -J formatting */ @@ -215,6 +246,7 @@ struct dmesg_control { force_prefix:1; /* force timestamp and decode prefix on each line */ int indent; /* due to timestamps if newline */ + size_t caller_id_size; /* PRINTK_CALLERID max field size */ }; struct dmesg_record { @@ -224,6 +256,7 @@ struct dmesg_record { int level; int facility; struct timeval tv; + char caller_id[PID_CHARS_MAX]; const char *next; /* buffer with next unparsed record */ size_t next_size; /* size of the next buffer */ @@ -236,9 +269,11 @@ struct dmesg_record { (_r)->level = -1; \ (_r)->tv.tv_sec = 0; \ (_r)->tv.tv_usec = 0; \ + (_r)->caller_id[0] = 0; \ } while (0) -static int read_kmsg(struct dmesg_control *ctl); +static int process_kmsg(struct dmesg_control *ctl); +static int process_kmsg_file(struct dmesg_control *ctl, char **buf); static int set_level_color(int log_level, const char *mesg, size_t mesgsz) { @@ -290,6 +325,7 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" -D, --console-off disable printing messages to console\n"), out); fputs(_(" -E, --console-on enable printing messages to console\n"), out); fputs(_(" -F, --file use the file instead of the kernel log buffer\n"), out); + fputs(_(" -K, --kmsg-file use the file in kmsg format\n"), out); fputs(_(" -f, --facility restrict output to defined facilities\n"), out); fputs(_(" -H, --human human readable output\n"), out); fputs(_(" -J, --json use JSON output format\n"), out); @@ -315,15 +351,15 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" -T, --ctime show human-readable timestamp (may be inaccurate!)\n"), out); fputs(_(" -t, --notime don't show any timestamp with messages\n"), out); fputs(_(" --time-format show timestamp using the given format:\n" - " [delta|reltime|ctime|notime|iso]\n" + " [delta|reltime|ctime|notime|iso|raw]\n" "Suspending/resume will make ctime and iso timestamps inaccurate.\n"), out); fputs(_(" --since