----- Original Message -----
Hi
On Tue, Aug 13, 2013 at 12:43 PM, Anatol Pomozov
<anatol.pomozov(a)gmail.com> wrote:
> In kernel 3.11 it was renamed to printk_log.
> See kernel commit 62e32ac3505a0cab1c5ef8ea2c0eab3b26ed855f
>
> Tested: can run 'log' command for 3.11-rc4 and 3.3 kernel dumps
> ---
> kernel.c | 25 ++++++++++++++++---------
> 1 file changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/kernel.c b/kernel.c
> index 73c2cc6..6cc4954 100755
> --- a/kernel.c
> +++ b/kernel.c
> @@ -4428,17 +4428,24 @@ dump_variable_length_record_log(int msg_flags)
> {
> uint32_t idx, log_first_idx, log_next_idx, log_buf_len;
> ulong log_buf;
> - char *logptr, *logbuf;
> + char *logptr, *logbuf, *log_struct_name = "printk_log";
>
> if (INVALID_SIZE(log)) {
> - STRUCT_SIZE_INIT(log, "log");
> - MEMBER_OFFSET_INIT(log_ts_nsec, "log",
"ts_nsec");
> - MEMBER_OFFSET_INIT(log_len, "log", "len");
> - MEMBER_OFFSET_INIT(log_text_len, "log",
"text_len");
> - MEMBER_OFFSET_INIT(log_dict_len, "log",
"dict_len");
> - MEMBER_OFFSET_INIT(log_level, "log", "level");
> - MEMBER_SIZE_INIT(log_level, "log", "level");
> - MEMBER_OFFSET_INIT(log_flags_level, "log",
"flags_level");
> + STRUCT_SIZE_INIT(log, log_struct_name);
> + if (INVALID_SIZE(log)) {
It might be better to use kernel_symbol_exists() to find whether it is
new or old style log.
> + // It looks like a pre 3.11 kernel.
> + // See commit 62e32ac3505a0cab that changed
> structure name
> + // log -> printk_log
> + log_struct_name = "log";
> + STRUCT_SIZE_INIT(log, log_struct_name);
> + }
> + MEMBER_OFFSET_INIT(log_ts_nsec, log_struct_name,
> "ts_nsec");
> + MEMBER_OFFSET_INIT(log_len, log_struct_name, "len");
> + MEMBER_OFFSET_INIT(log_text_len, log_struct_name,
> "text_len");
> + MEMBER_OFFSET_INIT(log_dict_len, log_struct_name,
> "dict_len");
> + MEMBER_OFFSET_INIT(log_level, log_struct_name, "level");
> + MEMBER_SIZE_INIT(log_level, log_struct_name, "level");
> + MEMBER_OFFSET_INIT(log_flags_level, log_struct_name,
> "flags_level");
>
> /*
> * If things change, don't kill a dumpfile session
> --
> 1.8.3
>
Hello Anatol,
Sorry for the delay -- I'm still recovering from a 2-week vacation, and
I was planning to get around to this tomorrow (hopefully).
Anyway, the kernel_symbol_exists() function only works for kernel symbols,
not for data structures. And I don't think the symbol name of the actual
buffer has changed, correct?
Probably the best way would be to:
if (STRUCT_EXISTS("printk_log")) {
<new way>
} else {
<old way>
}
Can you post another patch?
Thanks,
Dave