aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/printk.c
diff options
context:
space:
mode:
authorJames Morris <jmorris@namei.org>2010-02-28 17:36:31 -0500
committerJames Morris <jmorris@namei.org>2010-02-28 17:36:31 -0500
commitb4ccebdd37ff70d349321a198f416ba737a5e833 (patch)
tree275d717070346722c3aacd8355fb4f743216e03b /kernel/printk.c
parent30ff056c42c665b9ea535d8515890857ae382540 (diff)
parentef57471a73b67a7b65fd8708fd55c77cb7c619af (diff)
Merge branch 'next' into for-linus
Diffstat (limited to 'kernel/printk.c')
-rw-r--r--kernel/printk.c52
1 files changed, 23 insertions, 29 deletions
diff --git a/kernel/printk.c b/kernel/printk.c
index 1751c456b71f..40674122ecf2 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -35,6 +35,7 @@
35#include <linux/kexec.h> 35#include <linux/kexec.h>
36#include <linux/ratelimit.h> 36#include <linux/ratelimit.h>
37#include <linux/kmsg_dump.h> 37#include <linux/kmsg_dump.h>
38#include <linux/syslog.h>
38 39
39#include <asm/uaccess.h> 40#include <asm/uaccess.h>
40 41
@@ -258,38 +259,23 @@ static inline void boot_delay_msec(void)
258} 259}
259#endif 260#endif
260 261
261/* 262int do_syslog(int type, char __user *buf, int len, bool from_file)
262 * Commands to do_syslog:
263 *
264 * 0 -- Close the log. Currently a NOP.
265 * 1 -- Open the log. Currently a NOP.
266 * 2 -- Read from the log.
267 * 3 -- Read all messages remaining in the ring buffer.
268 * 4 -- Read and clear all messages remaining in the ring buffer
269 * 5 -- Clear ring buffer.
270 * 6 -- Disable printk's to console
271 * 7 -- Enable printk's to console
272 * 8 -- Set level of messages printed to console
273 * 9 -- Return number of unread characters in the log buffer
274 * 10 -- Return size of the log buffer
275 */
276int do_syslog(int type, char __user *buf, int len)
277{ 263{
278 unsigned i, j, limit, count; 264 unsigned i, j, limit, count;
279 int do_clear = 0; 265 int do_clear = 0;
280 char c; 266 char c;
281 int error = 0; 267 int error = 0;
282 268
283 error = security_syslog(type); 269 error = security_syslog(type, from_file);
284 if (error) 270 if (error)
285 return error; 271 return error;
286 272
287 switch (type) { 273 switch (type) {
288 case 0: /* Close log */ 274 case SYSLOG_ACTION_CLOSE: /* Close log */
289 break; 275 break;
290 case 1: /* Open log */ 276 case SYSLOG_ACTION_OPEN: /* Open log */
291 break; 277 break;
292 case 2: /* Read from log */ 278 case SYSLOG_ACTION_READ: /* Read from log */
293 error = -EINVAL; 279 error = -EINVAL;
294 if (!buf || len < 0) 280 if (!buf || len < 0)
295 goto out; 281 goto out;
@@ -320,10 +306,12 @@ int do_syslog(int type, char __user *buf, int len)
320 if (!error) 306 if (!error)
321 error = i; 307 error = i;
322 break; 308 break;
323 case 4: /* Read/clear last kernel messages */ 309 /* Read/clear last kernel messages */
310 case SYSLOG_ACTION_READ_CLEAR:
324 do_clear = 1; 311 do_clear = 1;
325 /* FALL THRU */ 312 /* FALL THRU */
326 case 3: /* Read last kernel messages */ 313 /* Read last kernel messages */
314 case SYSLOG_ACTION_READ_ALL:
327 error = -EINVAL; 315 error = -EINVAL;
328 if (!buf || len < 0) 316 if (!buf || len < 0)
329 goto out; 317 goto out;
@@ -376,21 +364,25 @@ int do_syslog(int type, char __user *buf, int len)
376 } 364 }
377 } 365 }
378 break; 366 break;
379 case 5: /* Clear ring buffer */ 367 /* Clear ring buffer */
368 case SYSLOG_ACTION_CLEAR:
380 logged_chars = 0; 369 logged_chars = 0;
381 break; 370 break;
382 case 6: /* Disable logging to console */ 371 /* Disable logging to console */
372 case SYSLOG_ACTION_CONSOLE_OFF:
383 if (saved_console_loglevel == -1) 373 if (saved_console_loglevel == -1)
384 saved_console_loglevel = console_loglevel; 374 saved_console_loglevel = console_loglevel;
385 console_loglevel = minimum_console_loglevel; 375 console_loglevel = minimum_console_loglevel;
386 break; 376 break;
387 case 7: /* Enable logging to console */ 377 /* Enable logging to console */
378 case SYSLOG_ACTION_CONSOLE_ON:
388 if (saved_console_loglevel != -1) { 379 if (saved_console_loglevel != -1) {
389 console_loglevel = saved_console_loglevel; 380 console_loglevel = saved_console_loglevel;
390 saved_console_loglevel = -1; 381 saved_console_loglevel = -1;
391 } 382 }
392 break; 383 break;
393 case 8: /* Set level of messages printed to console */ 384 /* Set level of messages printed to console */
385 case SYSLOG_ACTION_CONSOLE_LEVEL:
394 error = -EINVAL; 386 error = -EINVAL;
395 if (len < 1 || len > 8) 387 if (len < 1 || len > 8)
396 goto out; 388 goto out;
@@ -401,10 +393,12 @@ int do_syslog(int type, char __user *buf, int len)
401 saved_console_loglevel = -1; 393 saved_console_loglevel = -1;
402 error = 0; 394 error = 0;
403 break; 395 break;
404 case 9: /* Number of chars in the log buffer */ 396 /* Number of chars in the log buffer */
397 case SYSLOG_ACTION_SIZE_UNREAD:
405 error = log_end - log_start; 398 error = log_end - log_start;
406 break; 399 break;
407 case 10: /* Size of the log buffer */ 400 /* Size of the log buffer */
401 case SYSLOG_ACTION_SIZE_BUFFER:
408 error = log_buf_len; 402 error = log_buf_len;
409 break; 403 break;
410 default: 404 default:
@@ -417,7 +411,7 @@ out:
417 411
418SYSCALL_DEFINE3(syslog, int, type, char __user *, buf, int, len) 412SYSCALL_DEFINE3(syslog, int, type, char __user *, buf, int, len)
419{ 413{
420 return do_syslog(type, buf, len); 414 return do_syslog(type, buf, len, SYSLOG_FROM_CALL);
421} 415}
422 416
423/* 417/*