Skip to contentSkip to conversation

/proc/cmdline broken since 2.4.19

PATCH New Dick Streefland 1 participant 1 message Jan 20, 2003 Proc filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 /proc/cmdline broken since 2.4.19

Reading /proc/cmdline one character at a time produces garbage since kernel version 2.4.19:

$ cat /proc/cmdline
auto BOOT_IMAGE=2.4.20-x78 ro root=302 nomodules
$ dd bs=1 if=/proc/cmdline | od -x
49+0 records in
49+0 records out
0000000 0200 5555 0006 0000 622d 7361 0068 5555
0000020 5555 cfcf cfcf cfcf 5555 5555 0000 0000
0000040 02f7 5555 000b 0000 6c6e 4e5f 404c 7565
0000060 0072
0000061

The following patch fixes this:

fs/proc/proc_misc.c renamed from fs/proc/proc_misc.c.orig +2 -2
@@ -422,9 +422,9 @@
 				 int count, int *eof, void *data)
 {
 	extern char saved_command_line[];
-	int len;
+	int len = 0;
 
-	len = snprintf(page, count, "%s\n", saved_command_line);
+	proc_sprintf(page, &off, &len, "%s\n", saved_command_line);
 	return proc_calc_metrics(page, start, off, count, eof, len);
 }
 
Signature · 3 lines
Dick Streefland                      ////                      Altium BV
[email protected]           (@ @)          http://www.altium.com
--------------------------------oOO--(_)--OOo---------------------------