]> git.proxmox.com Git - systemd.git/blame - src/libsystemd/sd-bus/bus-kernel.c
New upstream version 240
[systemd.git] / src / libsystemd / sd-bus / bus-kernel.c
CommitLineData
52ad194e 1/* SPDX-License-Identifier: LGPL-2.1+ */
60f067b4 2
f5e65279 3#if HAVE_VALGRIND_MEMCHECK_H
60f067b4
JS
4#include <valgrind/memcheck.h>
5#endif
6
7#include <fcntl.h>
8#include <malloc.h>
9#include <sys/mman.h>
10#include <sys/prctl.h>
11
e735f4d4 12/* When we include libgen.h because we need dirname() we immediately
86f210e9
MP
13 * undefine basename() since libgen.h defines it as a macro to the POSIX
14 * version which is really broken. We prefer GNU basename(). */
e735f4d4
MP
15#include <libgen.h>
16#undef basename
17
db2df898 18#include "alloc-util.h"
60f067b4 19#include "bus-internal.h"
60f067b4 20#include "bus-kernel.h"
60f067b4 21#include "bus-label.h"
db2df898
MP
22#include "bus-message.h"
23#include "bus-util.h"
24#include "capability-util.h"
25#include "fd-util.h"
26#include "fileio.h"
2897b343 27#include "format-util.h"
db2df898
MP
28#include "memfd-util.h"
29#include "parse-util.h"
4c89c718 30#include "stdio-util.h"
db2df898
MP
31#include "string-util.h"
32#include "strv.h"
33#include "user-util.h"
34#include "util.h"
60f067b4 35
f5e65279 36void close_and_munmap(int fd, void *address, size_t size) {
60f067b4
JS
37 if (size > 0)
38 assert_se(munmap(address, PAGE_ALIGN(size)) >= 0);
39
40 safe_close(fd);
41}
42
f5e65279 43void bus_flush_memfd(sd_bus *b) {
60f067b4
JS
44 unsigned i;
45
46 assert(b);
47
48 for (i = 0; i < b->n_memfd_cache; i++)
49 close_and_munmap(b->memfd_cache[i].fd, b->memfd_cache[i].address, b->memfd_cache[i].mapped);
50}