]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/journal/mmap-cache.h
udev: fix codesonar warnings
[thirdparty/systemd.git] / src / journal / mmap-cache.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 #include <stdbool.h>
5 #include <sys/stat.h>
6
7 /* One context per object type, plus one of the header, plus one "additional" one */
8 #define MMAP_CACHE_MAX_CONTEXTS 9
9
10 typedef struct MMapCache MMapCache;
11 typedef struct MMapFileDescriptor MMapFileDescriptor;
12
13 MMapCache* mmap_cache_new(void);
14 MMapCache* mmap_cache_ref(MMapCache *m);
15 MMapCache* mmap_cache_unref(MMapCache *m);
16
17 int mmap_cache_get(
18 MMapCache *m,
19 MMapFileDescriptor *f,
20 int prot,
21 unsigned context,
22 bool keep_always,
23 uint64_t offset,
24 size_t size,
25 struct stat *st,
26 void **ret,
27 size_t *ret_size);
28 MMapFileDescriptor * mmap_cache_add_fd(MMapCache *m, int fd);
29 void mmap_cache_free_fd(MMapCache *m, MMapFileDescriptor *f);
30
31 unsigned mmap_cache_get_hit(MMapCache *m);
32 unsigned mmap_cache_get_missed(MMapCache *m);
33
34 bool mmap_cache_got_sigbus(MMapCache *m, MMapFileDescriptor *f);