1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
6 This file is part of systemd.
8 Copyright 2011 Lennart Poettering
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.
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.
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/>.
26 #include <sys/epoll.h>
27 #include <sys/types.h>
28 #include <sys/socket.h>
30 #include "journal-file.h"
34 #include "journald-rate-limit.h"
37 typedef enum Storage {
46 typedef enum SplitMode {
54 typedef struct StdoutStream StdoutStream;
56 typedef struct Server {
64 JournalFile *runtime_journal;
65 JournalFile *system_journal;
66 Hashmap *user_journals;
73 JournalRateLimit *rate_limit;
74 usec_t sync_interval_usec;
75 usec_t rate_limit_interval;
76 unsigned rate_limit_burst;
78 JournalMetrics runtime_metrics;
79 JournalMetrics system_metrics;
85 bool forward_to_syslog;
86 bool forward_to_console;
88 unsigned n_forward_syslog_missed;
89 usec_t last_warn_forward_syslog_missed;
91 uint64_t cached_available_space;
92 usec_t cached_available_space_timestamp;
94 uint64_t var_available_timestamp;
96 usec_t max_retention_usec;
98 usec_t oldest_file_usec;
100 LIST_HEAD(StdoutStream, stdout_streams);
101 unsigned n_stdout_streams;
106 int max_level_syslog;
108 int max_level_console;
111 SplitMode split_mode;
115 bool dev_kmsg_readable;
117 uint64_t *kernel_seqnum;
125 #define N_IOVEC_META_FIELDS 20
126 #define N_IOVEC_KERNEL_FIELDS 64
127 #define N_IOVEC_UDEV_FIELDS 32
128 #define N_IOVEC_OBJECT_FIELDS 11
130 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, pid_t object_pid);
131 void server_driver_message(Server *s, sd_id128_t message_id, const char *format, ...) _printf_(3,4);
133 /* gperf lookup function */
134 const struct ConfigPerfItem* journald_gperf_lookup(const char *key, unsigned length);
136 int config_parse_storage(const char *unit, const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
138 const char *storage_to_string(Storage s) _const_;
139 Storage storage_from_string(const char *s) _pure_;
141 int config_parse_split_mode(const char *unit, const char *filename, unsigned line, const char *section, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
143 const char *split_mode_to_string(SplitMode s) _const_;
144 SplitMode split_mode_from_string(const char *s) _pure_;
146 void server_fix_perms(Server *s, JournalFile *f, uid_t uid);
147 bool shall_try_append_again(JournalFile *f, int r);
148 int server_init(Server *s);
149 void server_done(Server *s);
150 void server_sync(Server *s);
151 void server_vacuum(Server *s);
152 void server_rotate(Server *s);
153 int server_schedule_sync(Server *s, int priority);
154 int server_flush_to_var(Server *s);
155 int process_event(Server *s, struct epoll_event *ev);
156 void server_maybe_append_tags(Server *s);