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