.\" Copyright (C) 1995 Andries Brouwer (aeb@cwi.nl)
.\"
+.\" %%%LICENSE_START(VERBATIM)
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
+.\" %%%LICENSE_END
.\"
.\" Written 11 June 1995 by Andries Brouwer <aeb@cwi.nl>
.\" 2008-02-15, Jeremy Kerr <jk@ozlabs.org>
.\" 2008-02-15, Michael Kerrisk <mtk.manpages@gmail.com>
.\" Update LOG_BUF_LEN details; update RETURN VALUE section.
.\"
-.TH SYSLOG 2 2011-09-07 "Linux" "Linux Programmer's Manual"
+.TH SYSLOG 2 2012-11-29 "Linux" "Linux Programmer's Manual"
.SH NAME
syslog, klogctl \- read and/or clear kernel message ring buffer;
set console_loglevel
.IR printk ()
buffer, and the glibc wrapper function is called
.BR klogctl ().
-
-The \fItype\fP argument determines the action taken by this function,
-as follows:
-
-.nf
- 0 \-\- Close the log. Currently a NOP.
- 1 \-\- Open the log. Currently a NOP.
- 2 \-\- Read from the log.
- 3 \-\- Read all messages remaining in the ring buffer.
- 4 \-\- Read and clear all messages remaining in the ring buffer
- 5 \-\- Clear ring buffer.
- 6 \-\- Disable printk to console
- 7 \-\- Enable printk to console
- 8 \-\- Set level of messages printed to console
- 9 \-\- Return number of unread characters in the log buffer
- 10 \-\- Return size of the log buffer
-.fi
-
-Type 9 was added in Linux 2.4.10; type 10 in Linux 2.6.6.
-
-In Linux kernels before 2.6.37,
-only command types 3 and 10 are allowed to unprivileged processes.
-Since Linux 2.6.37,
-command types 3 and 10 are only allowed to unprivileged processes if
-.IR /proc/sys/kernel/dmesg_restrict
-has the value 0.
-Before Linux 2.6.37, "privileged" means that the caller has the
-.BR CAP_SYS_ADMIN
-capability.
-Since Linux 2.6.37,
-"privileged" means that the caller has either the
-.BR CAP_SYS_ADMIN
-capability (now deprecated for this purpose) or the (new)
-.BR CAP_SYSLOG
-capability.
.SS The kernel log buffer
The kernel has a cyclic buffer of length
.B LOG_BUF_LEN
had the value 4096;
from kernel 1.3.54, it was 8192;
from kernel 2.1.113 it was 16384;
-since 2.4.23/2.6 the value is a kernel configuration option.
+since 2.4.23/2.6 the value is a kernel configuration option
+.RB ( CONFIG_LOG_BUF_SHIFT ).
.\" Under "General setup" ==> "Kernel log buffer size"
.\" For 2.6, precisely the option seems to have appeared in 2.5.55.
-In recent kernels the size can be queried with command type 10.
-
+In recent kernels the size can be queried with command type 10 (see below).
+.SS Commands
+The \fItype\fP argument determines the action taken by this function.
+The list below specifies the values for
+.IR type .
+The symbolic names are defined in the kernel source,
+but are not exported to user space;
+you will either need to use the numbers, or define the names yourself.
+.TP
+.BR SYSLOG_ACTION_CLOSE " (0)"
+Close the log.
+Currently a NOP.
+.TP
+.BR SYSLOG_ACTION_OPEN " (1)"
+Open the log.
+Currently a NOP.
+.TP
+.BR SYSLOG_ACTION_READ " (2)"
+Read from the log.
The call
-.I "syslog(2,buf,len)"
-waits until this kernel log buffer is nonempty, and then reads
-at most \fIlen\fP bytes into the buffer \fIbuf\fP.
-It returns
-the number of bytes read.
-Bytes read from the log disappear from
-the log buffer: the information can only be read once.
-This is the function executed by the kernel when a user program
-reads
+waits until the kernel log buffer is nonempty, and then reads
+at most \fIlen\fP bytes into the buffer pointed to by
+.IR bufp .
+The call returns the number of bytes read.
+Bytes read from the log disappear from the log buffer:
+the information can be read only once.
+This is the function executed by the kernel when a user program reads
.IR /proc/kmsg .
-
-The call
-.I syslog(3,buf,len)
-will read the last \fIlen\fP bytes from the log buffer (nondestructively),
+.TP
+.BR SYSLOG_ACTION_READ_ALL " (3)"
+Read all messages remaining in the ring buffer,
+placing then in the buffer pointed to by
+.IR bufp .
+The call reads the last \fIlen\fP
+bytes from the log buffer (nondestructively),
but will not read more than was written into the buffer since the
-last "clear ring buffer" command (which does not clear the buffer at all).
-It returns the number of bytes read.
-
-The call
-.I syslog(4,buf,len)
-does precisely the same, but also executes the "clear ring buffer" command.
-
-The call
-.I syslog(5,dummy,dummy)
-executes just the "clear ring buffer" command.
-(In each call where
-.I buf
-or
+last "clear ring buffer" command (see command 5 below)).
+The call returns the number of bytes read.
+.TP
+.BR SYSLOG_ACTION_READ_CLEAR " (4)"
+Read and clear all messages remaining in the ring buffer.
+The call does precisely the same as for a
+.I type
+of 3, but also executes the "clear ring buffer" command.
+.TP
+.BR SYSLOG_ACTION_CLEAR " (5)"
+The call executes just the "clear ring buffer" command.
+The
+.I bufp
+and
.I len
-is shown as "dummy", the value of the argument is ignored by the call.)
-
-The call
-.I syslog(6,dummy,dummy)
-sets the console log level to minimum, so that no messages are printed
-to the console.
-
-The call
-.I syslog(7,dummy,dummy)
-sets the console log level to default, so that messages are printed
-to the console.
-
-The call
-.I syslog(8,dummy,level)
-sets the console log level to
-.IR level ,
+arguments are ignored.
+.IP
+This command does not really clear the ring buffer.
+Rather, it sets a kernel bookkeeping variable that
+determines the results returned by commands 3
+.RB ( SYSLOG_ACTION_READ_ALL )
+and 4
+.RB ( SYSLOG_ACTION_READ_CLEAR ).
+This command has no effect on commands 2
+.RB ( SYSLOG_ACTION_READ )
+and 9
+.RB ( SYSLOG_ACTION_SIZE_UNREAD ).
+.TP
+.BR SYSLOG_ACTION_CONSOLE_OFF " (6)"
+Disable printk to console.
+The call sets the console log level to the minimum,
+so that no messages are printed to the console.
+The
+.I bufp
+and
+.I len
+arguments are ignored.
+.TP
+.BR SYSLOG_ACTION_CONSOLE_ON " (7)"
+The call sets the console log level to the default,
+so that messages are printed to the console.
+The
+.I bufp
+and
+.I len
+arguments are ignored.
+.TP
+.BR SYSLOG_ACTION_CONSOLE_LEVEL " (8)"
+The call sets the console log level to the value given in
+.IR len ,
which must be an integer between 1 and 8 (inclusive).
See the
.B loglevel
section for details.
-
+The
+.I bufp
+argument is ignored.
+.TP
+.BR SYSLOG_ACTION_SIZE_UNREAD " (9) (since Linux 2.4.10)"
The call
-.I syslog(9,dummy,dummy)
returns the number of bytes currently available to be read
-on the kernel log buffer.
-
-The call
-.I syslog(10,dummy,dummy)
-returns the total size of the kernel log buffer.
+from the kernel log buffer via command 2
+.RB ( SYSLOG_ACTION_READ ).
+The
+.I bufp
+and
+.I len
+arguments are ignored.
+.TP
+.BR SYSLOG_ACTION_SIZE_BUFFER " (10) (since Linux 2.6.6)"
+This command returns the total size of the kernel log buffer.
+The
+.I bufp
+and
+.I len
+arguments are ignored.
+.PP
+All commands except 3 and 10 require privilege.
+In Linux kernels before 2.6.37,
+command types 3 and 10 are allowed to unprivileged processes;
+since Linux 2.6.37,
+these commands are allowed to unprivileged processes only if
+.IR /proc/sys/kernel/dmesg_restrict
+has the value 0.
+Before Linux 2.6.37, "privileged" means that the caller has the
+.BR CAP_SYS_ADMIN
+capability.
+Since Linux 2.6.37,
+"privileged" means that the caller has either the
+.BR CAP_SYS_ADMIN
+capability (now deprecated for this purpose) or the (new)
+.BR CAP_SYSLOG
+capability.
.SS The loglevel
The kernel routine
.BR printk ()
(7), but is set to 10 if the
kernel command line contains the word "debug", and to 15 in case
of a kernel fault (the 10 and 15 are just silly, and equivalent to 8).
-This variable is set (to a value in the range 1-8) by the call
-.IR syslog(8,dummy,value) .
-The calls
-.I syslog(type,dummy,dummy)
-with \fItype\fP equal to 6 or 7, set it to 1 (kernel panics only)
+This variable is set (to a value in the range 1-8) by a
+.BR syslog ()
+call with a
+.I type
+of 8.
+Calls to
+.BR syslog ()
+with
+.I type
+equal to 6 or 7 set the variable to 1 (kernel panics only)
or 7 (all except debugging messages), respectively.
Every text line in a message has its own loglevel.
#define KERN_INFO "<6>" /* informational */
#define KERN_DEBUG "<7>" /* debug-level messages */
.fi
-.SH "RETURN VALUE"
+.SH RETURN VALUE
For \fItype\fP equal to 2, 3, or 4, a successful call to
.BR syslog ()
returns the number
.B ERESTARTSYS
System call was interrupted by a signal; nothing was read.
(This can be seen only during a trace.)
-.SH "CONFORMING TO"
+.SH CONFORMING TO
This system call is Linux-specific and should not be used in programs
intended to be portable.
.SH NOTES
From the very start people noted that it is unfortunate that
a system call and a library routine of the same name are entirely
different animals.
-In libc4 and libc5 the number of this call was defined by
-.BR SYS_klog .
-In glibc 2.0 the syscall is baptized
-.BR klogctl ().
-.SH "SEE ALSO"
+.\" In libc4 and libc5 the number of this call was defined by
+.\" .BR SYS_klog .
+.\" In glibc 2.0 the syscall is baptized
+.\" .BR klogctl ().
+.SH SEE ALSO
.BR syslog (3),
.BR capabilities (7)
+.SH COLOPHON
+This page is part of release 3.68 of the Linux
+.I man-pages
+project.
+A description of the project,
+information about reporting bugs,
+and the latest version of this page,
+can be found at
+\%http://www.kernel.org/doc/man\-pages/.