]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/journal/journald-server.h
journal: introduce cache_space_invalidate()
[thirdparty/systemd.git] / src / journal / journald-server.h
CommitLineData
c2f1db8f 1#pragma once
e6960940
LP
2
3/***
4 This file is part of systemd.
5
6 Copyright 2011 Lennart Poettering
7
8 systemd is free software; you can redistribute it and/or modify it
5430f7f2
LP
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
e6960940
LP
11 (at your option) any later version.
12
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5430f7f2 16 Lesser General Public License for more details.
e6960940 17
5430f7f2 18 You should have received a copy of the GNU Lesser General Public License
e6960940
LP
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20***/
21
e6960940 22#include <stdbool.h>
b1bafc00 23#include <sys/types.h>
e6960940 24
f9a810be 25#include "sd-event.h"
430f0182 26
e22aa3d3
LP
27typedef struct Server Server;
28
e6960940 29#include "hashmap.h"
430f0182 30#include "journal-file.h"
d2bd7630 31#include "journald-rate-limit.h"
e22aa3d3 32#include "journald-stream.h"
e6960940
LP
33#include "list.h"
34
e156d769
LP
35typedef enum Storage {
36 STORAGE_AUTO,
37 STORAGE_VOLATILE,
205c4d1d 38 STORAGE_PERSISTENT,
e156d769
LP
39 STORAGE_NONE,
40 _STORAGE_MAX,
41 _STORAGE_INVALID = -1
42} Storage;
43
182b858f 44typedef enum SplitMode {
182b858f 45 SPLIT_UID,
76153ad4 46 SPLIT_LOGIN, /* deprecated */
182b858f
LP
47 SPLIT_NONE,
48 _SPLIT_MAX,
49 _SPLIT_INVALID = -1
50} SplitMode;
51
266a4700 52typedef struct JournalStorageSpace {
23aba343
FB
53 usec_t timestamp;
54
266a4700
FB
55 uint64_t available;
56 uint64_t limit;
23aba343
FB
57
58 uint64_t vfs_used; /* space used by journal files */
59 uint64_t vfs_available;
266a4700
FB
60} JournalStorageSpace;
61
62typedef struct JournalStorage {
63 const char *name;
64 const char *path;
65
66 JournalMetrics metrics;
67 JournalStorageSpace space;
68} JournalStorage;
69
e22aa3d3 70struct Server {
e6960940
LP
71 int syslog_fd;
72 int native_fd;
73 int stdout_fd;
51abe64c 74 int dev_kmsg_fd;
875c2e22 75 int audit_fd;
0c24bb23 76 int hostname_fd;
e22aa3d3 77 int notify_fd;
e6960940 78
f9a810be
LP
79 sd_event *event;
80
81 sd_event_source *syslog_event_source;
82 sd_event_source *native_event_source;
83 sd_event_source *stdout_event_source;
84 sd_event_source *dev_kmsg_event_source;
875c2e22 85 sd_event_source *audit_event_source;
f9a810be
LP
86 sd_event_source *sync_event_source;
87 sd_event_source *sigusr1_event_source;
88 sd_event_source *sigusr2_event_source;
89 sd_event_source *sigterm_event_source;
90 sd_event_source *sigint_event_source;
94b65516 91 sd_event_source *sigrtmin1_event_source;
0c24bb23 92 sd_event_source *hostname_event_source;
e22aa3d3 93 sd_event_source *notify_event_source;
119e9655 94 sd_event_source *watchdog_event_source;
f9a810be 95
e6960940
LP
96 JournalFile *runtime_journal;
97 JournalFile *system_journal;
43cf8388 98 OrderedHashmap *user_journals;
e6960940
LP
99
100 uint64_t seqnum;
101
102 char *buffer;
103 size_t buffer_size;
104
105 JournalRateLimit *rate_limit;
26687bf8 106 usec_t sync_interval_usec;
e6960940
LP
107 usec_t rate_limit_interval;
108 unsigned rate_limit_burst;
109
266a4700
FB
110 JournalStorage runtime_storage;
111 JournalStorage system_storage;
e6960940
LP
112
113 bool compress;
eb53b74f 114 bool seal;
e6960940 115
224f2ee2
LP
116 bool forward_to_kmsg;
117 bool forward_to_syslog;
118 bool forward_to_console;
40b71e89 119 bool forward_to_wall;
224f2ee2 120
178cc770
LP
121 unsigned n_forward_syslog_missed;
122 usec_t last_warn_forward_syslog_missed;
123
e6960940
LP
124 uint64_t var_available_timestamp;
125
fb0951b0
LP
126 usec_t max_retention_usec;
127 usec_t max_file_usec;
128 usec_t oldest_file_usec;
129
e6960940 130 LIST_HEAD(StdoutStream, stdout_streams);
e22aa3d3 131 LIST_HEAD(StdoutStream, stdout_streams_notify_queue);
e6960940 132 unsigned n_stdout_streams;
0d9243f0
LP
133
134 char *tty_path;
213ba152
LP
135
136 int max_level_store;
137 int max_level_syslog;
138 int max_level_kmsg;
139 int max_level_console;
40b71e89 140 int max_level_wall;
e156d769
LP
141
142 Storage storage;
182b858f 143 SplitMode split_mode;
51abe64c 144
16e9f408
LP
145 MMapCache *mmap;
146
b58c888f
VC
147 Set *deferred_closes;
148
119e9655 149 struct udev *udev;
cee5e9a7
LP
150
151 uint64_t *kernel_seqnum;
119e9655 152 bool dev_kmsg_readable:1;
bdfb9e7f 153
119e9655
LP
154 bool send_watchdog:1;
155 bool sent_notify_ready:1;
156 bool sync_scheduled:1;
0c24bb23
LP
157
158 char machine_id_field[sizeof("_MACHINE_ID=") + 32];
159 char boot_id_field[sizeof("_BOOT_ID=") + 32];
160 char *hostname_field;
e9174f29
LP
161
162 /* Cached cgroup root, so that we don't have to query that all the time */
163 char *cgroup_root;
119e9655
LP
164
165 usec_t watchdog_usec;
7c070017
LP
166
167 usec_t last_realtime_clock;
e22aa3d3 168};
e6960940 169
8580d1f7
LP
170#define SERVER_MACHINE_ID(s) ((s)->machine_id_field + strlen("_MACHINE_ID="))
171
4b58153d 172#define N_IOVEC_META_FIELDS 22
ef63833d
LP
173#define N_IOVEC_KERNEL_FIELDS 64
174#define N_IOVEC_UDEV_FIELDS 32
d473176a 175#define N_IOVEC_OBJECT_FIELDS 14
282c5c4e 176#define N_IOVEC_PAYLOAD_FIELDS 15
ef63833d 177
3b3154df 178void 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);
8a03c9ef 179void server_driver_message(Server *s, sd_id128_t message_id, const char *format, ...) _printf_(3,0) _sentinel_;
ef63833d 180
e6960940
LP
181/* gperf lookup function */
182const struct ConfigPerfItem* journald_gperf_lookup(const char *key, unsigned length);
183
71a61510 184int 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 185
44a6b1b6
ZJS
186const char *storage_to_string(Storage s) _const_;
187Storage storage_from_string(const char *s) _pure_;
182b858f 188
71a61510 189int 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 190
44a6b1b6
ZJS
191const char *split_mode_to_string(SplitMode s) _const_;
192SplitMode split_mode_from_string(const char *s) _pure_;
d025f1e4 193
d025f1e4
ZJS
194int server_init(Server *s);
195void server_done(Server *s);
26687bf8 196void server_sync(Server *s);
8580d1f7 197int server_vacuum(Server *s, bool verbose, bool patch_min_use);
d025f1e4 198void server_rotate(Server *s);
d07f7b9e 199int server_schedule_sync(Server *s, int priority);
d025f1e4 200int server_flush_to_var(Server *s);
d025f1e4 201void server_maybe_append_tags(Server *s);
8531ae70 202int server_process_datagram(sd_event_source *es, int fd, uint32_t revents, void *userdata);
cba5629e 203void server_space_usage_message(Server *s, JournalStorage *storage);