]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/journal/mmap-cache.h
Add SPDX license identifiers to source files under the LGPL
[thirdparty/systemd.git] / src / journal / mmap-cache.h
CommitLineData
53e1b683 1/* SPDX-License-Identifier: LGPL-2.1+ */
16e9f408
LP
2#pragma once
3
4/***
5 This file is part of systemd.
6
7 Copyright 2012 Lennart Poettering
8
9 systemd is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation; either version 2.1 of the License, or
12 (at your option) any later version.
13
14 systemd is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21***/
22
f8019684
LP
23#include <stdbool.h>
24#include <sys/stat.h>
16e9f408 25
fa6ac760
LP
26/* One context per object type, plus one of the header, plus one "additional" one */
27#define MMAP_CACHE_MAX_CONTEXTS 9
69adae51 28
16e9f408 29typedef struct MMapCache MMapCache;
be7cdd8e 30typedef struct MMapFileDescriptor MMapFileDescriptor;
16e9f408 31
84168d80 32MMapCache* mmap_cache_new(void);
16e9f408
LP
33MMapCache* mmap_cache_ref(MMapCache *m);
34MMapCache* mmap_cache_unref(MMapCache *m);
35
ae97089d
ZJS
36int mmap_cache_get(
37 MMapCache *m,
be7cdd8e 38 MMapFileDescriptor *f,
ae97089d
ZJS
39 int prot,
40 unsigned context,
41 bool keep_always,
42 uint64_t offset,
43 size_t size,
44 struct stat *st,
b42549ad
VC
45 void **ret,
46 size_t *ret_size);
be7cdd8e
VC
47MMapFileDescriptor * mmap_cache_add_fd(MMapCache *m, int fd);
48void mmap_cache_free_fd(MMapCache *m, MMapFileDescriptor *f);
bf807d4d
LP
49
50unsigned mmap_cache_get_hit(MMapCache *m);
51unsigned mmap_cache_get_missed(MMapCache *m);
fa6ac760 52
be7cdd8e 53bool mmap_cache_got_sigbus(MMapCache *m, MMapFileDescriptor *f);