Skip to contentSkip to conversation

kdump: Append newline to the last lien of vmcoreinfo note

PATCH In review Vivek Goyal 3 participants 4 messages Jul 17, 2012 – Jul 20, 2012 kexec

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kdump: Append newline to the last lien of vmcoreinfo note

Last line of vmcoreinfo note does not end with \n. Parsing all the lines in note becomes easier if all lines end with \n instead of trying to special case the last line.

I know atleast one tool, vmcore-dmesg in kexec-tools tree which made the assumption that all lines end with \n. I think it is a good idea to fix it.

---
 kernel/kexec.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/kexec.c +1 -1
Index: linux-2.6/kernel/kexec.c
===================================================================
@@ -1424,7 +1424,7 @@ static void update_vmcoreinfo_note(void)
 
 void crash_save_vmcoreinfo(void)
 {
-	vmcoreinfo_append_str("CRASHTIME=%ld", get_seconds());
+	vmcoreinfo_append_str("CRASHTIME=%ld\n", get_seconds());
 	update_vmcoreinfo_note();
 }
 
maintainer
#1 lore raw
Quoted 18 lines · On Tue, 17 Jul 2012 13:36:55 -0400 Vivek Goyal <[email protected]> wrote:

Last line of vmcoreinfo note does not end with \n. Parsing all the lines in note becomes easier if all lines end with \n instead of trying to special case the last line.

I know atleast one tool, vmcore-dmesg in kexec-tools tree which made the assumption that all lines end with \n. I think it is a good idea to fix it.

---
 kernel/kexec.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/kernel/kexec.c
===================================================================

kernel/kexec.c static void update_vmcoreinfo_note(void) · line 1429

Quoted 7 lines
kernel/kexec.c +1 -1
@@ -1424,7 +1424,7 @@ static void update_vmcoreinfo_note(void)
 
 void crash_save_vmcoreinfo(void)
 {
-	vmcoreinfo_append_str("CRASHTIME=%ld", get_seconds());
+	vmcoreinfo_append_str("CRASHTIME=%ld\n", get_seconds());
 	update_vmcoreinfo_note();
 }

huh, that was a screwup. And now we have to make what must be viewed as a non-back-compatible ABI change.

Ho hum, presumably there isn't a lot of code out there which is dependent upon a non-newline-terminated CRASHTIME record.

Why did this work at all, anyway? Is CRASHTIME always the last-emitted record?

#2 lore raw
Quoted 32 lines · Andrew Morton
Quoted 18 lines · On Tue, 17 Jul 2012 13:36:55 -0400 Vivek Goyal <[email protected]> wrote:

Last line of vmcoreinfo note does not end with \n. Parsing all the lines in note becomes easier if all lines end with \n instead of trying to special case the last line.

I know atleast one tool, vmcore-dmesg in kexec-tools tree which made the assumption that all lines end with \n. I think it is a good idea to fix it.

---
 kernel/kexec.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/kernel/kexec.c
===================================================================

kernel/kexec.c static void update_vmcoreinfo_note(void) · line 1429

Quoted 7 lines
kernel/kexec.c +1 -1
@@ -1424,7 +1424,7 @@ static void update_vmcoreinfo_note(void)
 
 void crash_save_vmcoreinfo(void)
 {
-	vmcoreinfo_append_str("CRASHTIME=%ld", get_seconds());
+	vmcoreinfo_append_str("CRASHTIME=%ld\n", get_seconds());
 	update_vmcoreinfo_note();
 }

huh, that was a screwup. And now we have to make what must be viewed as a non-back-compatible ABI change.

Quoted 2 lines

Ho hum, presumably there isn't a lot of code out there which is dependent upon a non-newline-terminated CRASHTIME record.

I think so. AFAIK, makedumpfile (vmcore filtering utility) is only user of CRASHTIME=.

Quoted 3 lines

Why did this work at all, anyway? Is CRASHTIME always the last-emitted record?

Yes, CRASHTIME= is always the last emitted line in vmcoreinfo note.

I had a quick look at makedumpfile code and looks like they read the whole note, dump it to a file and then do fgets() on the file in a loop. As it is last line in the file, fgets encounters EOF and reads the CRASHTIME= line successfully. So even after this change makedumpfile should remain unaffected.

CCing makedumpfile maintainer, Atsushi Kumagai.

Thanks
Vivek

#3 lore raw

Hello Vivek,

Quoted 45 lines · On Thu, 19 Jul 2012 09:49:21 -0400 Vivek Goyal <[email protected]> wrote:
Quoted 32 lines · Andrew Morton
Quoted 18 lines · On Tue, 17 Jul 2012 13:36:55 -0400 Vivek Goyal <[email protected]> wrote:

Last line of vmcoreinfo note does not end with \n. Parsing all the lines in note becomes easier if all lines end with \n instead of trying to special case the last line.

I know atleast one tool, vmcore-dmesg in kexec-tools tree which made the assumption that all lines end with \n. I think it is a good idea to fix it.

---
 kernel/kexec.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/kernel/kexec.c
===================================================================

kernel/kexec.c static void update_vmcoreinfo_note(void) · line 1429

Quoted 7 lines
kernel/kexec.c +1 -1
@@ -1424,7 +1424,7 @@ static void update_vmcoreinfo_note(void)
 
 void crash_save_vmcoreinfo(void)
 {
-	vmcoreinfo_append_str("CRASHTIME=%ld", get_seconds());
+	vmcoreinfo_append_str("CRASHTIME=%ld\n", get_seconds());
 	update_vmcoreinfo_note();
 }

huh, that was a screwup. And now we have to make what must be viewed as a non-back-compatible ABI change.

Quoted 2 lines

Ho hum, presumably there isn't a lot of code out there which is dependent upon a non-newline-terminated CRASHTIME record.

I think so. AFAIK, makedumpfile (vmcore filtering utility) is only user of CRASHTIME=.

Quoted 3 lines

Why did this work at all, anyway? Is CRASHTIME always the last-emitted record?

Yes, CRASHTIME= is always the last emitted line in vmcoreinfo note.

Quoted 7 lines

I had a quick look at makedumpfile code and looks like they read the whole note, dump it to a file and then do fgets() on the file in a loop. As it is last line in the file, fgets encounters EOF and reads the CRASHTIME= line successfully. So even after this change makedumpfile should remain unaffected.

CCing makedumpfile maintainer, Atsushi Kumagai.

As you said, makedumpfile reads VMCOREINFO line by line with fgets(). So, it's OK that the end of the last line is whether \n or EOF.

Therefore, this change doesn't affect makedumpfile.

Thanks
Atsushi Kumagai