chiark / gitweb /
journal: rework directory enumeration/watch logic
[elogind.git] / src / journal / journal-internal.h
1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
2
3 #ifndef foojournalinternalhfoo
4 #define foojournalinternalhfoo
5
6 /***
7   This file is part of systemd.
8
9   Copyright 2011 Lennart Poettering
10
11   systemd is free software; you can redistribute it and/or modify it
12   under the terms of the GNU Lesser General Public License as published by
13   the Free Software Foundation; either version 2.1 of the License, or
14   (at your option) any later version.
15
16   systemd is distributed in the hope that it will be useful, but
17   WITHOUT ANY WARRANTY; without even the implied warranty of
18   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19   Lesser General Public License for more details.
20
21   You should have received a copy of the GNU Lesser General Public License
22   along with systemd; If not, see <http://www.gnu.org/licenses/>.
23 ***/
24
25 #include <sys/types.h>
26 #include <inttypes.h>
27 #include <stdbool.h>
28
29 #include <systemd/sd-id128.h>
30
31 #include "list.h"
32
33 typedef struct Match Match;
34 typedef struct Location Location;
35 typedef struct Directory Directory;
36
37 typedef enum location_type {
38         LOCATION_HEAD,
39         LOCATION_TAIL,
40         LOCATION_DISCRETE
41 } location_type_t;
42
43 struct Match {
44         char *data;
45         size_t size;
46         le64_t le_hash;
47
48         LIST_FIELDS(Match, matches);
49 };
50
51 struct Location {
52         location_type_t type;
53
54         uint64_t seqnum;
55         sd_id128_t seqnum_id;
56         bool seqnum_set;
57
58         uint64_t realtime;
59         bool realtime_set;
60
61         uint64_t monotonic;
62         sd_id128_t boot_id;
63         bool monotonic_set;
64
65         uint64_t xor_hash;
66         bool xor_hash_set;
67 };
68
69 struct Directory {
70         char *path;
71         int wd;
72         bool is_root;
73 };
74
75 struct sd_journal {
76         int flags;
77
78         Hashmap *files;
79
80         Location current_location;
81         JournalFile *current_file;
82         uint64_t current_field;
83
84         Hashmap *directories_by_path;
85         Hashmap *directories_by_wd;
86
87         int inotify_fd;
88
89         LIST_HEAD(Match, matches);
90         unsigned n_matches;
91
92         unsigned current_invalidate_counter, last_invalidate_counter;
93 };
94
95 #endif