]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
6629161f | 2 | |
fd8d62d9 | 3 | #include <sys/mman.h> |
6629161f | 4 | |
3ffd4af2 | 5 | #include "bus-kernel.h" |
5cdf13c7 | 6 | #include "bus-internal.h" |
3ffd4af2 | 7 | #include "fd-util.h" |
1cf40697 | 8 | #include "memory-util.h" |
777d7a61 | 9 | |
a132bef0 | 10 | void close_and_munmap(int fd, void *address, size_t size) { |
cbdac0c3 YW |
11 | if (size > 0) { |
12 | size = PAGE_ALIGN(size); | |
13 | assert(size < SIZE_MAX); | |
14 | assert_se(munmap(address, size) >= 0); | |
15 | } | |
45fbe937 | 16 | |
03e334a1 | 17 | safe_close(fd); |
bc7fd8cd LP |
18 | } |
19 | ||
a132bef0 | 20 | void bus_flush_memfd(sd_bus *b) { |
bc7fd8cd LP |
21 | assert(b); |
22 | ||
fe96c0f8 | 23 | for (unsigned i = 0; i < b->n_memfd_cache; i++) |
8e959fbf | 24 | close_and_munmap(b->memfd_cache[i].fd, b->memfd_cache[i].address, b->memfd_cache[i].mapped); |
bc7fd8cd | 25 | } |