linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] optional hardcoded kernel command line i386, x86_64 linux-2.4.20
@ 2003-03-04 11:58 Corvus Corax
  2003-03-05  1:13 ` Corvus Corax
  0 siblings, 1 reply; 3+ messages in thread
From: Corvus Corax @ 2003-03-04 11:58 UTC (permalink / raw)
  To: linux-kernel

2003.03.04 -- cmdline-linux-2.4.20.patch
This patch provides an optional hardcoded kernel command line
along with with specifyable override behaviour
against the command line provided by the bootloader (if any)
written for arch/i386 and arch/x86_64 in linux-2.4.20
by Eric Noack (Corvus V Corax) <corvusvcorax@gemia.de>

I have seen this feature as a patch for >= 2.5.x , but missed it for
linux 2.4.x, so i just wrote it, maybe there is already one,
which I missed, so just take the better ;-)
I guess it might be useful for floppy boot, but it needs testing
at least on the x86_64 architecture, i dont have one of these yet


patch is at

http://gemia.de/test/cmdline-patch.tgz
			\ README
			\ cmdline-linux-2.4.20.patch

please tell me if there are any problems with it, would you? ;)
have fun ...
 
Corvus Corax
(aka Eric Noack)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] optional hardcoded kernel command line i386, x86_64 linux-2.4.20
  2003-03-04 11:58 [PATCH] optional hardcoded kernel command line i386, x86_64 linux-2.4.20 Corvus Corax
@ 2003-03-05  1:13 ` Corvus Corax
  2003-03-05 11:16   ` [PATCH] (update) optional hardcoded cmdline " Corvus Corax
  0 siblings, 1 reply; 3+ messages in thread
From: Corvus Corax @ 2003-03-05  1:13 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 507 bytes --]

> 2003.03.04 -- cmdline-linux-2.4.20.patch
> This patch provides an optional hardcoded kernel command line
> along with with specifyable override behaviour
> against the command line provided by the bootloader (if any)
> written for arch/i386 and arch/x86_64 in linux-2.4.20
> by Eric Noack (Corvus V Corax) <corvusvcorax@gemia.de>
> 

if this format pleases you more

 attached: i386+x86_64-cmdline-linux-2.4.20.patch.tgz
 			\ README
 			\ cmdline-linux-2.4.20.patch
>  
> Corvus Corax
> (aka Eric Noack)

[-- Attachment #2: i386+x86_64-cmdline-linux-2.4.20.patch.tgz --]
[-- Type: application/x-gzip, Size: 1717 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] (update) optional hardcoded cmdline i386, x86_64 linux-2.4.20
  2003-03-05  1:13 ` Corvus Corax
@ 2003-03-05 11:16   ` Corvus Corax
  0 siblings, 0 replies; 3+ messages in thread
From: Corvus Corax @ 2003-03-05 11:16 UTC (permalink / raw)
  To: linux-kernel

Am Wed, 5 Mar 2003 02:13:34 +0100
schrieb Corvus Corax <corvusvcorax@gemia.de>:

> 2003.03.04 -- cmdline-linux-2.4.20.patch
> This patch provides an optional hardcoded kernel command line
> along with with specifyable override behaviour
> against the command line provided by the bootloader (if any)
> written for arch/i386 and arch/x86_64 in linux-2.4.20
> by Eric Noack (Corvus V Corax) <corvusvcorax@gemia.de>
> 
 
this patch should now fullfill the requirements of both
code-style and patch-committing-style, does it?

>  
> Corvus Corax
> (aka Eric Noack)                              _ __ ____ _____ _______ ________ ____
                                            .*°` `  `    `     `       `        `
  i386+x86_64-cmdline-linux-2.4.20.patch   /    2nd try
_,____,____,____,___,__,_,_,_,_,_,_,_,,,.*°


diff -ru linux-2.4.20.old/arch/i386/config.in linux/arch/i386/config.in
--- linux-2.4.20.old/arch/i386/config.in	2003-03-04 10:58:05.000000000 +0100
+++ linux/arch/i386/config.in	2003-03-04 11:19:27.000000000 +0100
@@ -316,6 +316,12 @@
    bool '    Use real mode APM BIOS call to power off' CONFIG_APM_REAL_MODE_POWER_OFF
 fi
 
+bool 'Hardcoded kernel command line' CONFIG_CMDLINE_ENABLE
+if [ "$CONFIG_CMDLINE_ENABLE" = "y" ]; then
+    bool '    Bootloader overrides hardcoded' CONFIG_CMDLINE_OVERRIDE
+    string '   Initial kernel command line' CONFIG_CMDLINE "root=301 ro"
+fi
+
 endmenu
 
 source drivers/mtd/Config.in
diff -ru linux-2.4.20.old/arch/i386/kernel/setup.c linux/arch/i386/kernel/setup.c
--- linux-2.4.20.old/arch/i386/kernel/setup.c	2003-03-04 10:59:15.000000000 +0100
+++ linux/arch/i386/kernel/setup.c	2003-03-05 11:44:22.000000000 +0100
@@ -325,6 +325,18 @@
 	}
 #endif
 
+#ifdef CONFIG_CMDLINE_ENABLE
+	#ifdef CONFIG_CMDLINE_OVERRIDE
+	static inline char *choose_valid_command_line()
+	{
+		if (*COMMAND_LINE) return COMMAND_LINE; else return CONFIG_CMDLINE;
+	}
+	#else
+	static inline char *choose_valid_command_line() {return CONFIG_CMDLINE;}
+	#endif
+#else
+static inline char *choose_valid_command_line() {return COMMAND_LINE;}
+#endif
 
 static char command_line[COMMAND_LINE_SIZE];
        char saved_command_line[COMMAND_LINE_SIZE];
@@ -733,12 +745,14 @@
 
 static void __init parse_cmdline_early (char ** cmdline_p)
 {
-	char c = ' ', *to = command_line, *from = COMMAND_LINE;
+	char c = ' ', *to = command_line, *from;
 	int len = 0;
 	int userdef = 0;
 
+	from=choose_valid_command_line();
+
 	/* Save unparsed command line copy for /proc/cmdline */
-	memcpy(saved_command_line, COMMAND_LINE, COMMAND_LINE_SIZE);
+	memcpy(saved_command_line, from, COMMAND_LINE_SIZE);
 	saved_command_line[COMMAND_LINE_SIZE-1] = '\0';
 
 	for (;;) {
diff -ru linux-2.4.20.old/arch/x86_64/config.in linux/arch/x86_64/config.in
--- linux-2.4.20.old/arch/x86_64/config.in	2003-03-04 10:58:15.000000000 +0100
+++ linux/arch/x86_64/config.in	2003-03-04 11:21:01.000000000 +0100
@@ -118,6 +118,12 @@
    fi
 fi
 
+bool 'Hardcoded kernel command line' CONFIG_CMDLINE_ENABLE
+if [ "$CONFIG_CMDLINE_ENABLE" = "y" ]; then
+    bool '    Bootloader overrides hardcoded' CONFIG_CMDLINE_OVERRIDE
+    string '   Initial kernel command line' CONFIG_CMDLINE "root=301 ro"
+fi
+
 endmenu
 
 source drivers/mtd/Config.in
diff -ru linux-2.4.20.old/arch/x86_64/kernel/e820.c linux/arch/x86_64/kernel/e820.c
--- linux-2.4.20.old/arch/x86_64/kernel/e820.c	2003-03-04 10:58:44.000000000 +0100
+++ linux/arch/x86_64/kernel/e820.c	2003-03-05 10:38:21.000000000 +0100
@@ -473,18 +473,33 @@
 	e820_print_map(who);
 }
 
+#ifdef CONFIG_CMDLINE_ENABLE
+	#ifdef CONFIG_CMDLINE_OVERRIDE
+	static inline char *choose_valid_command_line()
+	{
+		if (*COMMAND_LINE) return COMMAND_LINE; else return CONFIG_CMDLINE; 
+	}
+	#else
+	static inline char *choose_valid_command_line() {return CONFIG_CMDLINE;}
+	#endif
+#else
+static inline char *choose_valid_command_line() {return COMMAND_LINE;}
+#endif
+
 extern char command_line[], saved_command_line[];
 extern int fallback_aper_order;
 extern int iommu_setup(char *opt);
 
 void __init parse_mem_cmdline (char ** cmdline_p)
 {
-	char c = ' ', *to = command_line, *from = COMMAND_LINE;
+	char c = ' ', *to = command_line, *from;
 	int len = 0;
 	int usermem = 0;
 
+	from=choose_valid_command_line();
+
 	/* Save unparsed command line copy for /proc/cmdline */
-	memcpy(saved_command_line, COMMAND_LINE, COMMAND_LINE_SIZE);
+	memcpy(saved_command_line, from, COMMAND_LINE_SIZE);
 	saved_command_line[COMMAND_LINE_SIZE-1] = '\0';
 
 	for (;;) {
diff -ru linux-2.4.20.old/Documentation/Configure.help linux/Documentation/Configure.help
--- linux-2.4.20.old/Documentation/Configure.help	2003-03-04 10:55:32.000000000 +0100
+++ linux/Documentation/Configure.help	2003-03-05 10:46:56.000000000 +0100
@@ -24033,6 +24033,24 @@
   You can also say M here to compile this support as a module (which
   will be called arthur.o).
 
+Hardcoded kernel command line
+CONFIG_CMDLINE_ENABLE
+  When you create a kernel for booting directly from a floppy, or you
+  don't trust the command line provided by the bootloader for security
+  reasons, you can add support for a hardcoded command line by saying Y.
+  Most times you won't need this, say N.
+
+Bootloader overrides hardcoded
+CONFIG_CMDLINE_OVERRIDE
+  If you specify a hardcoded kernel command line, but you want to use
+  the same kernel with your favorite bootmanager (p.e. LILO),
+  the bootloader can set its own command line, this way overriding
+  the internal hardcoded one, if set to Y,
+  If you set this to N the bootloaders command line will just
+  be ignored and the hardcoded command line will be used instead.
+  This might be important doe to security reasons.
+  Most times it's better to say Y.
+
 Initial kernel command line
 CONFIG_CMDLINE
   On some architectures (EBSA110 and CATS), there is currently no way
@@ -24040,6 +24058,8 @@
   architectures, you should supply some command-line options at build
   time by entering them here. As a minimum, you should specify the
   memory size and the root device (e.g., mem=64M root=/dev/nfs).
+  This item has been added to i386 and x64_64,
+  as an optional feature, too.
 
 Kernel-mode alignment trap handler
 CONFIG_ALIGNMENT_TRAP

===END=OF=FILE=================================================================

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-03-05 11:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-04 11:58 [PATCH] optional hardcoded kernel command line i386, x86_64 linux-2.4.20 Corvus Corax
2003-03-05  1:13 ` Corvus Corax
2003-03-05 11:16   ` [PATCH] (update) optional hardcoded cmdline " Corvus Corax

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).