--- zzzz-none-000/linux-2.6.19.2/kernel/printk.c 2007-01-10 19:10:37.000000000 +0000 +++ davinci-8020-5505/linux-2.6.19.2/kernel/printk.c 2007-11-28 13:59:59.000000000 +0000 @@ -31,12 +31,22 @@ #include #include #include -#include +#include #include #define __LOG_BUF_LEN (1 << CONFIG_LOG_BUF_SHIFT) +#ifdef CONFIG_TFFS_PANIC_LOG +#if __LOG_BUF_LEN != 0x8000 +#warning CONFIG_LOG_BUF_SHIFT should be 15 +#endif +#endif /*--- #ifdef CONFIG_TFFS_PANIC_LOG ---*/ + +#ifdef CONFIG_DEBUG_LL +extern void printascii(char *); +#endif + /* printk's without a loglevel use this.. */ #define DEFAULT_MESSAGE_LOGLEVEL 4 /* KERN_WARNING */ @@ -124,6 +134,17 @@ static int log_buf_len = __LOG_BUF_LEN; static unsigned long logged_chars; /* Number of chars produced since last read+clear operation */ +#ifdef CONFIG_TFFS_PANIC_LOG +unsigned long printk_get_buffer(char **p_log_buf, unsigned long *p_log_end, unsigned long *p_anzahl) { + *p_log_buf = log_buf; + *p_log_end = log_end & LOG_BUF_MASK; + *p_anzahl = log_end; + /*--- printk("[printk_get_buffer] log_buf 0x%p len %d write_pos %ld anzahl %ld\n", log_buf, log_buf_len, log_end & LOG_BUF_MASK, log_end); ---*/ + return log_buf_len; +} +#endif /*--- #ifdef CONFIG_TFFS_PANIC_LOG ---*/ + + static int __init log_buf_len_setup(char *str) { unsigned long size = memparse(str, &str); @@ -187,6 +208,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 +461,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 +489,8 @@ __setup("time", printk_time_setup); +#endif + __attribute__((weak)) unsigned long long printk_clock(void) { return sched_clock(); @@ -489,6 +528,7 @@ * printf(3) */ +#undef printk asmlinkage int printk(const char *fmt, ...) { va_list args; @@ -500,6 +540,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 +587,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 +981,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 +1071,7 @@ { struct console *a, *b; int res = 1; + acquire_console_sem(); if (console_drivers == console) { @@ -1102,23 +1170,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);