PATCH: fix for serial console in 2.1.85

Miquel van Smoorenburg (miquels@cistron.nl)
9 Feb 1998 20:26:30 +0100


Somewehere in 2.1.7x or 2.1.8x the call to console_init() was moved up
a bit, before the call to parse_options(). And as console_init() actually
uses command line options, they didn't work anymore.

The following is a one line patch to init/main.c that fixes that, and
a slightly bigger patch against kernel/printk.c to prevent people from
specifying the same console device twice (which would cause double
output - very funny but not intended).

--- linux-2.1.85.orig/init/main.c Sat Feb 7 17:35:55 1998
+++ linux-2.1.85/init/main.c Sat Feb 7 17:25:06 1998
@@ -1002,10 +1002,10 @@
memory_start = paging_init(memory_start,memory_end);
trap_init();
init_IRQ();
- memory_start = console_init(memory_start,memory_end);
sched_init();
time_init();
parse_options(command_line);
+ memory_start = console_init(memory_start,memory_end);
#ifdef CONFIG_MODULES
init_modules();
#endif
--- linux-2.1.85.orig/kernel/printk.c Sat Jan 24 01:53:00 1998
+++ linux-2.1.85/kernel/printk.c Sat Feb 7 19:12:05 1998
@@ -61,36 +61,49 @@
*/
__initfunc(void console_setup(char *str, int *ints))
{
- char *s;
- int i;
struct console_cmdline *c;
+ char name[sizeof(c->name)];
+ char *s, *options;
+ int i, idx;

- for(i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0]; i++)
- ;
- if (i == MAX_CMDLINECONSOLES)
- return;
- c = &console_cmdline[i];
- selected_console = 1;
-
+ /*
+ * Decode str into name, index, options.
+ */
if (str[0] >= '0' && str[0] <= '9') {
- strcpy(c->name, "ttyS");
- strncpy(c->name + 4, str, sizeof(c->name) - 5);
+ strcpy(name, "ttyS");
+ strncpy(name + 4, str, sizeof(name) - 5);
} else
- strncpy(c->name, str, sizeof(c->name) - 1);
- if ((c->options = strchr(str, ',')) != NULL)
- *(c->options++) = 0;
+ strncpy(name, str, sizeof(name) - 1);
+ name[sizeof(name) - 1] = 0;
+ if ((options = strchr(str, ',')) != NULL)
+ *(options++) = 0;
#ifdef __sparc__
if (!strcmp(str, "ttya"))
- strcpy(c->name, "ttyS0");
+ strcpy(name, "ttyS0");
if (!strcmp(str, "ttyb"))
- strcpy(c->name, "ttyS1");
+ strcpy(name, "ttyS1");
#endif
-
- for(s = c->name; *s; s++)
+ for(s = name; *s; s++)
if (*s >= '0' && *s <= '9')
break;
- c->index = simple_strtoul(s, NULL, 10);
+ idx = simple_strtoul(s, NULL, 10);
*s = 0;
+
+ /*
+ * See if this tty is not yet registered, and
+ * if we have a slot free.
+ */
+ for(i = 0; i < MAX_CMDLINECONSOLES && console_cmdline[i].name[0]; i++)
+ if (strcmp(console_cmdline[i].name, name) == 0 &&
+ console_cmdline[i].index == idx)
+ return;
+ if (i == MAX_CMDLINECONSOLES)
+ return;
+ selected_console = 1;
+ c = &console_cmdline[i];
+ memcpy(c->name, name, sizeof(c->name));
+ c->options = options;
+ c->index = idx;
}


-- 
 Miquel van Smoorenburg |  The dyslexic, agnostic, insomniac lay in his bed
    miquels@cistron.nl  |  awake all night wondering if there is a doG
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu