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.name">
8 <title>kdbus.name</title>
9 <productname>kdbus.name</productname>
13 <refentrytitle>kdbus.name</refentrytitle>
14 <manvolnum>7</manvolnum>
18 <refname>kdbus.name</refname>
19 <refpurpose>kdbus.name</refpurpose>
23 <title>Description</title>
27 <refentrytitle>kdbus.bus</refentrytitle>
28 <manvolnum>7</manvolnum>
30 instantiates a name registry to resolve well-known names into unique
31 connection IDs for message delivery. The registry will be queried when a
32 message is sent with <varname>kdbus_msg.dst_id</varname> set to
33 <constant>KDBUS_DST_ID_NAME</constant>, or when a registry dump is
34 requested with <constant>KDBUS_CMD_NAME_LIST</constant>.
38 All of the below is subject to policy rules for <emphasis>SEE</emphasis>
39 and <emphasis>OWN</emphasis> permissions. See
41 <refentrytitle>kdbus.policy</refentrytitle>
42 <manvolnum>7</manvolnum>
49 <title>Name validity</title>
51 A name has to comply with the following rules in order to be considered
58 The name has two or more elements separated by a
59 '<literal>.</literal>' (period) character.
64 All elements must contain at least one character.
69 Each element must only contain the ASCII characters
70 <literal>[A-Z][a-z][0-9]_</literal> and must not begin with a
76 The name must contain at least one '<literal>.</literal>' (period)
77 character (and thus at least two elements).
82 The name must not begin with a '<literal>.</literal>' (period)
88 The name must not exceed <constant>255</constant> characters in
96 <title>Acquiring a name</title>
98 To acquire a name, a client uses the
99 <constant>KDBUS_CMD_NAME_ACQUIRE</constant> ioctl with
100 <type>struct kdbus_cmd</type> as argument.
108 struct kdbus_item items[0];
112 <para>The fields in this struct are described below.</para>
116 <term><varname>size</varname></term>
118 The overall size of the struct, including its items.
123 <term><varname>flags</varname></term>
124 <listitem><para>Flags to control details in the name acquisition.</para>
127 <term><constant>KDBUS_NAME_REPLACE_EXISTING</constant></term>
130 Acquiring a name that is already present usually fails,
131 unless this flag is set in the call, and
132 <constant>KDBUS_NAME_ALLOW_REPLACEMENT</constant> (see below)
133 was set when the current owner of the name acquired it, or
134 if the current owner is an activator connection (see
136 <refentrytitle>kdbus.connection</refentrytitle>
137 <manvolnum>7</manvolnum>
144 <term><constant>KDBUS_NAME_ALLOW_REPLACEMENT</constant></term>
147 Allow other connections to take over this name. When this
148 happens, the former owner of the connection will be notified
155 <term><constant>KDBUS_NAME_QUEUE</constant></term>
158 A name that is already acquired by a connection can not be
159 acquired again (unless the
160 <constant>KDBUS_NAME_ALLOW_REPLACEMENT</constant> flag was
161 set during acquisition; see above).
162 However, a connection can put itself in a queue of
163 connections waiting for the name to be released. Once that
164 happens, the first connection in that queue becomes the new
165 owner and is notified accordingly.
171 <term><constant>KDBUS_FLAG_NEGOTIATE</constant></term>
174 Request a set of valid flags for this ioctl. When this bit is
175 set, no action is taken; the ioctl will fail with
176 <errorcode>-1</errorcode>, and <varname>errno</varname>
177 is set to <constant>EPROTO</constant>.
178 Once the ioctl returned, the <varname>flags</varname>
179 field will have all bits set that the kernel recognizes as
180 valid for this command.
181 The <constant>KDBUS_FLAG_NEGOTIATE</constant> bit will be
182 cleared by the operation.
191 <term><varname>return_flags</varname></term>
194 Flags returned by the kernel. Currently, the following may be
195 returned by the kernel.
199 <term><constant>KDBUS_NAME_IN_QUEUE</constant></term>
202 The name was not acquired yet, but the connection was
203 placed in the queue of peers waiting for the name.
204 This can only happen if <constant>KDBUS_NAME_QUEUE</constant>
205 was set in the <varname>flags</varname> member (see above).
206 The connection will receive a name owner change notification
207 once the current owner has given up the name and its
208 ownership was transferred.
217 <term><varname>items</varname></term>
220 Items to submit the name. Currently, one item of type
221 <constant>KDBUS_ITEM_NAME</constant> is expected and allowed, and
222 the contained string must be a valid bus name.
223 <constant>KDBUS_ITEM_NEGOTIATE</constant> may be used to probe for
224 valid item types. See
226 <refentrytitle>kdbus.item</refentrytitle>
227 <manvolnum>7</manvolnum>
229 for a detailed description of how this item is used.
232 Unrecognized items are rejected, and the ioctl will fail with
233 <varname>errno</varname> set to <errorname>>EINVAL</errorname>.
241 <title>Releasing a name</title>
243 A connection may release a name explicitly with the
244 <constant>KDBUS_CMD_NAME_RELEASE</constant> ioctl. If the connection was
245 an implementer of an activatable name, its pending messages are moved
246 back to the activator. If there are any connections queued up as waiters
247 for the name, the first one in the queue (the oldest entry) will become
248 the new owner. The same happens implicitly for all names once a
249 connection terminates. See
251 <refentrytitle>kdbus.connection</refentrytitle>
252 <manvolnum>7</manvolnum>
254 for more information on connections.
257 The <constant>KDBUS_CMD_NAME_RELEASE</constant> ioctl uses the same data
258 structure as the acquisition call
259 (<constant>KDBUS_CMD_NAME_ACQUIRE</constant>),
260 but with slightly different field usage.
268 struct kdbus_item items[0];
272 <para>The fields in this struct are described below.</para>
276 <term><varname>size</varname></term>
278 The overall size of the struct, including its items.
283 <term><varname>flags</varname></term>
285 Flags to the command. Currently unused.
286 <constant>KDBUS_FLAG_NEGOTIATE</constant> is accepted to probe for
287 valid flags. If set, the ioctl will return <errorcode>0</errorcode>,
288 and the <varname>flags</varname> field is set to
289 <constant>0</constant>.
294 <term><varname>return_flags</varname></term>
296 Flags returned by the kernel. Currently unused and always set to
297 <constant>0</constant> by the kernel.
302 <term><varname>items</varname></term>
305 Items to submit the name. Currently, one item of type
306 <constant>KDBUS_ITEM_NAME</constant> is expected and allowed, and
307 the contained string must be a valid bus name.
308 <constant>KDBUS_ITEM_NEGOTIATE</constant> may be used to probe for
309 valid item types. See
311 <refentrytitle>kdbus.item</refentrytitle>
312 <manvolnum>7</manvolnum>
314 for a detailed description of how this item is used.
317 Unrecognized items are rejected, and the ioctl will fail with
318 <varname>errno</varname> set to <constant>EINVAL</constant>.
326 <title>Dumping the name registry</title>
328 A connection may request a complete or filtered dump of currently active
329 bus names with the <constant>KDBUS_CMD_LIST</constant> ioctl, which
330 takes a <type>struct kdbus_cmd_list</type> as argument.
334 struct kdbus_cmd_list {
341 <para>The fields in this struct are described below.</para>
345 <term><varname>flags</varname></term>
348 Any combination of flags to specify which names should be dumped.
352 <term><constant>KDBUS_LIST_UNIQUE</constant></term>
355 List the unique (numeric) IDs of the connection, whether it
362 <term><constant>KDBUS_LIST_NAMES</constant></term>
365 List well-known names stored in the database which are
366 actively owned by a real connection (not an activator).
372 <term><constant>KDBUS_LIST_ACTIVATORS</constant></term>
375 List names that are owned by an activator.
381 <term><constant>KDBUS_LIST_QUEUED</constant></term>
384 List connections that are not yet owning a name but are
385 waiting for it to become available.
391 <term><constant>KDBUS_FLAG_NEGOTIATE</constant></term>
394 Request a set of valid flags for this ioctl. When this bit is
395 set, no action is taken; the ioctl will fail with
396 <errorcode>-1</errorcode>, and <varname>errno</varname>
397 is set to <constant>EPROTO</constant>.
398 Once the ioctl returned, the <varname>flags</varname>
399 field will have all bits set that the kernel recognizes as
400 valid for this command.
401 The <constant>KDBUS_FLAG_NEGOTIATE</constant> bit will be
402 cleared by the operation.
411 <term><varname>return_flags</varname></term>
413 Flags returned by the kernel. Currently unused and always set to
414 <constant>0</constant> by the kernel.
419 <term><varname>offset</varname></term>
421 When the ioctl returns successfully, the offset to the name registry
422 dump inside the connection's pool will be stored in this field.
428 The returned list of names is stored in a <type>struct kdbus_list</type>
429 that in turn contains an array of type <type>struct kdbus_info</type>,
430 The array-size in bytes is given as <varname>list_size</varname>.
431 The fields inside <type>struct kdbus_info</type> is described next.
439 struct kdbus_item items[0];
443 <para>The fields in this struct are described below.</para>
447 <term><varname>size</varname></term>
449 The overall size of the struct, including its items.
454 <term><varname>id</varname></term>
456 The owning connection's unique ID.
461 <term><varname>flags</varname></term>
463 The flags of the owning connection.
468 <term><varname>items</varname></term>
471 Items containing the actual name. Currently, one item of type
472 <constant>KDBUS_ITEM_OWNED_NAME</constant> will be attached,
473 including the name's flags. In that item, the flags field of the
474 name may carry the following bits:
478 <term><constant>KDBUS_NAME_ALLOW_REPLACEMENT</constant></term>
481 Other connections are allowed to take over this name from the
482 connection that owns it.
488 <term><constant>KDBUS_NAME_IN_QUEUE</constant></term>
491 When retrieving a list of currently acquired names in the
492 registry, this flag indicates whether the connection
493 actually owns the name or is currently waiting for it to
500 <term><constant>KDBUS_NAME_ACTIVATOR</constant></term>
503 An activator connection owns a name as a placeholder for an
504 implementer, which is started on demand by programs as soon
505 as the first message arrives. There's some more information
508 <refentrytitle>kdbus.connection</refentrytitle>
509 <manvolnum>7</manvolnum>
515 <constant>KDBUS_NAME_REPLACE_EXISTING</constant>,
516 when a name is taken over from an activator connection, all
517 the messages that have been queued in the activator
518 connection will be moved over to the new owner. The activator
519 connection will still be tracked for the name and will take
520 control again if the implementer connection terminates.
523 This flag can not be used when acquiring a name, but is
524 implicitly set through <constant>KDBUS_CMD_HELLO</constant>
525 with <constant>KDBUS_HELLO_ACTIVATOR</constant> set in
526 <varname>kdbus_cmd_hello.conn_flags</varname>.
532 <term><constant>KDBUS_FLAG_NEGOTIATE</constant></term>
535 Requests a set of valid flags for this ioctl. When this bit is
536 set, no action is taken; the ioctl will return
537 <errorcode>0</errorcode>, and the <varname>flags</varname>
538 field will have all bits set that are valid for this command.
539 The <constant>KDBUS_FLAG_NEGOTIATE</constant> bit will be
540 cleared by the operation.
550 The returned buffer must be freed with the
551 <constant>KDBUS_CMD_FREE</constant> ioctl when the user is finished with
554 <refentrytitle>kdbus.pool</refentrytitle>
555 <manvolnum>7</manvolnum>
557 for more information.
562 <title>Return value</title>
564 On success, all mentioned ioctl commands return <errorcode>0</errorcode>;
565 on error, <errorcode>-1</errorcode> is returned, and
566 <varname>errno</varname> is set to indicate the error.
567 If the issued ioctl is illegal for the file descriptor used,
568 <varname>errno</varname> will be set to <constant>ENOTTY</constant>.
573 <constant>KDBUS_CMD_NAME_ACQUIRE</constant> may fail with the following
579 <term><constant>EINVAL</constant></term>
581 Illegal command flags, illegal name provided, or an activator
582 tried to acquire a second name.
587 <term><constant>EPERM</constant></term>
589 Policy prohibited name ownership.
594 <term><constant>EALREADY</constant></term>
596 Connection already owns that name.
601 <term><constant>EEXIST</constant></term>
603 The name already exists and can not be taken over.
608 <term><constant>E2BIG</constant></term>
610 The maximum number of well-known names per connection is exhausted.
618 <constant>KDBUS_CMD_NAME_RELEASE</constant>
619 may fail with the following errors
624 <term><constant>EINVAL</constant></term>
626 Invalid command flags, or invalid name provided.
631 <term><constant>ESRCH</constant></term>
633 Name is not found in the registry.
638 <term><constant>EADDRINUSE</constant></term>
640 Name is owned by a different connection and can't be released.
648 <constant>KDBUS_CMD_LIST</constant> may fail with the following
654 <term><constant>EINVAL</constant></term>
656 Invalid command flags
661 <term><constant>ENOBUFS</constant></term>
663 No available memory in the connection's pool.
671 <title>See Also</title>
672 <simplelist type="inline">
675 <refentrytitle>kdbus</refentrytitle>
676 <manvolnum>7</manvolnum>
681 <refentrytitle>kdbus.bus</refentrytitle>
682 <manvolnum>7</manvolnum>
687 <refentrytitle>kdbus.connection</refentrytitle>
688 <manvolnum>7</manvolnum>
693 <refentrytitle>kdbus.item</refentrytitle>
694 <manvolnum>7</manvolnum>
699 <refentrytitle>kdbus.policy</refentrytitle>
700 <manvolnum>7</manvolnum>
705 <refentrytitle>kdbus.pool</refentrytitle>
706 <manvolnum>7</manvolnum>