]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
6629161f | 2 | |
349cc4a5 | 3 | #if HAVE_VALGRIND_MEMCHECK_H |
7211f918 LP |
4 | #include <valgrind/memcheck.h> |
5 | #endif | |
6 | ||
6629161f | 7 | #include <fcntl.h> |
c556fe79 | 8 | #include <malloc.h> |
fd8d62d9 | 9 | #include <sys/mman.h> |
5972fe95 | 10 | #include <sys/prctl.h> |
6629161f | 11 | |
eef46c37 | 12 | /* When we include libgen.h because we need dirname() we immediately |
11c9f1e4 SM |
13 | * undefine basename() since libgen.h defines it as a macro to the POSIX |
14 | * version which is really broken. We prefer GNU basename(). */ | |
eef46c37 LP |
15 | #include <libgen.h> |
16 | #undef basename | |
17 | ||
b5efdb8a | 18 | #include "alloc-util.h" |
07630cea | 19 | #include "bus-internal.h" |
3ffd4af2 | 20 | #include "bus-kernel.h" |
07630cea LP |
21 | #include "bus-label.h" |
22 | #include "bus-message.h" | |
23 | #include "bus-util.h" | |
430f0182 | 24 | #include "capability-util.h" |
3ffd4af2 | 25 | #include "fd-util.h" |
1a299299 | 26 | #include "fileio.h" |
f97b34a6 | 27 | #include "format-util.h" |
07630cea | 28 | #include "memfd-util.h" |
6bedfcbb | 29 | #include "parse-util.h" |
d054f0a4 | 30 | #include "stdio-util.h" |
07630cea LP |
31 | #include "string-util.h" |
32 | #include "strv.h" | |
ee104e11 | 33 | #include "user-util.h" |
0a970718 | 34 | #include "memory-util.h" |
777d7a61 | 35 | |
a132bef0 | 36 | void close_and_munmap(int fd, void *address, size_t size) { |
45fbe937 | 37 | if (size > 0) |
76b7742c | 38 | assert_se(munmap(address, PAGE_ALIGN(size)) >= 0); |
45fbe937 | 39 | |
03e334a1 | 40 | safe_close(fd); |
bc7fd8cd LP |
41 | } |
42 | ||
a132bef0 | 43 | void bus_flush_memfd(sd_bus *b) { |
bc7fd8cd LP |
44 | unsigned i; |
45 | ||
46 | assert(b); | |
47 | ||
76b7742c | 48 | for (i = 0; i < b->n_memfd_cache; i++) |
8e959fbf | 49 | close_and_munmap(b->memfd_cache[i].fd, b->memfd_cache[i].address, b->memfd_cache[i].mapped); |
bc7fd8cd | 50 | } |