chiark / gitweb /
enable localization for common *ctl commands
[elogind.git] / src / journal / journald.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #pragma once
4
5 /***
6   This file is part of systemd.
7
8   Copyright 2011 Lennart Poettering
9
10   systemd is free software; you can redistribute it and/or modify it
11   under the terms of the GNU Lesser General Public License as published by
12   the Free Software Foundation; either version 2.1 of the License, or
13   (at your option) any later version.
14
15   systemd is distributed in the hope that it will be useful, but
16   WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18   Lesser General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 ***/
23
24 #include <inttypes.h>
25 #include <stdbool.h>
26 #include <sys/types.h>
27 #include <sys/socket.h>
28
29 #include "journal-file.h"
30 #include "hashmap.h"
31 #include "util.h"
32 #include "audit.h"
33 #include "journald-rate-limit.h"
34 #include "list.h"
35
36 typedef enum Storage {
37         STORAGE_AUTO,
38         STORAGE_VOLATILE,
39         STORAGE_PERSISTENT,
40         STORAGE_NONE,
41         _STORAGE_MAX,
42         _STORAGE_INVALID = -1
43 } Storage;
44
45 typedef enum SplitMode {
46         SPLIT_LOGIN,
47         SPLIT_UID,
48         SPLIT_NONE,
49         _SPLIT_MAX,
50         _SPLIT_INVALID = -1
51 } SplitMode;
52
53 typedef struct StdoutStream StdoutStream;
54
55 typedef struct Server {
56         int epoll_fd;
57         int signal_fd;
58         int syslog_fd;
59         int native_fd;
60         int stdout_fd;
61         int dev_kmsg_fd;
62
63         JournalFile *runtime_journal;
64         JournalFile *system_journal;
65         Hashmap *user_journals;
66
67         uint64_t seqnum;
68
69         char *buffer;
70         size_t buffer_size;
71
72         JournalRateLimit *rate_limit;
73         usec_t rate_limit_interval;
74         unsigned rate_limit_burst;
75
76         JournalMetrics runtime_metrics;
77         JournalMetrics system_metrics;
78
79         bool compress;
80         bool seal;
81
82         bool forward_to_kmsg;
83         bool forward_to_syslog;
84         bool forward_to_console;
85
86         unsigned n_forward_syslog_missed;
87         usec_t last_warn_forward_syslog_missed;
88
89         uint64_t cached_available_space;
90         usec_t cached_available_space_timestamp;
91
92         uint64_t var_available_timestamp;
93
94         usec_t max_retention_usec;
95         usec_t max_file_usec;
96         usec_t oldest_file_usec;
97
98         gid_t file_gid;
99         bool file_gid_valid;
100
101         LIST_HEAD(StdoutStream, stdout_streams);
102         unsigned n_stdout_streams;
103
104         char *tty_path;
105
106         int max_level_store;
107         int max_level_syslog;
108         int max_level_kmsg;
109         int max_level_console;
110
111         Storage storage;
112         SplitMode split_mode;
113
114         MMapCache *mmap;
115
116         bool dev_kmsg_readable;
117
118         uint64_t *kernel_seqnum;
119
120         struct udev *udev;
121 } Server;
122
123 #define N_IOVEC_META_FIELDS 17
124 #define N_IOVEC_KERNEL_FIELDS 64
125 #define N_IOVEC_UDEV_FIELDS 32
126
127 void server_dispatch_message(Server *s, struct iovec *iovec, unsigned n, unsigned m, struct ucred *ucred, struct timeval *tv, const char *label, size_t label_len, const char *unit_id, int priority);
128 void server_driver_message(Server *s, sd_id128_t message_id, const char *format, ...);
129
130 /* gperf lookup function */
131 const struct ConfigPerfItem* journald_gperf_lookup(const char *key, unsigned length);
132
133 int config_parse_storage(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
134
135 const char *storage_to_string(Storage s);
136 Storage storage_from_string(const char *s);
137
138 int config_parse_split_mode(const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
139
140 const char *split_mode_to_string(SplitMode s);
141 SplitMode split_mode_from_string(const char *s);