summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-bus/bus-kernel.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-08-18 18:12:55 +0200
committerLennart Poettering <lennart@poettering.net>2014-08-18 18:12:55 +0200
commit630a4d9ea7298fb4a494662cbb4871069143ff56 (patch)
tree01059a8c749b0dabfd98b6f40a587e0fcdf8bfae /src/libsystemd/sd-bus/bus-kernel.c
parent283868e1dcd8ea7475850d9c6e7d4722c473dd50 (diff)
parente0fbf1fcffe014d5af6767b29f9108c2f2444888 (diff)
Merge remote-tracking branch 'origin/master'
Diffstat (limited to 'src/libsystemd/sd-bus/bus-kernel.c')
-rw-r--r--src/libsystemd/sd-bus/bus-kernel.c21
1 files changed, 3 insertions, 18 deletions
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 8b961c38eb..d384f846b9 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -1111,9 +1111,6 @@ int bus_kernel_pop_memfd(sd_bus *bus, void **address, size_t *mapped, size_t *al
if (bus->n_memfd_cache <= 0) {
_cleanup_free_ char *g = NULL;
- struct kdbus_cmd_memfd_make *cmd;
- struct kdbus_item *item;
- size_t l, sz;
int r;
assert_se(pthread_mutex_unlock(&bus->memfd_cache_mutex) >= 0);
@@ -1124,26 +1121,14 @@ int bus_kernel_pop_memfd(sd_bus *bus, void **address, size_t *mapped, size_t *al
if (!g)
return -ENOMEM;
- l = strlen(g);
- sz = ALIGN8(offsetof(struct kdbus_cmd_memfd_make, items)) +
- ALIGN8(offsetof(struct kdbus_item, str)) +
- l + 1;
- cmd = alloca0(sz);
- cmd->size = sz;
-
- item = cmd->items;
- item->size = ALIGN8(offsetof(struct kdbus_item, str)) + l + 1;
- item->type = KDBUS_ITEM_MEMFD_NAME;
- memcpy(item->str, g, l + 1);
-
- r = ioctl(bus->input_fd, KDBUS_CMD_MEMFD_NEW, cmd);
+ r = memfd_create(g, MFD_ALLOW_SEALING);
if (r < 0)
return -errno;
*address = NULL;
*mapped = 0;
*allocated = 0;
- return cmd->fd;
+ return r;
}
c = &bus->memfd_cache[--bus->n_memfd_cache];
@@ -1195,7 +1180,7 @@ void bus_kernel_push_memfd(sd_bus *bus, int fd, void *address, size_t mapped, si
/* If overly long, let's return a bit to the OS */
if (mapped > max_mapped) {
- assert_se(ioctl(fd, KDBUS_CMD_MEMFD_SIZE_SET, &max_mapped) >= 0);
+ assert_se(ftruncate(fd, max_mapped) >= 0);
assert_se(munmap((uint8_t*) address + max_mapped, PAGE_ALIGN(mapped - max_mapped)) >= 0);
c->mapped = c->allocated = max_mapped;
} else {