X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=kernel%2Fprintk.c;h=89011bf8c106615cf3569a3f1f80777afe3e55ef;hb=7607341a265a56cdf8b4bf10d355098e80ea481b;hp=b2b5c3a22a36b302da177fafae653740f7eeeddf;hpb=92d15c2ccbb3e31a3fc71ad28fdb55e1319383c0;p=linux-2.6 diff --git a/kernel/printk.c b/kernel/printk.c index b2b5c3a22a..89011bf8c1 100644 --- a/kernel/printk.c +++ b/kernel/printk.c @@ -219,6 +219,58 @@ static inline void boot_delay_msec(void) } #endif +/* + * Return the number of unread characters in the log buffer. + */ +int log_buf_get_len(void) +{ + return logged_chars; +} + +/* + * Copy a range of characters from the log buffer. + */ +int log_buf_copy(char *dest, int idx, int len) +{ + int ret, max; + bool took_lock = false; + + if (!oops_in_progress) { + spin_lock_irq(&logbuf_lock); + took_lock = true; + } + + max = log_buf_get_len(); + if (idx < 0 || idx >= max) { + ret = -1; + } else { + if (len > max) + len = max; + ret = len; + idx += (log_end - max); + while (len-- > 0) + dest[len] = LOG_BUF(idx + len); + } + + if (took_lock) + spin_unlock_irq(&logbuf_lock); + + return ret; +} + +/* + * Extract a single character from the log buffer. + */ +int log_buf_read(int idx) +{ + char ret; + + if (log_buf_copy(&ret, idx, 1) == 1) + return ret; + else + return -1; +} + /* * Commands to do_syslog: * @@ -765,7 +817,7 @@ __setup("console=", console_setup); * commonly to provide a default console (ie from PROM variables) when * the user has not supplied one. */ -int __init add_preferred_console(char *name, int idx, char *options) +int add_preferred_console(char *name, int idx, char *options) { struct console_cmdline *c; int i; @@ -810,7 +862,16 @@ int update_console_cmdline(char *name, int idx, char *name_new, int idx_new, cha return -1; } -#ifndef CONFIG_DISABLE_CONSOLE_SUSPEND +int console_suspend_enabled = 1; +EXPORT_SYMBOL(console_suspend_enabled); + +static int __init console_suspend_disable(char *str) +{ + console_suspend_enabled = 0; + return 1; +} +__setup("no_console_suspend", console_suspend_disable); + /** * suspend_console - suspend the console subsystem * @@ -818,6 +879,8 @@ int update_console_cmdline(char *name, int idx, char *name_new, int idx_new, cha */ void suspend_console(void) { + if (!console_suspend_enabled) + return; printk("Suspending console(s)\n"); acquire_console_sem(); console_suspended = 1; @@ -825,10 +888,11 @@ void suspend_console(void) void resume_console(void) { + if (!console_suspend_enabled) + return; console_suspended = 0; release_console_sem(); } -#endif /* CONFIG_DISABLE_CONSOLE_SUSPEND */ /** * acquire_console_sem - lock the console system for exclusive use.