Containerized syslog working properly
[safe/jmp/linux-2.6] / include / linux / syslog.h
1 /*  Syslog internals
2  *
3  *  Copyright 2010 Canonical, Ltd.
4  *  Author: Kees Cook <kees.cook@canonical.com>
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2, or (at your option)
9  *  any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; see the file COPYING.  If not, write to
18  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19  */
20
21 #ifndef _LINUX_SYSLOG_H
22 #define _LINUX_SYSLOG_H
23
24 /* Close the log.  Currently a NOP. */
25 #define SYSLOG_ACTION_CLOSE          0
26 /* Open the log. Currently a NOP. */
27 #define SYSLOG_ACTION_OPEN           1
28 /* Read from the log. */
29 #define SYSLOG_ACTION_READ           2
30 /* Read all messages remaining in the ring buffer. */
31 #define SYSLOG_ACTION_READ_ALL       3
32 /* Read and clear all messages remaining in the ring buffer */
33 #define SYSLOG_ACTION_READ_CLEAR     4
34 /* Clear ring buffer. */
35 #define SYSLOG_ACTION_CLEAR          5
36 /* Disable printk's to console */
37 #define SYSLOG_ACTION_CONSOLE_OFF    6
38 /* Enable printk's to console */
39 #define SYSLOG_ACTION_CONSOLE_ON     7
40 /* Set level of messages printed to console */
41 #define SYSLOG_ACTION_CONSOLE_LEVEL  8
42 /* Return number of unread characters in the log buffer */
43 #define SYSLOG_ACTION_SIZE_UNREAD    9
44 /* Return size of the log buffer */
45 #define SYSLOG_ACTION_SIZE_BUFFER   10
46
47 #define SYSLOG_FROM_CALL 0
48 #define SYSLOG_FROM_FILE 1
49
50 #define CLONE_SYSLOG \
51         (CLONE_NEWUTS | CLONE_NEWIPC | CLONE_NEWUSER | \
52          CLONE_NEWPID | CLONE_NEWNET)
53 /*structure used to dispatch syslog data according container of origin  */
54 struct syslog_ns {
55         struct kref kref;       /*syslog_ns reference count & control      */
56         int handle;             /*syslog handle number                     */
57         struct syslog_ns *prvns;/*parent process own syslog                */
58         spinlock_t logbuf_lock; /* access conflict locker                  */
59         unsigned log_start;     /* Index: next char to be read by syslog() */
60         unsigned con_start;     /* Index: next char to be sent to consoles */
61         unsigned log_end;       /* Index: most-recently-written-char + 1   */
62         unsigned logged_chars;  /* Num chars produced since last read+clear*/
63         unsigned buf_len;       /* buffer available space size             */
64         char *buf;              /* allocated ring buffer                   */
65 };
66
67 /*
68  * Static structure used by nsproxy
69  */
70 extern struct syslog_ns init_syslog_ns;
71 extern struct syslog_ns *resize_syslog_ns(struct syslog_ns *syslog_ns,
72                                         unsigned container_buf_len);
73 extern struct syslog_ns *copy_syslog_ns(unsigned long flags,
74                                         struct syslog_ns *current_syslog_ns);
75 extern void free_syslog_ns(struct kref *kref);
76 extern struct syslog_ns *current_syslog_ns(void);
77 extern struct syslog_ns *switch_syslog_ns(struct syslog_ns *syslog_ns);
78 extern struct syslog_ns *find_syslog_ns_bypid(pid_t pid);
79 extern void put_syslog_ns(struct syslog_ns *ns);
80
81
82
83 int do_syslog(int type, char __user *buf, int count, bool from_file);
84
85 #endif /* _LINUX_SYSLOG_H */