2.31-2: dmesg fix
This commit is contained in:
parent
3251a896f8
commit
4420515181
194
0001-Revert-dmesg-fragment-concatenation.patch
Normal file
194
0001-Revert-dmesg-fragment-concatenation.patch
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
From 8a6f0cfd96a3a7f0e72079407af4b8ed705c1ed2 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Karel Zak <kzak@redhat.com>
|
||||||
|
Date: Mon, 30 Oct 2017 15:04:20 +0100
|
||||||
|
Subject: [PATCH] Revert "dmesg: fragment concatenation"
|
||||||
|
|
||||||
|
* introduces regressions
|
||||||
|
* stupid code; parse_kmsg_record() called more than once for each record
|
||||||
|
|
||||||
|
This reverts commit 22eb2f0190d8a9850da750641439ccd284ac0bfe.
|
||||||
|
---
|
||||||
|
sys-utils/dmesg.c | 117 ++++--------------------------------------------------
|
||||||
|
1 file changed, 7 insertions(+), 110 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/sys-utils/dmesg.c b/sys-utils/dmesg.c
|
||||||
|
index b626380f7..6e5911a76 100644
|
||||||
|
--- a/sys-utils/dmesg.c
|
||||||
|
+++ b/sys-utils/dmesg.c
|
||||||
|
@@ -20,7 +20,6 @@
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
-#include <poll.h>
|
||||||
|
|
||||||
|
#include "c.h"
|
||||||
|
#include "colors.h"
|
||||||
|
@@ -179,8 +178,6 @@ struct dmesg_control {
|
||||||
|
int kmsg; /* /dev/kmsg file descriptor */
|
||||||
|
ssize_t kmsg_first_read;/* initial read() return code */
|
||||||
|
char kmsg_buf[BUFSIZ];/* buffer to read kmsg data */
|
||||||
|
- char kmsg_saved[BUFSIZ];/* buffer to save line after fragment */
|
||||||
|
- ssize_t kmsg_saved_size; /* if nonzero, read from kmsg_saved */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* For the --file option we mmap whole file. The unnecessary (already
|
||||||
|
@@ -209,7 +206,6 @@ struct dmesg_record {
|
||||||
|
int level;
|
||||||
|
int facility;
|
||||||
|
struct timeval tv;
|
||||||
|
- char flags;
|
||||||
|
|
||||||
|
const char *next; /* buffer with next unparsed record */
|
||||||
|
size_t next_size; /* size of the next buffer */
|
||||||
|
@@ -226,13 +222,6 @@ struct dmesg_record {
|
||||||
|
|
||||||
|
static int read_kmsg(struct dmesg_control *ctl);
|
||||||
|
|
||||||
|
-
|
||||||
|
-static int parse_kmsg_record(struct dmesg_control *ctl,
|
||||||
|
- struct dmesg_record *rec,
|
||||||
|
- char *buf,
|
||||||
|
- size_t sz);
|
||||||
|
-
|
||||||
|
-
|
||||||
|
static int set_level_color(int log_level, const char *mesg, size_t mesgsz)
|
||||||
|
{
|
||||||
|
int id = -1;
|
||||||
|
@@ -1024,101 +1013,15 @@ static void print_buffer(struct dmesg_control *ctl,
|
||||||
|
print_record(ctl, &rec);
|
||||||
|
}
|
||||||
|
|
||||||
|
-/*
|
||||||
|
- * Read one record from kmsg, automatically concatenating message fragments
|
||||||
|
- */
|
||||||
|
static ssize_t read_kmsg_one(struct dmesg_control *ctl)
|
||||||
|
{
|
||||||
|
ssize_t size;
|
||||||
|
- struct dmesg_record rec = { .flags = 0 };
|
||||||
|
- char fragment_buf[BUFSIZ] = { 0 };
|
||||||
|
- ssize_t fragment_offset = 0;
|
||||||
|
-
|
||||||
|
- if (ctl->kmsg_saved_size != 0) {
|
||||||
|
- size = ctl->kmsg_saved_size;
|
||||||
|
- memcpy(ctl->kmsg_buf, ctl->kmsg_saved, size);
|
||||||
|
- ctl->kmsg_saved_size = 0;
|
||||||
|
- return size;
|
||||||
|
- }
|
||||||
|
|
||||||
|
- /*
|
||||||
|
- * kmsg returns EPIPE if record was modified while reading.
|
||||||
|
- * Read records until there is one with a flag different from 'c'/'+',
|
||||||
|
- * which indicates that a fragment (if it exists) is complete.
|
||||||
|
- */
|
||||||
|
+ /* kmsg returns EPIPE if record was modified while reading */
|
||||||
|
do {
|
||||||
|
- /*
|
||||||
|
- * If there is a fragment in progress, and we're in follow mode,
|
||||||
|
- * read with a timeout so that if no line is read in 100ms, we can
|
||||||
|
- * assume that the fragment is the last line in /dev/kmsg and it
|
||||||
|
- * is completed.
|
||||||
|
- */
|
||||||
|
- if (ctl->follow && fragment_offset) {
|
||||||
|
- struct pollfd pfd = {.fd = ctl->kmsg, .events = POLLIN};
|
||||||
|
- poll(&pfd, 1, 100);
|
||||||
|
- /* If 100ms has passed and kmsg has no data to read() */
|
||||||
|
- if (!(pfd.revents & POLLIN)) {
|
||||||
|
- memcpy(ctl->kmsg_buf, fragment_buf, fragment_offset);
|
||||||
|
- return fragment_offset + 1;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- size = read(ctl->kmsg, ctl->kmsg_buf, sizeof(ctl->kmsg_buf) - 1);
|
||||||
|
-
|
||||||
|
- /*
|
||||||
|
- * If read() would have blocked and we have a fragment in
|
||||||
|
- * progress, assume that it's completed (ie. it was the last line
|
||||||
|
- * in the ring buffer) otherwise it won't be displayed until
|
||||||
|
- * another non-fragment message is logged.
|
||||||
|
- */
|
||||||
|
- if (errno == EAGAIN && fragment_offset) {
|
||||||
|
- memcpy(ctl->kmsg_buf, fragment_buf, fragment_offset);
|
||||||
|
- return fragment_offset + 1;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if (parse_kmsg_record(ctl, &rec, ctl->kmsg_buf,
|
||||||
|
- (size_t) size) == 0) {
|
||||||
|
- /*
|
||||||
|
- * 'c' can indicate a start of a fragment or a
|
||||||
|
- * continuation, '+' is used in older kernels to
|
||||||
|
- * indicate a continuation.
|
||||||
|
- */
|
||||||
|
- if (rec.flags == 'c' || rec.flags == '+') {
|
||||||
|
- if (!fragment_offset) {
|
||||||
|
- memcpy(fragment_buf, ctl->kmsg_buf, size);
|
||||||
|
- fragment_offset = size - 1;
|
||||||
|
- } else {
|
||||||
|
- /*
|
||||||
|
- * In case of a buffer overflow, just
|
||||||
|
- * truncate the fragment - no one should
|
||||||
|
- * be logging this much anyway
|
||||||
|
- */
|
||||||
|
- ssize_t truncate_size = min(
|
||||||
|
- fragment_offset + rec.mesg_size,
|
||||||
|
- sizeof(fragment_buf));
|
||||||
|
-
|
||||||
|
- memcpy(fragment_buf + fragment_offset,
|
||||||
|
- rec.mesg, truncate_size);
|
||||||
|
- fragment_offset += rec.mesg_size;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- } else if (rec.flags == '-') {
|
||||||
|
- /*
|
||||||
|
- * If there was a fragment being built, move it
|
||||||
|
- * into kmsg_buf, but first save a copy of the
|
||||||
|
- * current message so that it doesn't get lost.
|
||||||
|
- */
|
||||||
|
- if (fragment_offset) {
|
||||||
|
- memcpy(ctl->kmsg_saved,
|
||||||
|
- ctl->kmsg_buf, size);
|
||||||
|
- ctl->kmsg_saved_size = size;
|
||||||
|
- memcpy(ctl->kmsg_buf,
|
||||||
|
- fragment_buf, fragment_offset);
|
||||||
|
- return fragment_offset + 1;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
- } while ((size < 0 && errno == EPIPE) ||
|
||||||
|
- (rec.flags == 'c' || rec.flags == '+'));
|
||||||
|
+ size = read(ctl->kmsg, ctl->kmsg_buf,
|
||||||
|
+ sizeof(ctl->kmsg_buf) - 1);
|
||||||
|
+ } while (size < 0 && errno == EPIPE);
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
@@ -1212,17 +1115,11 @@ static int parse_kmsg_record(struct dmesg_control *ctl,
|
||||||
|
if (LAST_KMSG_FIELD(p))
|
||||||
|
goto mesg;
|
||||||
|
|
||||||
|
- /* D) flags */
|
||||||
|
- rec->flags = *p; // flag is one char
|
||||||
|
- p = p + 1;
|
||||||
|
- if (LAST_KMSG_FIELD(p))
|
||||||
|
- goto mesg;
|
||||||
|
-
|
||||||
|
- /* E) optional fields (ignore) */
|
||||||
|
+ /* D) optional fields (ignore) */
|
||||||
|
p = skip_item(p, end, ";");
|
||||||
|
|
||||||
|
mesg:
|
||||||
|
- /* F) message text */
|
||||||
|
+ /* E) message text */
|
||||||
|
rec->mesg = p;
|
||||||
|
p = skip_item(p, end, "\n");
|
||||||
|
|
||||||
|
@@ -1238,7 +1135,7 @@ mesg:
|
||||||
|
*/
|
||||||
|
unhexmangle_to_buffer(rec->mesg, (char *) rec->mesg, rec->mesg_size + 1);
|
||||||
|
|
||||||
|
- /* G) message tags (ignore) */
|
||||||
|
+ /* F) message tags (ignore) */
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.13.6
|
||||||
|
|
@ -2,7 +2,7 @@
|
|||||||
Summary: A collection of basic system utilities
|
Summary: A collection of basic system utilities
|
||||||
Name: util-linux
|
Name: util-linux
|
||||||
Version: 2.31
|
Version: 2.31
|
||||||
Release: 1%{?dist}
|
Release: 2%{?dist}
|
||||||
License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain
|
License: GPLv2 and GPLv2+ and LGPLv2+ and BSD with advertising and Public Domain
|
||||||
Group: System Environment/Base
|
Group: System Environment/Base
|
||||||
URL: http://en.wikipedia.org/wiki/Util-linux
|
URL: http://en.wikipedia.org/wiki/Util-linux
|
||||||
@ -92,6 +92,9 @@ Requires: libfdisk = %{version}-%{release}
|
|||||||
# 151635 - makeing /var/log/lastlog
|
# 151635 - makeing /var/log/lastlog
|
||||||
Patch0: 2.28-login-lastlog-create.patch
|
Patch0: 2.28-login-lastlog-create.patch
|
||||||
|
|
||||||
|
# upstream
|
||||||
|
Patch1: 0001-Revert-dmesg-fragment-concatenation.patch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
The util-linux package contains a large variety of low-level system
|
The util-linux package contains a large variety of low-level system
|
||||||
utilities that are necessary for a Linux system to function. Among
|
utilities that are necessary for a Linux system to function. Among
|
||||||
@ -940,6 +943,9 @@ exit 0
|
|||||||
%{_libdir}/python*/site-packages/libmount/*
|
%{_libdir}/python*/site-packages/libmount/*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Oct 30 2017 Karel Zak <kzak@redhat.com> - 2.31-2
|
||||||
|
- fix dmesg for multi-line records
|
||||||
|
|
||||||
* Mon Oct 23 2017 Karel Zak <kzak@redhat.com> - 2.31-1
|
* Mon Oct 23 2017 Karel Zak <kzak@redhat.com> - 2.31-1
|
||||||
- upgrade to final v2.31
|
- upgrade to final v2.31
|
||||||
- move rfkill to sbin (for backward compatibility)
|
- move rfkill to sbin (for backward compatibility)
|
||||||
|
Loading…
Reference in New Issue
Block a user