chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Update french translation
[elogind.git]
/
src
/
libsystemd
/
sd-bus
/
bus-message.c
diff --git
a/src/libsystemd/sd-bus/bus-message.c
b/src/libsystemd/sd-bus/bus-message.c
index eaffa2d3a207b1924e758af185b257dcd17f0834..d00455a1121de100b01e64cb5a61e6c550a47398 100644
(file)
--- a/
src/libsystemd/sd-bus/bus-message.c
+++ b/
src/libsystemd/sd-bus/bus-message.c
@@
-28,6
+28,7
@@
#include "strv.h"
#include "time-util.h"
#include "cgroup-util.h"
#include "strv.h"
#include "time-util.h"
#include "cgroup-util.h"
+#include "memfd.h"
#include "sd-bus.h"
#include "bus-message.h"
#include "sd-bus.h"
#include "bus-message.h"
@@
-801,9
+802,10
@@
_public_ sd_bus_message* sd_bus_message_unref(sd_bus_message *m) {
assert(m->n_ref > 0);
m->n_ref--;
assert(m->n_ref > 0);
m->n_ref--;
- if (m->n_ref
<=
0)
-
message_free(m)
;
+ if (m->n_ref
>
0)
+
return NULL
;
+ message_free(m);
return NULL;
}
return NULL;
}
@@
-1075,7
+1077,7
@@
static int part_make_space(
uint64_t new_allocated;
new_allocated = PAGE_ALIGN(sz > 0 ? 2 * sz : 1);
uint64_t new_allocated;
new_allocated = PAGE_ALIGN(sz > 0 ? 2 * sz : 1);
- r =
ioctl(part->memfd, KDBUS_CMD_MEMFD_SIZE_SET, &
new_allocated);
+ r =
ftruncate(part->memfd,
new_allocated);
if (r < 0) {
m->poisoned = true;
return -errno;
if (r < 0) {
m->poisoned = true;
return -errno;
@@
-2526,7
+2528,7
@@
_public_ int sd_bus_message_append_array_iovec(
_public_ int sd_bus_message_append_array_memfd(sd_bus_message *m,
char type,
_public_ int sd_bus_message_append_array_memfd(sd_bus_message *m,
char type,
-
sd_memfd *
memfd) {
+
int
memfd) {
_cleanup_close_ int copy_fd = -1;
struct bus_body_part *part;
ssize_t align, sz;
_cleanup_close_ int copy_fd = -1;
struct bus_body_part *part;
ssize_t align, sz;
@@
-2536,7
+2538,7
@@
_public_ int sd_bus_message_append_array_memfd(sd_bus_message *m,
if (!m)
return -EINVAL;
if (!m)
return -EINVAL;
- if (
!memfd
)
+ if (
memfd < 0
)
return -EINVAL;
if (m->sealed)
return -EPERM;
return -EINVAL;
if (m->sealed)
return -EPERM;
@@
-2545,15
+2547,15
@@
_public_ int sd_bus_message_append_array_memfd(sd_bus_message *m,
if (m->poisoned)
return -ESTALE;
if (m->poisoned)
return -ESTALE;
- r =
sd_memfd_set_sealed(memfd, true
);
+ r =
memfd_set_sealed(memfd
);
if (r < 0)
return r;
if (r < 0)
return r;
- copy_fd =
sd_memfd_dup_fd
(memfd);
+ copy_fd =
dup
(memfd);
if (copy_fd < 0)
return copy_fd;
if (copy_fd < 0)
return copy_fd;
- r =
sd_
memfd_get_size(memfd, &size);
+ r = memfd_get_size(memfd, &size);
if (r < 0)
return r;
if (r < 0)
return r;
@@
-2592,7
+2594,7
@@
_public_ int sd_bus_message_append_array_memfd(sd_bus_message *m,
return sd_bus_message_close_container(m);
}
return sd_bus_message_close_container(m);
}
-_public_ int sd_bus_message_append_string_memfd(sd_bus_message *m,
sd_memfd *
memfd) {
+_public_ int sd_bus_message_append_string_memfd(sd_bus_message *m,
int
memfd) {
_cleanup_close_ int copy_fd = -1;
struct bus_body_part *part;
struct bus_container *c;
_cleanup_close_ int copy_fd = -1;
struct bus_body_part *part;
struct bus_container *c;
@@
-2601,19
+2603,19
@@
_public_ int sd_bus_message_append_string_memfd(sd_bus_message *m, sd_memfd *mem
int r;
assert_return(m, -EINVAL);
int r;
assert_return(m, -EINVAL);
- assert_return(memfd, -EINVAL);
+ assert_return(memfd
>= 0
, -EINVAL);
assert_return(!m->sealed, -EPERM);
assert_return(!m->poisoned, -ESTALE);
assert_return(!m->sealed, -EPERM);
assert_return(!m->poisoned, -ESTALE);
- r =
sd_memfd_set_sealed(memfd, true
);
+ r =
memfd_set_sealed(memfd
);
if (r < 0)
return r;
if (r < 0)
return r;
- copy_fd =
sd_memfd_dup_fd
(memfd);
+ copy_fd =
dup
(memfd);
if (copy_fd < 0)
return copy_fd;
if (copy_fd < 0)
return copy_fd;
- r =
sd_
memfd_get_size(memfd, &size);
+ r = memfd_get_size(memfd, &size);
if (r < 0)
return r;
if (r < 0)
return r;
@@
-2798,11
+2800,11
@@
int bus_message_seal(sd_bus_message *m, uint64_t cookie, usec_t timeout) {
/* Then, sync up real memfd size */
sz = part->size;
/* Then, sync up real memfd size */
sz = part->size;
- if (
ioctl(part->memfd, KDBUS_CMD_MEMFD_SIZE_SET, &
sz) < 0)
+ if (
ftruncate(part->memfd,
sz) < 0)
return -errno;
/* Finally, try to seal */
return -errno;
/* Finally, try to seal */
- if (
ioctl(part->memfd, KDBUS_CMD_MEMFD_SEAL_SET, 1
) >= 0)
+ if (
fcntl(part->memfd, F_ADD_SEALS, F_SEAL_SHRINK | F_SEAL_GROW | F_SEAL_WRITE
) >= 0)
part->sealed = true;
}
}
part->sealed = true;
}
}
@@
-2839,7
+2841,7
@@
int bus_body_part_map(struct bus_body_part *part) {
psz = PAGE_ALIGN(part->size);
if (part->memfd >= 0)
psz = PAGE_ALIGN(part->size);
if (part->memfd >= 0)
- p = mmap(NULL, psz, PROT_READ, MAP_
SHARED
, part->memfd, 0);
+ p = mmap(NULL, psz, PROT_READ, MAP_
PRIVATE
, part->memfd, 0);
else if (part->is_zero)
p = mmap(NULL, psz, PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
else
else if (part->is_zero)
p = mmap(NULL, psz, PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
else