1SD_BUS_MESSAGE_APPEND_ARRAYs(d3_)bus_message_append_aSrDr_aByUS_MESSAGE_APPEND_ARRAY(3)
2
3
4
6 sd_bus_message_append_array, sd_bus_message_append_array_memfd,
7 sd_bus_message_append_array_iovec, sd_bus_message_append_array_space -
8 Append an array of fields to a D-Bus message
9
11 #include <systemd/sd-bus.h>
12
13 int sd_bus_message_append_array(sd_bus_message *m, char type,
14 void *ptr, size_t size);
15
16 int sd_bus_message_append_array_memfd(sd_bus_message *m, char type,
17 int memfd, uint64_t offset,
18 uint64_t size);
19
20 int sd_bus_message_append_array_iovec(sd_bus_message *m, char type,
21 const struct iovec *iov,
22 unsigned n);
23
24 int sd_bus_message_append_array_space(sd_bus_message *m, char type,
25 size_t size, void **ptr);
26
28 The sd_bus_message_append_array() function appends an array to a D-Bus
29 message m. A container will be opened, the array contents appended, and
30 the container closed. The parameter type determines how the pointer p
31 is interpreted. type must be one of the "trivial" types "y", "n", "q",
32 "i", "u", "x", "t", "d" (but not "b"), as defined by the Basic Types[1]
33 section of the D-Bus specification, and listed in
34 sd_bus_message_append_basic(3). Pointer p must point to an array of
35 size size bytes containing items of the respective type. Size size must
36 be a multiple of the size of the type type. As a special case, p may be
37 NULL, if size is 0. The memory pointed to by p is copied into the
38 memory area containing the message and stays in possession of the
39 caller. The caller may hence freely change the data after this call
40 without affecting the message the array was appended to.
41
42 The sd_bus_message_append_array_memfd() function appends an array of a
43 trivial type to message m, similar to sd_bus_message_append_array().
44 The contents of the memory file descriptor memfd starting at the
45 specified offset and of the specified size is used as the contents of
46 the array. The offset and size must be a multiple of the size of the
47 type type. However, as a special exception, if the offset is specified
48 as zero and the size specified as UINT64_MAX the full memory file
49 descriptor contents is used. The memory file descriptor is sealed by
50 this call if it has not been sealed yet, and cannot be modified after
51 this call. See memfd_create(2) for details about memory file
52 descriptors. Appending arrays with memory file descriptors enables
53 efficient zero-copy data transfer, as the memory file descriptor may be
54 passed as-is to the destination, without copying the memory in it to
55 the destination process. Not all protocol transports support passing
56 memory file descriptors between participants, in which case this call
57 will automatically fall back to copying. Also, as memory file
58 descriptor passing is inefficient for smaller amounts of data, copying
59 might still be enforced even where memory file descriptor passing is
60 supported.
61
62 The sd_bus_message_append_array_iovec() function appends an array of a
63 trivial type to the message m, similar to
64 sd_bus_message_append_array(). Contents of the I/O vector array iov are
65 used as the contents of the array. The total size of iov payload (the
66 sum of iov_len fields) must be a multiple of the size of the type type.
67 The iov argument must point to n I/O vector structures. Each structure
68 may have the iov_base field set, in which case the memory pointed to
69 will be copied into the message, or unset (set to zero), in which case
70 a block of zeros of length iov_len bytes will be inserted. The memory
71 pointed at by iov may be changed after this call.
72
73 The sd_bus_message_append_array_space() function appends space for an
74 array of a trivial type to message m. It behaves the same as
75 sd_bus_message_append_array(), but instead of copying items to the
76 message, it returns a pointer to the destination area to the caller in
77 pointer p. The caller should subsequently write the array contents to
78 this memory. Modifications to the memory pointed to should only occur
79 until the next operation on the bus message is invoked. Most
80 importantly, the memory should not be altered anymore when another
81 field has been added to the message or the message has been sealed.
82
84 On success, these calls return 0 or a positive integer. On failure,
85 they return a negative errno-style error code.
86
87 Errors
88 Returned errors may indicate the following problems:
89
90 -EINVAL
91 Specified parameter is invalid.
92
93 -EPERM
94 Message has been sealed.
95
96 -ESTALE
97 Message is in invalid state.
98
99 -ENXIO
100 Message cannot be appended to.
101
102 -ENOMEM
103 Memory allocation failed.
104
106 These APIs are implemented as a shared library, which can be compiled
107 and linked to with the libsystemd pkg-config(1) file.
108
110 systemd(1), sd-bus(3), sd_bus_message_append(3),
111 sd_bus_message_append_basic(3), memfd_create(2), The D-Bus
112 specification[2]
113
115 1. Basic Types
116 http://dbus.freedesktop.org/doc/dbus-specification.html#basic-types
117
118 2. The D-Bus specification
119 http://dbus.freedesktop.org/doc/dbus-specification.html
120
121
122
123systemd 250 SD_BUS_MESSAGE_APPEND_ARRAY(3)