Blame view
fs/proc/kmsg.c
1.45 KB
1da177e4c Linux-2.6.12-rc2 |
1 2 3 4 5 6 7 8 9 10 11 12 |
/* * linux/fs/proc/kmsg.c * * Copyright (C) 1992 by Linus Torvalds * */ #include <linux/types.h> #include <linux/errno.h> #include <linux/time.h> #include <linux/kernel.h> #include <linux/poll.h> |
ae048112c proc: move /proc/... |
13 |
#include <linux/proc_fs.h> |
1da177e4c Linux-2.6.12-rc2 |
14 |
#include <linux/fs.h> |
002345925 syslog: distingui... |
15 |
#include <linux/syslog.h> |
1da177e4c Linux-2.6.12-rc2 |
16 17 18 19 20 |
#include <asm/uaccess.h> #include <asm/io.h> extern wait_queue_head_t log_wait; |
1da177e4c Linux-2.6.12-rc2 |
21 22 |
static int kmsg_open(struct inode * inode, struct file * file) { |
d78ca3cd7 syslog: use defin... |
23 |
return do_syslog(SYSLOG_ACTION_OPEN, NULL, 0, SYSLOG_FROM_FILE); |
1da177e4c Linux-2.6.12-rc2 |
24 25 26 27 |
} static int kmsg_release(struct inode * inode, struct file * file) { |
d78ca3cd7 syslog: use defin... |
28 |
(void) do_syslog(SYSLOG_ACTION_CLOSE, NULL, 0, SYSLOG_FROM_FILE); |
1da177e4c Linux-2.6.12-rc2 |
29 30 31 32 33 34 |
return 0; } static ssize_t kmsg_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) { |
002345925 syslog: distingui... |
35 |
if ((file->f_flags & O_NONBLOCK) && |
d78ca3cd7 syslog: use defin... |
36 |
!do_syslog(SYSLOG_ACTION_SIZE_UNREAD, NULL, 0, SYSLOG_FROM_FILE)) |
1da177e4c Linux-2.6.12-rc2 |
37 |
return -EAGAIN; |
d78ca3cd7 syslog: use defin... |
38 |
return do_syslog(SYSLOG_ACTION_READ, buf, count, SYSLOG_FROM_FILE); |
1da177e4c Linux-2.6.12-rc2 |
39 40 41 42 43 |
} static unsigned int kmsg_poll(struct file *file, poll_table *wait) { poll_wait(file, &log_wait, wait); |
d78ca3cd7 syslog: use defin... |
44 |
if (do_syslog(SYSLOG_ACTION_SIZE_UNREAD, NULL, 0, SYSLOG_FROM_FILE)) |
1da177e4c Linux-2.6.12-rc2 |
45 46 47 |
return POLLIN | POLLRDNORM; return 0; } |
ae048112c proc: move /proc/... |
48 |
static const struct file_operations proc_kmsg_operations = { |
1da177e4c Linux-2.6.12-rc2 |
49 50 51 52 |
.read = kmsg_read, .poll = kmsg_poll, .open = kmsg_open, .release = kmsg_release, |
41775e29a procfs: Use gener... |
53 |
.llseek = generic_file_llseek, |
1da177e4c Linux-2.6.12-rc2 |
54 |
}; |
ae048112c proc: move /proc/... |
55 56 57 58 59 60 61 |
static int __init proc_kmsg_init(void) { proc_create("kmsg", S_IRUSR, NULL, &proc_kmsg_operations); return 0; } module_init(proc_kmsg_init); |