]> git.ipfire.org Git - thirdparty/systemd.git/blame - src/journal/mmap-cache.h
journal: return mapped size from mmap_cache_get()
[thirdparty/systemd.git] / src / journal / mmap-cache.h
CommitLineData
16e9f408
LP
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
f8019684
LP
22#include <stdbool.h>
23#include <sys/stat.h>
16e9f408 24
fa6ac760
LP
25/* One context per object type, plus one of the header, plus one "additional" one */
26#define MMAP_CACHE_MAX_CONTEXTS 9
69adae51 27
16e9f408 28typedef struct MMapCache MMapCache;
be7cdd8e 29typedef struct MMapFileDescriptor MMapFileDescriptor;
16e9f408 30
84168d80 31MMapCache* mmap_cache_new(void);
16e9f408
LP
32MMapCache* mmap_cache_ref(MMapCache *m);
33MMapCache* mmap_cache_unref(MMapCache *m);
34
ae97089d
ZJS
35int mmap_cache_get(
36 MMapCache *m,
be7cdd8e 37 MMapFileDescriptor *f,
ae97089d
ZJS
38 int prot,
39 unsigned context,
40 bool keep_always,
41 uint64_t offset,
42 size_t size,
43 struct stat *st,
b42549ad
VC
44 void **ret,
45 size_t *ret_size);
be7cdd8e
VC
46MMapFileDescriptor * mmap_cache_add_fd(MMapCache *m, int fd);
47void mmap_cache_free_fd(MMapCache *m, MMapFileDescriptor *f);
bf807d4d
LP
48
49unsigned mmap_cache_get_hit(MMapCache *m);
50unsigned mmap_cache_get_missed(MMapCache *m);
fa6ac760 51
be7cdd8e 52bool mmap_cache_got_sigbus(MMapCache *m, MMapFileDescriptor *f);