--- zzzz-none-000/linux-2.6.19.2/kernel/printk.c 2007-01-10 19:10:37.000000000 +0000 +++ davinci-8020-5504/linux-2.6.19.2/kernel/printk.c 2007-05-08 15:50:11.000000000 +0000 @@ -31,12 +31,16 @@ #include #include #include -#include +#include #include #define __LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT) +#ifdef CONFIG_DEBUG_LL +extern void printascii(char *); +#endif + /* printk's without a loglevel use this.. */ #define DEFAULT_MESSAGE_LOGLEVEL 4 /* KERN_WARNING */ @@ -187,6 +191,11 @@ char c; int error = 0; +#ifdef CONFIG_GRKERNSEC_DMESG + if (grsec_enable_dmesg && !capable(CAP_SYS_ADMIN)) + return -EPERM; +#endif + error = security_syslog(type); if (error) return error; @@ -435,12 +444,23 @@ init_MUTEX(&console_sem); } -#if defined(CONFIG_PRINTK_TIME) -static int printk_time = 1; -#else static int printk_time = 0; -#endif -module_param(printk_time, int, S_IRUGO | S_IWUSR); + +#ifdef CONFIG_PRINTK_TIME + +/* + * Initialize printk time. Note that on some systems sched_clock() + * does not work until timer is initialized. + */ +static int __init printk_time_init(void) +{ + printk_time = 1; + + return 0; +} +subsys_initcall(printk_time_init); + +#else static int __init printk_time_setup(char *str) { @@ -452,6 +472,8 @@ __setup("time", printk_time_setup); +#endif + __attribute__((weak)) unsigned long long printk_clock(void) { return sched_clock(); @@ -489,6 +511,7 @@ * printf(3) */ +#undef printk asmlinkage int printk(const char *fmt, ...) { va_list args; @@ -500,6 +523,26 @@ return r; } +asmlinkage int (*__printk)(const char * fmt, ...) __attribute__ ((format (printf, 1, 2))) = printk; +asmlinkage int (*_printk)(const char * fmt, ...) __attribute__ ((format (printf, 1, 2))) = printk; + +EXPORT_SYMBOL(__printk); /* zeigt immer auf printk */ +EXPORT_SYMBOL(_printk); /* wird umgesetzt */ + +/*--------------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------------*/ +void set_printk(int (*__print)(const char * fmt, ...) __attribute__ ((format (printf, 1, 2)))) { + _printk = __print; +} +EXPORT_SYMBOL(set_printk); + +/*--------------------------------------------------------------------------------*\ +\*--------------------------------------------------------------------------------*/ +void restore_printk(void) { + _printk = printk; +} +EXPORT_SYMBOL(restore_printk); + /* cpu currently holding logbuf_lock */ static volatile unsigned int printk_cpu = UINT_MAX; @@ -527,6 +570,10 @@ /* Emit the output into the temporary buffer */ printed_len = vscnprintf(printk_buf, sizeof(printk_buf), fmt, args); +#ifdef CONFIG_DEBUG_LL + printascii(printk_buf); +#endif + /* * Copy the output into log_buf. If the caller didn't provide * appropriate log level tags, we insert them here @@ -917,11 +964,14 @@ * print any messages that were printed by the kernel before the * console driver was initialized. */ +static unsigned int count = 0; + void register_console(struct console *console) { int i; unsigned long flags; + if (preferred_console < 0) preferred_console = selected_console; @@ -1004,6 +1054,7 @@ { struct console *a, *b; int res = 1; + acquire_console_sem(); if (console_drivers == console) { @@ -1102,23 +1153,3 @@ printk_ratelimit_burst); } EXPORT_SYMBOL(printk_ratelimit); - -/** - * printk_timed_ratelimit - caller-controlled printk ratelimiting - * @caller_jiffies: pointer to caller's state - * @interval_msecs: minimum interval between prints - * - * printk_timed_ratelimit() returns true if more than @interval_msecs - * milliseconds have elapsed since the last time printk_timed_ratelimit() - * returned true. - */ -bool printk_timed_ratelimit(unsigned long *caller_jiffies, - unsigned int interval_msecs) -{ - if (*caller_jiffies == 0 || time_after(jiffies, *caller_jiffies)) { - *caller_jiffies = jiffies + msecs_to_jiffies(interval_msecs); - return true; - } - return false; -} -EXPORT_SYMBOL(printk_timed_ratelimit);