]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/journal/mmap-cache.h
Merge pull request #6300 from keszybz/refuse-to-load-some-units
[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 typedef struct MMapFileDescriptor MMapFileDescriptor;
30
31 MMapCache* mmap_cache_new(void);
32 MMapCache* mmap_cache_ref(MMapCache *m);
33 MMapCache* mmap_cache_unref(MMapCache *m);
34
35 int mmap_cache_get(
36 MMapCache *m,
37 MMapFileDescriptor *f,
38 int prot,
39 unsigned context,
40 bool keep_always,
41 uint64_t offset,
42 size_t size,
43 struct stat *st,
44 void **ret);
45 MMapFileDescriptor * mmap_cache_add_fd(MMapCache *m, int fd);
46 void mmap_cache_free_fd(MMapCache *m, MMapFileDescriptor *f);
47
48 unsigned mmap_cache_get_hit(MMapCache *m);
49 unsigned mmap_cache_get_missed(MMapCache *m);
50
51 bool mmap_cache_got_sigbus(MMapCache *m, MMapFileDescriptor *f);