]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/journal/mmap-cache.h
journal: introduce JournalStorage and JournalStorageSpace structures
[thirdparty/systemd.git] / src / journal / mmap-cache.h
1 #pragma once
2
3 /***
4 This file is part of systemd.
5
6 Copyright 2012 Lennart Poettering
7
8 systemd is free software; you can redistribute it and/or modify it
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
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
16 Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 ***/
21
22 #include <stdbool.h>
23 #include <sys/stat.h>
24
25 /* One context per object type, plus one of the header, plus one "additional" one */
26 #define MMAP_CACHE_MAX_CONTEXTS 9
27
28 typedef struct MMapCache MMapCache;
29
30 MMapCache* mmap_cache_new(void);
31 MMapCache* mmap_cache_ref(MMapCache *m);
32 MMapCache* mmap_cache_unref(MMapCache *m);
33
34 int mmap_cache_get(
35 MMapCache *m,
36 int fd,
37 int prot,
38 unsigned context,
39 bool keep_always,
40 uint64_t offset,
41 size_t size,
42 struct stat *st,
43 void **ret);
44 void mmap_cache_close_fd(MMapCache *m, int fd);
45
46 unsigned mmap_cache_get_hit(MMapCache *m);
47 unsigned mmap_cache_get_missed(MMapCache *m);
48
49 bool mmap_cache_got_sigbus(MMapCache *m, int fd);