1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 Copyright 2013 Lennart Poettering
6 #if HAVE_VALGRIND_MEMCHECK_H
7 #include <valgrind/memcheck.h>
13 #include <sys/prctl.h>
15 /* When we include libgen.h because we need dirname() we immediately
16 * undefine basename() since libgen.h defines it as a macro to the POSIX
17 * version which is really broken. We prefer GNU basename(). */
21 #include "alloc-util.h"
22 #include "bus-internal.h"
23 #include "bus-kernel.h"
24 #include "bus-label.h"
25 #include "bus-message.h"
27 #include "capability-util.h"
30 #include "format-util.h"
31 #include "memfd-util.h"
32 #include "parse-util.h"
33 #include "stdio-util.h"
34 #include "string-util.h"
36 #include "user-util.h"
39 void close_and_munmap(int fd, void *address, size_t size) {
41 assert_se(munmap(address, PAGE_ALIGN(size)) >= 0);
46 void bus_flush_memfd(sd_bus *b) {
51 for (i = 0; i < b->n_memfd_cache; i++)
52 close_and_munmap(b->memfd_cache[i].fd, b->memfd_cache[i].address, b->memfd_cache[i].mapped);
54 #if 0 /// UNNEEDED by elogind