]>
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" | |
430f0182 | 23 | #include "capability-util.h" |
3ffd4af2 | 24 | #include "fd-util.h" |
1a299299 | 25 | #include "fileio.h" |
f97b34a6 | 26 | #include "format-util.h" |
07630cea | 27 | #include "memfd-util.h" |
6bedfcbb | 28 | #include "parse-util.h" |
d054f0a4 | 29 | #include "stdio-util.h" |
07630cea LP |
30 | #include "string-util.h" |
31 | #include "strv.h" | |
ee104e11 | 32 | #include "user-util.h" |
0a970718 | 33 | #include "memory-util.h" |
777d7a61 | 34 | |
a132bef0 | 35 | void close_and_munmap(int fd, void *address, size_t size) { |
45fbe937 | 36 | if (size > 0) |
76b7742c | 37 | assert_se(munmap(address, PAGE_ALIGN(size)) >= 0); |
45fbe937 | 38 | |
03e334a1 | 39 | safe_close(fd); |
bc7fd8cd LP |
40 | } |
41 | ||
a132bef0 | 42 | void bus_flush_memfd(sd_bus *b) { |
bc7fd8cd LP |
43 | unsigned i; |
44 | ||
45 | assert(b); | |
46 | ||
76b7742c | 47 | for (i = 0; i < b->n_memfd_cache; i++) |
8e959fbf | 48 | close_and_munmap(b->memfd_cache[i].fd, b->memfd_cache[i].address, b->memfd_cache[i].mapped); |
bc7fd8cd | 49 | } |