16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering#pragma once
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering/***
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering This file is part of systemd.
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering Copyright 2012 Lennart Poettering
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering systemd is free software; you can redistribute it and/or modify it
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering under the terms of the GNU Lesser General Public License as published by
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering (at your option) any later version.
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering systemd is distributed in the hope that it will be useful, but
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering Lesser General Public License for more details.
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering You should have received a copy of the GNU Lesser General Public License
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering***/
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering
f801968466fed39d50d410b30ac828c26722cc95Lennart Poettering#include <stdbool.h>
f801968466fed39d50d410b30ac828c26722cc95Lennart Poettering#include <sys/stat.h>
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering
fa6ac76083b8ffc1309876459f54f9f0e2843731Lennart Poettering/* One context per object type, plus one of the header, plus one "additional" one */
fa6ac76083b8ffc1309876459f54f9f0e2843731Lennart Poettering#define MMAP_CACHE_MAX_CONTEXTS 9
69adae5168da231c6cf319f708860954701b25edMichal Schmidt
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poetteringtypedef struct MMapCache MMapCache;
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering
84168d8068bb67dcd5468ab3b376535d81643aefLennart PoetteringMMapCache* mmap_cache_new(void);
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart PoetteringMMapCache* mmap_cache_ref(MMapCache *m);
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart PoetteringMMapCache* mmap_cache_unref(MMapCache *m);
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poettering
ae97089d49d1795a35a443b7b830ee666028e733Zbigniew Jędrzejewski-Szmekint mmap_cache_get(
ae97089d49d1795a35a443b7b830ee666028e733Zbigniew Jędrzejewski-Szmek MMapCache *m,
ae97089d49d1795a35a443b7b830ee666028e733Zbigniew Jędrzejewski-Szmek int fd,
ae97089d49d1795a35a443b7b830ee666028e733Zbigniew Jędrzejewski-Szmek int prot,
ae97089d49d1795a35a443b7b830ee666028e733Zbigniew Jędrzejewski-Szmek unsigned context,
ae97089d49d1795a35a443b7b830ee666028e733Zbigniew Jędrzejewski-Szmek bool keep_always,
ae97089d49d1795a35a443b7b830ee666028e733Zbigniew Jędrzejewski-Szmek uint64_t offset,
ae97089d49d1795a35a443b7b830ee666028e733Zbigniew Jędrzejewski-Szmek size_t size,
ae97089d49d1795a35a443b7b830ee666028e733Zbigniew Jędrzejewski-Szmek struct stat *st,
1b8951e5bd9b2bf1722098a861055cae0bb52088Michal Schmidt void **ret);
16e9f408fa9a9626059bdd6c89dc175e06b9e976Lennart Poetteringvoid mmap_cache_close_fd(MMapCache *m, int fd);
bf807d4dbf27c783db8dfd7f4eca321ae4be5b00Lennart Poettering
bf807d4dbf27c783db8dfd7f4eca321ae4be5b00Lennart Poetteringunsigned mmap_cache_get_hit(MMapCache *m);
bf807d4dbf27c783db8dfd7f4eca321ae4be5b00Lennart Poetteringunsigned mmap_cache_get_missed(MMapCache *m);
fa6ac76083b8ffc1309876459f54f9f0e2843731Lennart Poettering
fa6ac76083b8ffc1309876459f54f9f0e2843731Lennart Poetteringbool mmap_cache_got_sigbus(MMapCache *m, int fd);