diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-05-15 19:45:05 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-05-15 19:45:45 +0200 |
commit | 453a0c2946da620f99825d39db335e9ea9861829 (patch) | |
tree | cb994a26bf2b84d0c6090e88d8ccb113aeef37e6 /src/libsystemd-bus/sd-memfd.c | |
parent | 99271804172f6ac51be9556b2bdf37d6a7e952bc (diff) |
bus: add support for adding memfds into message payload
Diffstat (limited to 'src/libsystemd-bus/sd-memfd.c')
-rw-r--r-- | src/libsystemd-bus/sd-memfd.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/libsystemd-bus/sd-memfd.c b/src/libsystemd-bus/sd-memfd.c index 2712a26f66..bd14da3a70 100644 --- a/src/libsystemd-bus/sd-memfd.c +++ b/src/libsystemd-bus/sd-memfd.c @@ -205,3 +205,27 @@ int sd_memfd_set_size(sd_memfd *m, uint64_t sz) { return r; } + +int sd_memfd_new_and_map(sd_memfd **m, size_t sz, void **p) { + sd_memfd *n; + int r; + + r = sd_memfd_new(&n); + if (r < 0) + return r; + + r = sd_memfd_set_size(n, sz); + if (r < 0) { + sd_memfd_free(n); + return r; + } + + r = sd_memfd_map(n, 0, sz, p); + if (r < 0) { + sd_memfd_free(n); + return r; + } + + *m = n; + return 0; +} |