]>
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 | |
b5efdb8a | 12 | #include "alloc-util.h" |
07630cea | 13 | #include "bus-internal.h" |
3ffd4af2 | 14 | #include "bus-kernel.h" |
07630cea LP |
15 | #include "bus-label.h" |
16 | #include "bus-message.h" | |
430f0182 | 17 | #include "capability-util.h" |
3ffd4af2 | 18 | #include "fd-util.h" |
1a299299 | 19 | #include "fileio.h" |
f97b34a6 | 20 | #include "format-util.h" |
07630cea | 21 | #include "memfd-util.h" |
6bedfcbb | 22 | #include "parse-util.h" |
d054f0a4 | 23 | #include "stdio-util.h" |
07630cea LP |
24 | #include "string-util.h" |
25 | #include "strv.h" | |
ee104e11 | 26 | #include "user-util.h" |
0a970718 | 27 | #include "memory-util.h" |
777d7a61 | 28 | |
a132bef0 | 29 | void close_and_munmap(int fd, void *address, size_t size) { |
cbdac0c3 YW |
30 | if (size > 0) { |
31 | size = PAGE_ALIGN(size); | |
32 | assert(size < SIZE_MAX); | |
33 | assert_se(munmap(address, size) >= 0); | |
34 | } | |
45fbe937 | 35 | |
03e334a1 | 36 | safe_close(fd); |
bc7fd8cd LP |
37 | } |
38 | ||
a132bef0 | 39 | void bus_flush_memfd(sd_bus *b) { |
bc7fd8cd LP |
40 | assert(b); |
41 | ||
fe96c0f8 | 42 | for (unsigned i = 0; i < b->n_memfd_cache; i++) |
8e959fbf | 43 | close_and_munmap(b->memfd_cache[i].fd, b->memfd_cache[i].address, b->memfd_cache[i].mapped); |
bc7fd8cd | 44 | } |