]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/journal/journald-server.h
journald: process SIGBUS for the memory maps we set up
[thirdparty/systemd.git] / src / journal / journald-server.h
CommitLineData
e6960940
LP
1/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
c2f1db8f 3#pragma once
e6960940
LP
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
5430f7f2
LP
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
e6960940
LP
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
5430f7f2 18 Lesser General Public License for more details.
e6960940 19
5430f7f2 20 You should have received a copy of the GNU Lesser General Public License
e6960940
LP
21 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22***/
23
24#include <inttypes.h>
e6960940 25#include <stdbool.h>
d025f1e4 26#include <sys/epoll.h>
b1bafc00
ZJS
27#include <sys/types.h>
28#include <sys/socket.h>
e6960940 29
f9a810be 30#include "sd-event.h"
e6960940
LP
31#include "journal-file.h"
32#include "hashmap.h"
33#include "util.h"
d7832d2c 34#include "audit.h"
d2bd7630 35#include "journald-rate-limit.h"
e6960940
LP
36#include "list.h"
37
e156d769
LP
38typedef enum Storage {
39 STORAGE_AUTO,
40 STORAGE_VOLATILE,
205c4d1d 41 STORAGE_PERSISTENT,
e156d769
LP
42 STORAGE_NONE,
43 _STORAGE_MAX,
44 _STORAGE_INVALID = -1
45} Storage;
46
182b858f 47typedef enum SplitMode {
182b858f 48 SPLIT_UID,
edc3797f 49 SPLIT_LOGIN,
182b858f
LP
50 SPLIT_NONE,
51 _SPLIT_MAX,
52 _SPLIT_INVALID = -1
53} SplitMode;
54
e6960940
LP
55typedef struct StdoutStream StdoutStream;
56
57typedef struct Server {
e6960940
LP
58 int syslog_fd;
59 int native_fd;
60 int stdout_fd;
51abe64c 61 int dev_kmsg_fd;
875c2e22 62 int audit_fd;
0c24bb23 63 int hostname_fd;
e6960940 64
f9a810be
LP
65 sd_event *event;
66
67 sd_event_source *syslog_event_source;
68 sd_event_source *native_event_source;
69 sd_event_source *stdout_event_source;
70 sd_event_source *dev_kmsg_event_source;
875c2e22 71 sd_event_source *audit_event_source;
f9a810be
LP
72 sd_event_source *sync_event_source;
73 sd_event_source *sigusr1_event_source;
74 sd_event_source *sigusr2_event_source;
75 sd_event_source *sigterm_event_source;
76 sd_event_source *sigint_event_source;
0c24bb23 77 sd_event_source *hostname_event_source;
f9a810be 78
e6960940
LP
79 JournalFile *runtime_journal;
80 JournalFile *system_journal;
43cf8388 81 OrderedHashmap *user_journals;
e6960940
LP
82
83 uint64_t seqnum;
84
85 char *buffer;
86 size_t buffer_size;
87
88 JournalRateLimit *rate_limit;
26687bf8 89 usec_t sync_interval_usec;
e6960940
LP
90 usec_t rate_limit_interval;
91 unsigned rate_limit_burst;
92
93 JournalMetrics runtime_metrics;
94 JournalMetrics system_metrics;
95
96 bool compress;
eb53b74f 97 bool seal;
e6960940 98
224f2ee2
LP
99 bool forward_to_kmsg;
100 bool forward_to_syslog;
101 bool forward_to_console;
40b71e89 102 bool forward_to_wall;
224f2ee2 103
178cc770
LP
104 unsigned n_forward_syslog_missed;
105 usec_t last_warn_forward_syslog_missed;
106
e6960940
LP
107 uint64_t cached_available_space;
108 usec_t cached_available_space_timestamp;
109
110 uint64_t var_available_timestamp;
111
fb0951b0
LP
112 usec_t max_retention_usec;
113 usec_t max_file_usec;
114 usec_t oldest_file_usec;
115
e6960940
LP
116 LIST_HEAD(StdoutStream, stdout_streams);
117 unsigned n_stdout_streams;
0d9243f0
LP
118
119 char *tty_path;
213ba152
LP
120
121 int max_level_store;
122 int max_level_syslog;
123 int max_level_kmsg;
124 int max_level_console;
40b71e89 125 int max_level_wall;
e156d769
LP
126
127 Storage storage;
182b858f 128 SplitMode split_mode;
51abe64c 129
16e9f408
LP
130 MMapCache *mmap;
131
51abe64c 132 bool dev_kmsg_readable;
cee5e9a7
LP
133
134 uint64_t *kernel_seqnum;
bdfb9e7f
LP
135
136 struct udev *udev;
26687bf8 137
26687bf8 138 bool sync_scheduled;
0c24bb23
LP
139
140 char machine_id_field[sizeof("_MACHINE_ID=") + 32];
141 char boot_id_field[sizeof("_BOOT_ID=") + 32];
142 char *hostname_field;
e9174f29
LP
143
144 /* Cached cgroup root, so that we don't have to query that all the time */
145 char *cgroup_root;
e6960940
LP
146} Server;
147
0a244b8e 148#define N_IOVEC_META_FIELDS 20
ef63833d
LP
149#define N_IOVEC_KERNEL_FIELDS 64
150#define N_IOVEC_UDEV_FIELDS 32
968f3196 151#define N_IOVEC_OBJECT_FIELDS 11
ef63833d 152
3b3154df 153void server_dispatch_message(Server *s, struct iovec *iovec, unsigned n, unsigned m, const struct ucred *ucred, const struct timeval *tv, const char *label, size_t label_len, const char *unit_id, int priority, pid_t object_pid);
44b601bc 154void server_driver_message(Server *s, sd_id128_t message_id, const char *format, ...) _printf_(3,4);
ef63833d 155
e6960940
LP
156/* gperf lookup function */
157const struct ConfigPerfItem* journald_gperf_lookup(const char *key, unsigned length);
158
71a61510 159int config_parse_storage(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
e156d769 160
44a6b1b6
ZJS
161const char *storage_to_string(Storage s) _const_;
162Storage storage_from_string(const char *s) _pure_;
182b858f 163
71a61510 164int config_parse_split_mode(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
182b858f 165
44a6b1b6
ZJS
166const char *split_mode_to_string(SplitMode s) _const_;
167SplitMode split_mode_from_string(const char *s) _pure_;
d025f1e4
ZJS
168
169void server_fix_perms(Server *s, JournalFile *f, uid_t uid);
170bool shall_try_append_again(JournalFile *f, int r);
171int server_init(Server *s);
172void server_done(Server *s);
26687bf8 173void server_sync(Server *s);
d025f1e4
ZJS
174void server_vacuum(Server *s);
175void server_rotate(Server *s);
d07f7b9e 176int server_schedule_sync(Server *s, int priority);
d025f1e4 177int server_flush_to_var(Server *s);
d025f1e4 178void server_maybe_append_tags(Server *s);
f9a810be 179int process_datagram(sd_event_source *es, int fd, uint32_t revents, void *userdata);