]>
Commit | Line | Data |
---|---|---|
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 LP |
29 | |
30 | #include "journal-file.h" | |
31 | #include "hashmap.h" | |
32 | #include "util.h" | |
d7832d2c | 33 | #include "audit.h" |
d2bd7630 | 34 | #include "journald-rate-limit.h" |
e6960940 LP |
35 | #include "list.h" |
36 | ||
e156d769 LP |
37 | typedef enum Storage { |
38 | STORAGE_AUTO, | |
39 | STORAGE_VOLATILE, | |
205c4d1d | 40 | STORAGE_PERSISTENT, |
e156d769 LP |
41 | STORAGE_NONE, |
42 | _STORAGE_MAX, | |
43 | _STORAGE_INVALID = -1 | |
44 | } Storage; | |
45 | ||
182b858f LP |
46 | typedef enum SplitMode { |
47 | SPLIT_LOGIN, | |
48 | SPLIT_UID, | |
49 | SPLIT_NONE, | |
50 | _SPLIT_MAX, | |
51 | _SPLIT_INVALID = -1 | |
52 | } SplitMode; | |
53 | ||
e6960940 LP |
54 | typedef struct StdoutStream StdoutStream; |
55 | ||
56 | typedef struct Server { | |
57 | int epoll_fd; | |
58 | int signal_fd; | |
59 | int syslog_fd; | |
60 | int native_fd; | |
61 | int stdout_fd; | |
51abe64c | 62 | int dev_kmsg_fd; |
e6960940 LP |
63 | |
64 | JournalFile *runtime_journal; | |
65 | JournalFile *system_journal; | |
66 | Hashmap *user_journals; | |
67 | ||
68 | uint64_t seqnum; | |
69 | ||
70 | char *buffer; | |
71 | size_t buffer_size; | |
72 | ||
73 | JournalRateLimit *rate_limit; | |
26687bf8 | 74 | usec_t sync_interval_usec; |
e6960940 LP |
75 | usec_t rate_limit_interval; |
76 | unsigned rate_limit_burst; | |
77 | ||
78 | JournalMetrics runtime_metrics; | |
79 | JournalMetrics system_metrics; | |
80 | ||
81 | bool compress; | |
eb53b74f | 82 | bool seal; |
e6960940 | 83 | |
224f2ee2 LP |
84 | bool forward_to_kmsg; |
85 | bool forward_to_syslog; | |
86 | bool forward_to_console; | |
87 | ||
178cc770 LP |
88 | unsigned n_forward_syslog_missed; |
89 | usec_t last_warn_forward_syslog_missed; | |
90 | ||
e6960940 LP |
91 | uint64_t cached_available_space; |
92 | usec_t cached_available_space_timestamp; | |
93 | ||
94 | uint64_t var_available_timestamp; | |
95 | ||
fb0951b0 LP |
96 | usec_t max_retention_usec; |
97 | usec_t max_file_usec; | |
98 | usec_t oldest_file_usec; | |
99 | ||
5e41cfec LP |
100 | gid_t file_gid; |
101 | bool file_gid_valid; | |
102 | ||
e6960940 LP |
103 | LIST_HEAD(StdoutStream, stdout_streams); |
104 | unsigned n_stdout_streams; | |
0d9243f0 LP |
105 | |
106 | char *tty_path; | |
213ba152 LP |
107 | |
108 | int max_level_store; | |
109 | int max_level_syslog; | |
110 | int max_level_kmsg; | |
111 | int max_level_console; | |
e156d769 LP |
112 | |
113 | Storage storage; | |
182b858f | 114 | SplitMode split_mode; |
51abe64c | 115 | |
16e9f408 LP |
116 | MMapCache *mmap; |
117 | ||
51abe64c | 118 | bool dev_kmsg_readable; |
cee5e9a7 LP |
119 | |
120 | uint64_t *kernel_seqnum; | |
bdfb9e7f LP |
121 | |
122 | struct udev *udev; | |
26687bf8 OS |
123 | |
124 | int sync_timer_fd; | |
125 | bool sync_scheduled; | |
e6960940 LP |
126 | } Server; |
127 | ||
19cace37 | 128 | #define N_IOVEC_META_FIELDS 19 |
ef63833d LP |
129 | #define N_IOVEC_KERNEL_FIELDS 64 |
130 | #define N_IOVEC_UDEV_FIELDS 32 | |
968f3196 | 131 | #define N_IOVEC_OBJECT_FIELDS 11 |
ef63833d | 132 | |
968f3196 | 133 | 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); |
b1e2b33c | 134 | void server_driver_message(Server *s, sd_id128_t message_id, const char *format, ...) _printf_attr_(3,4); |
ef63833d | 135 | |
e6960940 LP |
136 | /* gperf lookup function */ |
137 | const struct ConfigPerfItem* journald_gperf_lookup(const char *key, unsigned length); | |
138 | ||
e8e581bf | 139 | 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); |
e156d769 | 140 | |
44a6b1b6 ZJS |
141 | const char *storage_to_string(Storage s) _const_; |
142 | Storage storage_from_string(const char *s) _pure_; | |
182b858f | 143 | |
e8e581bf | 144 | 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); |
182b858f | 145 | |
44a6b1b6 ZJS |
146 | const char *split_mode_to_string(SplitMode s) _const_; |
147 | SplitMode split_mode_from_string(const char *s) _pure_; | |
d025f1e4 ZJS |
148 | |
149 | void server_fix_perms(Server *s, JournalFile *f, uid_t uid); | |
150 | bool shall_try_append_again(JournalFile *f, int r); | |
151 | int server_init(Server *s); | |
152 | void server_done(Server *s); | |
26687bf8 | 153 | void server_sync(Server *s); |
d025f1e4 ZJS |
154 | void server_vacuum(Server *s); |
155 | void server_rotate(Server *s); | |
26687bf8 | 156 | int server_schedule_sync(Server *s); |
d025f1e4 ZJS |
157 | int server_flush_to_var(Server *s); |
158 | int process_event(Server *s, struct epoll_event *ev); | |
159 | void server_maybe_append_tags(Server *s); |