1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
5 <refentry id="kdbus.pool">
8 <title>kdbus.pool</title>
9 <productname>kdbus.pool</productname>
13 <refentrytitle>kdbus.pool</refentrytitle>
14 <manvolnum>7</manvolnum>
18 <refname>kdbus.pool</refname>
19 <refpurpose>kdbus pool</refpurpose>
23 <title>Description</title>
25 A pool for data received from the kernel is installed for every
26 <emphasis>connection</emphasis> of the <emphasis>bus</emphasis>, and
27 is sized according to the information stored in the
28 <varname>pool_size</varname> member of <type>struct kdbus_cmd_hello</type>
29 when <constant>KDBUS_CMD_HELLO</constant> is employed. Internally, the
30 pool is segmented into <emphasis>slices</emphasis>, each referenced by its
31 <emphasis>offset</emphasis> in the pool, expressed in <type>bytes</type>.
34 <refentrytitle>kdbus.connection</refentrytitle>
35 <manvolnum>7</manvolnum>
37 for more information about <constant>KDBUS_CMD_HELLO</constant>.
41 The pool is written to by the kernel when one of the following
42 <emphasis>ioctls</emphasis> is issued:
46 <term><constant>KDBUS_CMD_HELLO</constant></term>
48 ... to receive details about the bus the connection was made to
52 <term><constant>KDBUS_CMD_RECV</constant></term>
54 ... to receive a message
58 <term><constant>KDBUS_CMD_LIST</constant></term>
60 ... to dump the name registry
64 <term><constant>KDBUS_CMD_CONN_INFO</constant></term>
66 ... to retrieve information on a connection
70 <term><constant>KDBUS_CMD_BUS_CREATOR_INFO</constant></term>
72 ... to retrieve information about a connection's bus creator
79 The <varname>offset</varname> fields returned by either one of the
80 aforementioned ioctls describe offsets inside the pool. In order to make
81 the slice available for subsequent calls,
82 <constant>KDBUS_CMD_FREE</constant> has to be called on that offset
83 (see below). Otherwise, the pool will fill up, and the connection won't
84 be able to receive any more information through its pool.
89 <title>Pool slice allocation</title>
91 Pool slices are allocated by the kernel in order to report information
92 back to a task, such as messages, returned name list etc.
93 Allocation of pool slices cannot be initiated by userspace. See
95 <refentrytitle>kdbus.connection</refentrytitle>
96 <manvolnum>7</manvolnum>
100 <refentrytitle>kdbus.name</refentrytitle>
101 <manvolnum>7</manvolnum>
103 for examples of commands that use the <emphasis>pool</emphasis> to
109 <title>Accessing the pool memory</title>
111 Memory in the pool is read-only for userspace and may only be written
112 to by the kernel. To read from the pool memory, the caller is expected to
114 <refentrytitle>mmap</refentrytitle>
115 <manvolnum>2</manvolnum>
117 the buffer into its task, like this:
120 uint8_t *buf = mmap(NULL, size, PROT_READ, MAP_SHARED, conn_fd, 0);
124 In order to map the entire pool, the <varname>size</varname> parameter in
125 the example above should be set to the value of the
126 <varname>pool_size</varname> member of
127 <type>struct kdbus_cmd_hello</type> when
128 <constant>KDBUS_CMD_HELLO</constant> was employed to create the
129 connection (see above).
133 The <emphasis>file descriptor</emphasis> used to map the memory must be
134 the one that was used to create the <emphasis>connection</emphasis>.
135 In other words, the one that was used to call
136 <constant>KDBUS_CMD_HELLO</constant>. See
138 <refentrytitle>kdbus.connection</refentrytitle>
139 <manvolnum>7</manvolnum>
145 Alternatively, instead of mapping the entire pool buffer, only parts
146 of it can be mapped. Every kdbus command that returns an
147 <emphasis>offset</emphasis> (see above) also reports a
148 <emphasis>size</emphasis> along with it, so programs can be written
149 in a way that it only maps portions of the pool to access a specific
150 <emphasis>slice</emphasis>.
154 When access to the pool memory is no longer needed, programs should
155 call <function>munmap()</function> on the pointer returned by
156 <function>mmap()</function>.
161 <title>Freeing pool slices</title>
163 The <constant>KDBUS_CMD_FREE</constant> ioctl is used to free a slice
164 inside the pool, describing an offset that was returned in an
165 <varname>offset</varname> field of another ioctl struct.
166 The <constant>KDBUS_CMD_FREE</constant> command takes a
167 <type>struct kdbus_cmd_free</type> as argument.
171 struct kdbus_cmd_free {
176 struct kdbus_item items[0];
180 <para>The fields in this struct are described below.</para>
184 <term><varname>size</varname></term>
186 The overall size of the struct, including its items.
191 <term><varname>flags</varname></term>
194 <constant>KDBUS_FLAG_NEGOTIATE</constant> is accepted to probe for
195 valid flags. If set, the ioctl will return <errorcode>0</errorcode>,
196 and the <varname>flags</varname> field is set to
197 <constant>0</constant>.
202 <term><varname>return_flags</varname></term>
204 Flags returned by the kernel. Currently unused and always set to
205 <constant>0</constant> by the kernel.
210 <term><varname>offset</varname></term>
212 The offset to free, as returned by other ioctls that allocated
213 memory for returned information.
218 <term><varname>items</varname></term>
220 Items to specify further details for the receive command.
222 Unrecognized items are rejected, and the ioctl will fail with
223 <varname>errno</varname> set to <constant>EINVAL</constant>.
225 <constant>KDBUS_ITEM_NEGOTIATE</constant> (see
227 <refentrytitle>kdbus.item</refentrytitle>
228 <manvolnum>7</manvolnum>
237 <title>Return value</title>
239 On success, all mentioned ioctl commands return <errorcode>0</errorcode>;
240 on error, <errorcode>-1</errorcode> is returned, and
241 <varname>errno</varname> is set to indicate the error.
242 If the issued ioctl is illegal for the file descriptor used,
243 <varname>errno</varname> will be set to <constant>ENOTTY</constant>.
248 <constant>KDBUS_CMD_FREE</constant> may fail with the following
254 <term><constant>ENXIO</constant></term>
256 No pool slice found at given offset.
261 <term><constant>EINVAL</constant></term>
263 Invalid flags provided.
268 <term><constant>EINVAL</constant></term>
270 The offset is valid, but the user is not allowed to free the slice.
271 This happens, for example, if the offset was retrieved with
272 <constant>KDBUS_RECV_PEEK</constant>.
280 <title>See Also</title>
281 <simplelist type="inline">
284 <refentrytitle>kdbus</refentrytitle>
285 <manvolnum>7</manvolnum>
290 <refentrytitle>kdbus.bus</refentrytitle>
291 <manvolnum>7</manvolnum>
296 <refentrytitle>kdbus.connection</refentrytitle>
297 <manvolnum>7</manvolnum>
302 <refentrytitle>kdbus.endpoint</refentrytitle>
303 <manvolnum>7</manvolnum>
308 <refentrytitle>kdbus.name</refentrytitle>
309 <manvolnum>7</manvolnum>
314 <refentrytitle>mmap</refentrytitle>
315 <manvolnum>2</manvolnum>
320 <refentrytitle>munmap</refentrytitle>
321 <manvolnum>2</manvolnum>