OSDN Git Service

75748fc0114d2c34d88a3cc0fc488c4a88afec8f
[linuxjm/LDP_man-pages.git] / draft / man2 / syslog.2
1 .\" Copyright (C) 1995 Andries Brouwer (aeb@cwi.nl)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" Written 11 June 1995 by Andries Brouwer <aeb@cwi.nl>
24 .\" 2008-02-15, Jeremy Kerr <jk@ozlabs.org>
25 .\"     Add info on command type 10; add details on types 6, 7, 8, & 9.
26 .\" 2008-02-15, Michael Kerrisk <mtk.manpages@gmail.com>
27 .\"     Update LOG_BUF_LEN details; update RETURN VALUE section.
28 .\"
29 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
30 .\"         all rights reserved.
31 .\" Translated Mon Dec 16 11:16:34 JST 2001
32 .\"         by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
33 .\" Updated Thu Mar 6 2003 by Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
34 .\" Updated 2005-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
35 .\" Updated 2008-04-04, Akihiro MOTOKI, LDP v2.79
36 .\" Updated 2008-07-31, Akihiro MOTOKI, LDP v3.05
37 .\"
38 .\"WORD:        kernel                  カーネル
39 .\"WORD:        message ring buffer     メッセージ・リング・バッファ
40 .\"WORD:        library                 ライブラリ
41 .\"WORD:        kernel log buffer       カーネル・ログ・バッファ
42 .\"WORD:        console                 コンソール
43 .\"WORD:        kernel panic            カーネル・パニック
44 .\"WORD:        loglevel                ログレベル
45 .\"WORD:        debug message           デバッグ・メッセージ
46 .\"
47 .TH SYSLOG 2  2008-06-20 "Linux" "Linux Programmer's Manual"
48 .\"O .SH NAME
49 .SH 名前
50 .\"O syslog, klogctl \- read and/or clear kernel message ring buffer;
51 .\"O set console_loglevel
52 syslog, klogctl \- カーネルのメッセージ・リング・バッファを読んだり消去したりする;
53 console_loglevel の設定を行う
54 .\"O .SH SYNOPSIS
55 .SH 書式
56 .nf
57 .BI "int syslog(int " type ", char *" bufp ", int " len );
58 .\"O .B  "                /* No wrapper provided in glibc */"
59 .B  "                /* glibc ではラッパー関数は提供されていない */"
60 .sp
61 .\"O /* The glibc interface */
62 /* glibc のインタフェース */
63 .br
64 .B "#include <sys/klog.h>"
65 .sp
66 .BI "int klogctl(int " type ", char *" bufp ", int " len );
67 .fi
68 .\"O .SH DESCRIPTION
69 .SH 説明
70 .\"O If you need the C library function
71 .\"O .BR syslog ()
72 .\"O (which talks to
73 .\"O .BR syslogd (8)),
74 .\"O then look at
75 .\"O .BR syslog (3).
76 .\"O The system call of this name is about controlling the kernel
77 .\"O .IR printk ()
78 .\"O buffer, and the glibc version is called
79 .\"O .BR klogctl ().
80 .RB ( syslogd (8)
81 と話す) C ライブラリ関数の
82 .BR syslog ()
83 が必要な場合は、
84 .BR syslog (3)
85 を見ること。
86 この名前のシステム・コールはカーネルの
87 .IR printk ()
88 バッファを制御するものであり、glibc では
89 .BR klogctl ()
90 と呼ばれている。
91
92 .\"O .The \fItype\fP argument determines the action taken by this function.
93 \fItype\fP 引き数はこの関数の動作を決定する。
94
95 .\"O Quoting from
96 .\"O .IR kernel/printk.c :
97 .I kernel/printk.c
98 からの引用 :
99 .nf
100 .\"O /*
101 .\"O  * Commands to sys_syslog:
102 .\"O  *
103 .\"O  *      0 \-\- Close the log.  Currently a NOP.
104 .\"O  *      1 \-\- Open the log. Currently a NOP.
105 .\"O  *      2 \-\- Read from the log.
106 .\"O  *      3 \-\- Read all messages remaining in the ring buffer.
107 .\"O  *      4 \-\- Read and clear all messages remaining in the ring buffer
108 .\"O  *      5 \-\- Clear ring buffer.
109 .\"O  *      6 \-\- Disable printk to console
110 .\"O  *      7 \-\- Enable printk to console
111 .\"O  *      8 \-\- Set level of messages printed to console
112 .\"O  *      9 \-\- Return number of unread characters in the log buffer
113 .\"O  *     10 \-\- Return size of the log buffer
114 .\"O  */
115 /*
116  * Commands to sys_syslog:
117  *
118  *      0 \-\- ログを閉じる。現在の実装では何もしない (NOP) 。
119  *      1 \-\- ログを開く。現在の実装では何もしない (NOP) 。
120  *      2 \-\- ログから読み出す。
121  *      3 \-\- リング・バッファに残っているメッセージをすべて読み出す。
122  *      4 \-\- リング・バッファに残っているメッセージをすべて読み出し、消去する。
123  *      5 \-\- リングバッファを消去する。
124  *      6 \-\- コンソールへの printk を無効にする。
125  *      7 \-\- コンソールへの printk を有効にする。
126  *      8 \-\- コンソールに表示されるメッセージのレベルを設定する。
127  *      9 \-\- ログバッファの未読の文字数を返す。
128  *      10 \-\- ログバッファのサイズを返す。
129  */
130 .fi
131
132 .\"O Only command types 3 and 10 are allowed to unprivileged processes.
133 .\"O Type 9 was added in 2.4.10; type 10 in 2.6.6.
134 非特権プロセスにはコマンド 3 と 10 のみが許可されている
135 (コマンド 9 は Linux 2.4.10 で、コマンド 10 は Linux 2.6.6 で追加された)。
136 .\"O .SS The kernel log buffer
137 .SS カーネル・ログ・バッファ (kernel log buffer)
138 .\"O The kernel has a cyclic buffer of length
139 .\"O .B LOG_BUF_LEN
140 .\"O in which messages given as arguments to the kernel function
141 .\"O .BR printk ()
142 .\"O are stored (regardless of their loglevel).
143 .\"O In early kernels,
144 .\"O .B LOG_BUF_LEN
145 .\"O had the value 4096;
146 .\"O from kernel 1.3.54, it was 8192;
147 .\"O from kernel 2.1.113 it was 16384;
148 .\"O since 2.4.23/2.6 the value is a kernel configuration option.
149 .\"O .\" Under "General setup" ==> "Kernel log buffer size"
150 .\"O .\" For 2.6, precisely the option seems to have appeared in 2.5.55.
151 .\"O In recent kernels the size can be queried with command type 10.
152 カーネルは長さ
153 .B LOG_BUF_LEN
154 の巡回式のバッファを持っており、
155 それにはカーネル関数の
156 .BR printk ()
157 の引き数として与えられた
158 メッセージが (そのログレベルにかかわらず) 格納される。
159 初期のカーネルでは
160 .B LOG_BUF_LEN
161 の値は 4096 であった。
162 カーネル 1.3.54 からは 8192、
163 カーネル 2.1.113 からは 16384 になり、
164 カーネル 2.4.23 以降および 2.6 以降ではカーネルのコンパイル時に
165 値を設定できるようになっている。
166 .\" Under "General setup" ==> "Kernel log buffer size"
167 .\" For 2.6, precisely the option seems to have appeared in 2.5.55.
168 最近のカーネルでは、コマンド 10 でバッファのサイズを問い合わせできる。
169
170 .\"O The call
171 .\"O .I "syslog(2,buf,len)"
172 .\"O waits until this kernel log buffer is nonempty, and then reads
173 .\"O at most \fIlen\fP bytes into the buffer \fIbuf\fP.
174 .\"O It returns
175 .\"O the number of bytes read.
176 .\"O Bytes read from the log disappear from
177 .\"O the log buffer: the information can only be read once.
178 .\"O This is the function executed by the kernel when a user program
179 .\"O reads
180 .\"O .IR /proc/kmsg .
181 .I "syslog(2,buf,len)"
182 の呼び出しはカーネル・ログ・バッファが空でなくなるまで待って、
183 最大 \fIlen\fP バイトまで \fIbuf\fP へと読み出し、読み込んだ
184 バイト数を返す。ログから読まれたバイトはログ・バッファから消える:
185 情報は一度しか読むことができない。
186 これはユーザーのプログラムが
187 .I /proc/kmsg
188 を読んだ時にカーネルによって実行される関数でもある。
189
190 .\"O The call
191 .\"O .I syslog(3,buf,len)
192 .\"O will read the last \fIlen\fP bytes from the log buffer (nondestructively),
193 .\"O but will not read more than was written into the buffer since the
194 .\"O last "clear ring buffer" command (which does not clear the buffer at all).
195 .\"O It returns the number of bytes read.
196 .I syslog(3,buf,len)
197 の呼び出しはログ・バッファの最後の \fIlen\fP バイトを
198 (非破壊的に)読み出す、しかし、直近の「リング・バッファ消去」命令
199 (この命令はバッファを消去するわけではない)
200 以降にバッファに書き込まれた情報しか読み出せない。
201 返り値は読み込んだバイト数である。
202
203 .\"O The call
204 .\"O .I syslog(4,buf,len)
205 .\"O does precisely the same, but also executes the "clear ring buffer" command.
206 .I syslog(4,buf,len)
207 呼び出しは「リング・バッファ消去」命令も実行する以外は
208 機能 3 と完全に同じである。
209
210 .\"O The call
211 .\"O .I syslog(5,dummy,dummy)
212 .\"O executes just the "clear ring buffer" command.
213 .\"O (In each call where
214 .\"O .I buf
215 .\"O or
216 .\"O .I len
217 .\"O is shown as "dummy", the value of the argument is ignored by the call.)
218 .I syslog(5,dummy,dummy)
219 呼び出しは「リング・バッファ消去」命令のみを実行する
220 (呼び出しの書式で、
221 .I buf
222
223 .I len
224 が "dummy" と記載されている場合、その引き数の値が無視されることを表す)。
225
226 .\"O The call
227 .\"O .I syslog(6,dummy,dummy)
228 .\"O sets the console log level to minimum, so that no messages are printed
229 .\"O to the console.
230 .I syslog(6,dummy,dummy)
231 呼び出しはコンソールのログレベルを最小に設定し、
232 コンソールにメッセージが表示されないようにする。
233
234 .\"O The call
235 .\"O .I syslog(7,dummy,dummy)
236 .\"O sets the console log level to default, so that messages are printed
237 .\"O to the console.
238 .I syslog(7,dummy,dummy)
239 呼び出しはコンソールのログレベルをデフォルトに設定し、
240 コンソールにメッセージが表示されるようにする。
241
242 .\"O The call
243 .\"O .I syslog(8,dummy,level)
244 .\"O sets the console log level to
245 .\"O .IR level ,
246 .\"O which must be an integer between 1 and 8 (inclusive).
247 .\"O See the
248 .\"O .B loglevel
249 .\"O section for details.
250 .I syslog(8,dummy,level)
251 呼び出しはコンソールのログレベルを
252 .I level
253 に設定する。
254 .I level
255 は 1 以上 8 以下の整数でなければならない。
256 詳細は
257 .B ログレベル (loglevel)
258 の節を参照のこと。
259
260 .\"O The call
261 .\"O .I syslog(9,dummy,dummy)
262 .\"O returns the number of bytes currently available to be read
263 .\"O on the kernel log buffer.
264 .I syslog(9,dummy,dummy)
265 呼び出しはカーネル・ログバッファにある現在読み出し可能なバイト数を返す。
266
267 .\"O The call
268 .\"O .I syslog(10,dummy,dummy)
269 .\"O returns the total size of the kernel log buffer.
270 .I syslog(10,dummy,dummy)
271 呼び出しはカーネル・ログバッファの総量を返す。
272 .\"O .SS The loglevel
273 .SS ログレベル (loglevel)
274 .\"O The kernel routine
275 .\"O .BR printk ()
276 .\"O will only print a message on the
277 .\"O console, if it has a loglevel less than the value of the variable
278 .\"O .IR console_loglevel .
279 .\"O This variable initially has the value
280 .\"O .B DEFAULT_CONSOLE_LOGLEVEL
281 .\"O (7), but is set to 10 if the
282 .\"O kernel command line contains the word "debug", and to 15 in case
283 .\"O  of a kernel fault (the 10 and 15 are just silly, and equivalent to 8).
284 カーネル・ルーチンの
285 .BR printk ()
286 は、ログレベルが
287 .I console_loglevel
288 変数より小さいときにのみ、コンソールにメッセージを表示する。
289 .I console_loglevel
290 は最初
291 .B DEFAULT_CONSOLE_LOGLEVEL
292 (7) に設定されるが、起動時にカーネルの
293 コマンド・ライン・オプションに "debug" という単語が含まれている場合は
294 10 に設定され、カーネル・フォールトが発生した場合には 15 に設定される
295 (但し、10 や 15 という数字に意味はなく、8 と同等である)。
296 .\"O This variable is set (to a value in the range 1-8) by the call
297 .\"O .IR syslog(8,dummy,value) .
298 .\"O The calls
299 .\"O .I syslog(type,dummy,dummy)
300 .\"O with \fItype\fP equal to 6 or 7, set it to 1 (kernel panics only)
301 .\"O or 7 (all except debugging messages), respectively.
302 この変数は
303 .IR syslog(8,dummy,value) .
304 呼び出しによって設定され、値の範囲は 1-8 である。
305 .I syslog(type,dummy,dummy)
306 呼び出しで \fItype\fP が 6 もしくは 7 の場合、
307 console_loglevel は 1 (カーネル・パニックのみ)、
308 7 (デバッグ・メッセージ以外の全て) にそれぞれ設定される。
309
310 .\"O Every text line in a message has its own loglevel.
311 .\"O This level is
312 .\"O .I "DEFAULT_MESSAGE_LOGLEVEL \- 1"
313 .\"O (6) unless the line starts with <d>
314 .\"O where \fId\fP is a digit in the range 1-7, in which case the level
315 .\"O is \fId\fP.
316 .\"O The conventional meaning of the loglevel is defined in
317 .\"O .I <linux/kernel.h>
318 .\"O as follows:
319 メッセージの各行はそれぞれにログレベルを持つ。このログレベルは
320 .I "DEFAULT_MESSAGE_LOGLEVEL \- 1"
321 (6) であるが、 <d> (\fId\fP は 1-7 の範囲の数字) で始まる行の
322 ログレベルは \fId\fP である。
323 ログレベルの慣習的な意味は
324 .I <linux/kernel.h>
325 に以下のように定義されている:
326
327 .nf
328 .\"O #define KERN_EMERG    "<0>"  /* system is unusable               */
329 .\"O #define KERN_ALERT    "<1>"  /* action must be taken immediately */
330 .\"O #define KERN_CRIT     "<2>"  /* critical conditions              */
331 .\"O #define KERN_ERR      "<3>"  /* error conditions                 */
332 .\"O #define KERN_WARNING  "<4>"  /* warning conditions               */
333 .\"O #define KERN_NOTICE   "<5>"  /* normal but significant condition */
334 .\"O #define KERN_INFO     "<6>"  /* informational                    */
335 .\"O #define KERN_DEBUG    "<7>"  /* debug-level messages             */
336 #define KERN_EMERG    "<0>"  /* システムが使用不能         */
337 #define KERN_ALERT    "<1>"  /* 直ちに対処が必要            */
338 #define KERN_CRIT     "<2>"  /* 致命的な状態                  */
339 #define KERN_ERR      "<3>"  /* エラー状態                     */
340 #define KERN_WARNING  "<4>"  /* 警告状態                        */
341 #define KERN_NOTICE   "<5>"  /* 通常状態だが大事な情報           */
342 #define KERN_INFO     "<6>"  /* 通知                              */
343 #define KERN_DEBUG    "<7>"  /* デバッグレベルの情報        */
344 .fi
345 .\"O .SH "RETURN VALUE"
346 .SH 返り値
347 .\"O For \fItype\fP equal to 2, 3, or 4, a successful call to
348 .\"O .BR syslog ()
349 .\"O returns the number
350 .\"O of bytes read.
351 .\"O For \fItype\fP 9,
352 .\"O .BR syslog ()
353 .\"O returns the number of bytes currently
354 .\"O available to be read on the kernel log buffer.
355 .\"O For \fItype\fP 10,
356 .\"O .BR syslog ()
357 .\"O returns the total size of the kernel log buffer.
358 .\"O For other values of \fItype\fP, 0 is returned on success.
359 \fItype\fP が 2, 3, 4 の場合、成功すると
360 .BR syslog ()
361 は読み出したバイト数を返す。
362 \fItype\fP が 9 の場合、
363 カーネル・ログバッファにある現在読み出し可能なバイト数を返す。
364 \fItype\fP が 10 の場合、
365 カーネル・ログバッファの総量を返す。
366 \fItype\fP がそれ以外の値の場合、成功すると 0 が返される。
367
368 .\"O In case of error, \-1 is returned,
369 .\"O and \fIerrno\fP is set to indicate the error.
370 エラーの場合は、\-1\ が返り、
371 \fIerrno\fP にエラーを示す値が設定される。
372 .\"O .SH ERRORS
373 .SH エラー
374 .TP
375 .B EINVAL
376 .\"O Bad arguments (e.g.,
377 .\"O bad
378 .\"O .IR type ;
379 .\"O or for
380 .\"O .I type
381 .\"O 2, 3, or 4,
382 .\"O .I buf
383 .\"O is NULL,
384 .\"O or
385 .\"O .I len
386 .\"O is less than zero; or for
387 .\"O .I type
388 .\"O 8, the
389 .\"O .I level
390 .\"O is outside the range 1 to 8).
391 不正な引き数
392 (具体的には、
393 .I type
394 が正しくない、もしくは
395 .I type
396 が 2, 3, 4 の場合に
397 .I buf
398 が NULL か
399 .I len
400 が 0 未満である、もしくは
401 .I type
402 が 8 の場合に
403 .I level
404 が 1 以上 8 以下の範囲に入っていない)。
405 .TP
406 .B ENOSYS
407 .\"O This
408 .\"O .BR syslog ()
409 .\"O system call is not available, because the kernel was compiled with the
410 .\"O .BR CONFIG_PRINTK
411 .\"O kernel-configuration option disabled.
412 カーネルの設定オプション
413 .BR CONFIG_PRINTK
414 を無効にしてカーネルがコンパイルされているため、
415 .BR syslog ()
416 システムコールが利用できない。
417 .TP
418 .B EPERM
419 .\"O An attempt was made to change console_loglevel or clear the kernel
420 .\"O message ring buffer by a process without sufficient privilege
421 .\"O (more precisely: without the
422 .\"O .B CAP_SYS_ADMIN
423 .\"O capability).
424 十分な権限を持たないプロセス (正確には
425 .B CAP_SYS_ADMIN
426 ケーパビリティを持たないプロセス) が console_loglevelを変更しようとしたか、
427 カーネル・メッセージ・リングを消去しようとした。
428 .TP
429 .B ERESTARTSYS
430 .\"O System call was interrupted by a signal - nothing was read.
431 .\"O (This can be seen only during a trace.)
432 システム・コールがシグナルによって割り込まれ、何も読み出せなかった。
433 (トレース中にしか発生することはない)
434 .\"O .SH "CONFORMING TO"
435 .SH 準拠
436 .\"O This system call is Linux-specific and should not be used in programs
437 .\"O intended to be portable.
438 このシステム・コールは Linux 特有であり、移植を意図したプログラムでは
439 使用してはいけない。
440 .\"O .SH NOTES
441 .SH 注意
442 .\"O From the very start people noted that it is unfortunate that
443 .\"O a system call and a library routine of the same name are entirely
444 .\"O different animals.
445 .\"O In libc4 and libc5 the number of this call was defined by
446 .\"O .BR SYS_klog .
447 .\"O In glibc 2.0 the syscall is baptized
448 .\"O .BR klogctl ().
449 かなり初期の頃から、同じ名前を持つシステム・コールと
450 ライブラリ・ルーチンが全く異なる代物であるのは不幸なことだと
451 気付かれていた。
452 libc4 と libc5 ではこのコールの番号は
453 .B SYS_klog
454 と定義されていた。
455 glibc2.0 でこのシステムコールは
456 .BR klogctl ()
457 という名前に改められた。
458 .\"O .SH "SEE ALSO"
459 .SH 関連項目
460 .BR syslog (3)