lkml.org 
[lkml]   [1996]   [Mar]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
SubjectPATCH: printk/syslog customizations
Date
The patch below creates three config options that make it quite easy
to tweak the way printk() and kernel logging behave at compile time.

Anyone experiencing more console messages than they would like
should find this quite useful. Simple work, I guess.

Comments greatly appreciated.

.-.
. |-
-- -- | |
\_/


--- linux/arch/i386/config.in.old Thu Mar 28 21:07:51 1996
+++ linux/arch/i386/config.in Thu Mar 28 21:06:29 1996
@@ -102,4 +102,10 @@
if [ "$CONFIG_PROFILE" = "y" ]; then
int ' Profile shift count' CONFIG_PROFILE_SHIFT 2
fi
+bool 'Tweak printk logging options' CONFIG_TWEAK_PRINTK
+if [ "$CONFIG_TWEAK_PRINTK" = "y" ]; then
+ int ' Minimum suppressable console log level' CONFIG_PRINTK_MINIMUM 4
+ int ' Default log level for printk()' CONFIG_PRINTK_DEFAULT 2
+ int ' Size of kernel message buffer' CONFIG_PRINTK_BUFSIZE 8192
+fi
endmenu
--- linux/kernel/printk.c.old Thu Mar 28 21:10:26 1996
+++ linux/kernel/printk.c Thu Mar 28 20:57:05 1996
@@ -9,6 +9,11 @@
* to the console. Added hook for sending the console messages
* elsewhere, in preparation for a serial line console (someday).
* Ted Ts'o, 2/11/93.
+ *
+ *
+ * Modified to allow configurable logging and larger buffers,
+ * Joe Fouche [jf@ugcs.caltech.edu], 3/29/96.
+ *
*/

#include <stdarg.h>
@@ -23,17 +28,26 @@
#include <linux/tty.h>
#include <linux/tty_driver.h>

-#define LOG_BUF_LEN 8192
+#include <linux/autoconf.h>
+
+#ifndef CONFIG_PRINTK_BUFSIZE
+#define CONFIG_PRINTK_BUFSIZE 8192
+#endif

static char buf[1024];

extern void console_print(const char *);

/* printk's without a loglevel use this.. */
-#define DEFAULT_MESSAGE_LOGLEVEL 4 /* KERN_WARNING */
+#ifndef CONFIG_PRINTK_DEFAULT
+#define CONFIG_PRINTK_DEFAULT 4 /* KERN_WARNING */
+#endif

/* We show everything that is MORE important than this.. */
-#define MINIMUM_CONSOLE_LOGLEVEL 5 /* Minimum loglevel we let people use */
+#ifndef CONFIG_PRINTK_MINIMUM
+#define CONFIG_PRINTK_MINIMUM 2 /* Minimum loglevel we let people use */
+#endif
+
#define DEFAULT_CONSOLE_LOGLEVEL 7 /* anything MORE serious than KERN_DEBUG */

unsigned long log_size = 0;
@@ -41,7 +55,7 @@
int console_loglevel = DEFAULT_CONSOLE_LOGLEVEL;

static void (*console_print_proc)(const char *) = 0;
-static char log_buf[LOG_BUF_LEN];
+static char log_buf[CONFIG_PRINTK_BUFSIZE];
static unsigned long log_start = 0;
static unsigned long logged_chars = 0;

@@ -93,7 +107,7 @@
c = *((char *) log_buf+log_start);
log_start++;
log_size--;
- log_start &= LOG_BUF_LEN-1;
+ log_start &= CONFIG_PRINTK_BUFSIZE-1;
sti();
put_user(c,buf);
buf++;
@@ -114,13 +128,13 @@
if (error)
return error;
count = len;
- if (count > LOG_BUF_LEN)
- count = LOG_BUF_LEN;
+ if (count > CONFIG_PRINTK_BUFSIZE)
+ count = CONFIG_PRINTK_BUFSIZE;
if (count > logged_chars)
count = logged_chars;
j = log_start + log_size - count;
for (i = 0; i < count; i++) {
- c = *((char *) log_buf+(j++ & (LOG_BUF_LEN-1)));
+ c = *((char *) log_buf+(j++ & (CONFIG_PRINTK_BUFSIZE-1)));
put_user(c, buf++);
}
if (do_clear)
@@ -130,7 +144,7 @@
logged_chars = 0;
return 0;
case 6: /* Disable logging to console */
- console_loglevel = MINIMUM_CONSOLE_LOGLEVEL;
+ console_loglevel = CONFIG_PRINTK_MINIMUM;
return 0;
case 7: /* Enable logging to console */
console_loglevel = DEFAULT_CONSOLE_LOGLEVEL;
@@ -138,8 +152,8 @@
case 8:
if (len < 1 || len > 8)
return -EINVAL;
- if (len < MINIMUM_CONSOLE_LOGLEVEL)
- len = MINIMUM_CONSOLE_LOGLEVEL;
+ if (len < CONFIG_PRINTK_MINIMUM)
+ len = CONFIG_PRINTK_MINIMUM;
console_loglevel = len;
return 0;
}
@@ -172,19 +186,19 @@
) {
p -= 3;
p[0] = '<';
- p[1] = DEFAULT_MESSAGE_LOGLEVEL + '0';
+ p[1] = CONFIG_PRINTK_DEFAULT + '0';
p[2] = '>';
} else
msg += 3;
msg_level = p[1] - '0';
}
for (; p < buf_end; p++) {
- log_buf[(log_start+log_size) & (LOG_BUF_LEN-1)] = *p;
- if (log_size < LOG_BUF_LEN)
+ log_buf[(log_start+log_size) & (CONFIG_PRINTK_BUFSIZE-1)] = *p;
+ if (log_size < CONFIG_PRINTK_BUFSIZE)
log_size++;
else {
log_start++;
- log_start &= LOG_BUF_LEN-1;
+ log_start &= CONFIG_PRINTK_BUFSIZE-1;
}
logged_chars++;
if (*p == '\n')
@@ -222,7 +236,7 @@

for (i=0,j=0; i < log_size; i++) {
buf[j++] = log_buf[p];
- p++; p &= LOG_BUF_LEN-1;
+ p++; p &= CONFIG_PRINTK_BUFSIZE-1;
if (buf[j-1] != '\n' && i < log_size - 1 && j < sizeof(buf)-1)
continue;
buf[j] = 0;
--- linux/Documentation/Configure.help.old Thu Mar 28 21:14:12 1996
+++ linux/Documentation/Configure.help Thu Mar 28 21:04:56 1996
@@ -2989,6 +2989,31 @@
enabled "Kernel profiling support", you must be a kernel hacker and
hence you know what this is about :-)

+Tweak printk options
+CONFIG_TWEAK_PRINTK
+ This lets the user take control of the way the kernel logs to
+ the console. Say N to get sensible defaults.
+
+CONFIG_PRINTK_MINIMUM
+ This specifies the syslog priority (smaller numbers equal higher
+ priority) for kernel messages that can be redirected from the
+ console. Setting this lower than the default allows more serious
+ messages to be redirected with the sys_syslog system call.
+ (usually this call is made by klogd).
+
+CONFIG_PRINTK_DEFAULT
+ This level is the default for calls to printk(). If the call
+ doesn't specify its own loglevel, the printk is made at
+ this syslog level.
+
+CONFIG_PRINTK_BUFSIZE
+ This changes the size of the internal kernel buffer that holds
+ all printk's. Change this to save memory or to allow more extensive
+ kernel debugging.
+
+
+
+
ISDN subsystem
CONFIG_ISDN
This allows you to use an ISDN-card for networking connections and


\
 
 \ /
  Last update: 2005-03-22 13:36    [W:0.079 / U:0.220 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site