use pointer arithmetics for dump_dmesg
Resolves: bz2069200 Upstream: github.com/makedumpfile/makedumpfile.git Conflicts: None commit e1d2e5302b016c6f7942f46ffa27aa31326686c5 Author: Philipp Rudo <prudo@redhat.com> Date: Mon Mar 14 17:04:30 2022 +0100 [PATCH v2 2/3] use pointer arithmetics for dump_dmesg When parsing the printk buffer for the old printk mechanism (> v3.5.0+ and < 5.10.0) a log entry is currently specified by the offset into the buffer where the entry starts. Change this to use a pointers instead. This is done in preparation for using the new cycle detection mechanism. Signed-off-by: Philipp Rudo <prudo@redhat.com> Reviewed-and-tested-by: Dave Wysochanski <dwysocha@redhat.com> Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com> Signed-off-by: Philipp Rudo <prudo@redhat.com>
This commit is contained in:
parent
90da030e61
commit
92f7d2ba5e
@ -0,0 +1,102 @@
|
||||
commit e1d2e5302b016c6f7942f46ffa27aa31326686c5
|
||||
Author: Philipp Rudo <prudo@redhat.com>
|
||||
Date: Mon Mar 14 17:04:30 2022 +0100
|
||||
|
||||
[PATCH v2 2/3] use pointer arithmetics for dump_dmesg
|
||||
|
||||
When parsing the printk buffer for the old printk mechanism (> v3.5.0+ and
|
||||
< 5.10.0) a log entry is currently specified by the offset into the
|
||||
buffer where the entry starts. Change this to use a pointers instead.
|
||||
This is done in preparation for using the new cycle detection mechanism.
|
||||
|
||||
Signed-off-by: Philipp Rudo <prudo@redhat.com>
|
||||
Reviewed-and-tested-by: Dave Wysochanski <dwysocha@redhat.com>
|
||||
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
|
||||
|
||||
diff --git a/makedumpfile-1.7.0/makedumpfile.c b/makedumpfile-1.7.0/makedumpfile.c
|
||||
index 7ed9756a8c43ae4a2b6770e86dc81763796c2187..e72dba219eec198ec865045562f39a14b5a092eb 100644
|
||||
--- a/makedumpfile-1.7.0/makedumpfile.c
|
||||
+++ b/makedumpfile-1.7.0/makedumpfile.c
|
||||
@@ -5482,13 +5482,10 @@ dump_log_entry(char *logptr, int fp, const char *file_name)
|
||||
* get log record by index; idx must point to valid message.
|
||||
*/
|
||||
static char *
|
||||
-log_from_idx(unsigned int idx, char *logbuf)
|
||||
+log_from_ptr(char *logptr, char *logbuf)
|
||||
{
|
||||
- char *logptr;
|
||||
unsigned int msglen;
|
||||
|
||||
- logptr = logbuf + idx;
|
||||
-
|
||||
/*
|
||||
* A length == 0 record is the end of buffer marker.
|
||||
* Wrap around and return the message at the start of
|
||||
@@ -5497,19 +5494,16 @@ log_from_idx(unsigned int idx, char *logbuf)
|
||||
|
||||
msglen = USHORT(logptr + OFFSET(printk_log.len));
|
||||
if (!msglen)
|
||||
- logptr = logbuf;
|
||||
+ return logbuf;
|
||||
|
||||
return logptr;
|
||||
}
|
||||
|
||||
-static long
|
||||
-log_next(unsigned int idx, char *logbuf)
|
||||
+static void *
|
||||
+log_next(void *logptr, void *logbuf)
|
||||
{
|
||||
- char *logptr;
|
||||
unsigned int msglen;
|
||||
|
||||
- logptr = logbuf + idx;
|
||||
-
|
||||
/*
|
||||
* A length == 0 record is the end of buffer marker. Wrap around and
|
||||
* read the message at the start of the buffer as *this* one, and
|
||||
@@ -5519,10 +5513,10 @@ log_next(unsigned int idx, char *logbuf)
|
||||
msglen = USHORT(logptr + OFFSET(printk_log.len));
|
||||
if (!msglen) {
|
||||
msglen = USHORT(logbuf + OFFSET(printk_log.len));
|
||||
- return msglen;
|
||||
+ return logbuf + msglen;
|
||||
}
|
||||
|
||||
- return idx + msglen;
|
||||
+ return logptr + msglen;
|
||||
}
|
||||
|
||||
int
|
||||
@@ -5530,11 +5524,12 @@ dump_dmesg()
|
||||
{
|
||||
int log_buf_len, length_log, length_oldlog, ret = FALSE;
|
||||
unsigned long index, log_buf, log_end;
|
||||
- unsigned int idx, log_first_idx, log_next_idx;
|
||||
+ unsigned int log_first_idx, log_next_idx;
|
||||
unsigned long long first_idx_sym;
|
||||
unsigned long log_end_2_6_24;
|
||||
unsigned log_end_2_6_25;
|
||||
char *log_buffer = NULL, *log_ptr = NULL;
|
||||
+ char *ptr;
|
||||
|
||||
/*
|
||||
* log_end has been changed to "unsigned" since linux-2.6.25.
|
||||
@@ -5681,13 +5676,13 @@ dump_dmesg()
|
||||
ERRMSG("Can't open output file.\n");
|
||||
goto out;
|
||||
}
|
||||
- idx = log_first_idx;
|
||||
- while (idx != log_next_idx) {
|
||||
- log_ptr = log_from_idx(idx, log_buffer);
|
||||
+ ptr = log_buffer + log_first_idx;
|
||||
+ while (ptr != log_buffer + log_next_idx) {
|
||||
+ log_ptr = log_from_ptr(ptr, log_buffer);
|
||||
if (!dump_log_entry(log_ptr, info->fd_dumpfile,
|
||||
info->name_dumpfile))
|
||||
goto out;
|
||||
- idx = log_next(idx, log_buffer);
|
||||
+ ptr = log_next(ptr, log_buffer);
|
||||
}
|
||||
if (!close_files_for_creating_dumpfile())
|
||||
goto out;
|
@ -114,6 +114,7 @@ Requires: systemd-udev%{?_isa}
|
||||
Patch601: ./kexec-tools-2.0.22-01-s390_handle_R_390_PLT32DBL_reloc_entries_in_machine_apply_elf_rel_.patch
|
||||
Patch602: ./kexec-tools-2.0.23-makedumpfile-sadump-kaslr-fix-failure-of-calculating-kaslr_.patch
|
||||
Patch603: ./kexec-tools-2.0.23-01-_PATCH_v2_1_3_add_generic_cycle_detection.patch
|
||||
Patch604: ./kexec-tools-2.0.23-02-_PATCH_v2_2_3_use_pointer_arithmetics_for_dump_dmesg.patch
|
||||
|
||||
%description
|
||||
kexec-tools provides /sbin/kexec binary that facilitates a new
|
||||
@ -132,6 +133,7 @@ tar -z -x -v -f %{SOURCE19}
|
||||
%patch601 -p1
|
||||
%patch602 -p1
|
||||
%patch603 -p1
|
||||
%patch604 -p1
|
||||
|
||||
%ifarch ppc
|
||||
%define archdef ARCH=ppc
|
||||
|
Loading…
Reference in New Issue
Block a user