]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/sd_bus_track_add_name.xml
copy: only check for traversing mount points on directories
[thirdparty/systemd.git] / man / sd_bus_track_add_name.xml
CommitLineData
ecddb2b5
LP
1<?xml version='1.0'?> <!--*- Mode: nxml; nxml-child-indent: 2; indent-tabs-mode: nil -*-->
2<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
4
5<!--
572eb058
ZJS
6 SPDX-License-Identifier: LGPL-2.1+
7
ecddb2b5
LP
8 This file is part of systemd.
9
10 Copyright 2016 Lennart Poettering
ecddb2b5
LP
11-->
12
7d6b2723 13<refentry id="sd_bus_track_add_name" xmlns:xi="http://www.w3.org/2001/XInclude">
ecddb2b5
LP
14
15 <refentryinfo>
16 <title>sd_bus_track_add_name</title>
17 <productname>systemd</productname>
18
19 <authorgroup>
20 <author>
21 <contrib>Developer</contrib>
22 <firstname>Lennart</firstname>
23 <surname>Poettering</surname>
24 <email>lennart@poettering.net</email>
25 </author>
26 </authorgroup>
27 </refentryinfo>
28
29 <refmeta>
30 <refentrytitle>sd_bus_track_add_name</refentrytitle>
31 <manvolnum>3</manvolnum>
32 </refmeta>
33
34 <refnamediv>
35 <refname>sd_bus_track_add_name</refname>
36 <refname>sd_bus_track_add_sender</refname>
37 <refname>sd_bus_track_remove_name</refname>
38 <refname>sd_bus_track_remove_sender</refname>
39 <refname>sd_bus_track_count</refname>
40 <refname>sd_bus_track_count_sender</refname>
41 <refname>sd_bus_track_count_name</refname>
42 <refname>sd_bus_track_contains</refname>
43 <refname>sd_bus_track_first</refname>
44 <refname>sd_bus_track_next</refname>
45
46 <refpurpose>Add, remove and retrieve bus peers tracked in a bus peer tracking object</refpurpose>
47 </refnamediv>
48
49 <refsynopsisdiv>
50 <funcsynopsis>
51 <funcsynopsisinfo>#include &lt;systemd/sd-bus.h&gt;</funcsynopsisinfo>
52
53 <funcprototype>
54 <funcdef>int <function>sd_bus_track_add_name</function></funcdef>
55 <paramdef>sd_bus_track* <parameter>t</parameter></paramdef>
56 <paramdef>const char* <parameter>name</parameter></paramdef>
57 </funcprototype>
58
59 <funcprototype>
60 <funcdef>int <function>sd_bus_track_add_sender</function></funcdef>
61 <paramdef>sd_bus_track* <parameter>t</parameter></paramdef>
62 <paramdef>sd_bus_message* <parameter>message</parameter></paramdef>
63 </funcprototype>
64
65 <funcprototype>
66 <funcdef>int <function>sd_bus_track_remove_name</function></funcdef>
67 <paramdef>sd_bus_track* <parameter>t</parameter></paramdef>
68 <paramdef>const char* <parameter>name</parameter></paramdef>
69 </funcprototype>
70
71 <funcprototype>
72 <funcdef>int <function>sd_bus_track_remove_sender</function></funcdef>
73 <paramdef>sd_bus_track* <parameter>t</parameter></paramdef>
74 <paramdef>sd_bus_message* <parameter>message</parameter></paramdef>
75 </funcprototype>
76
77 <funcprototype>
78 <funcdef>unsigned <function>sd_bus_track_count</function></funcdef>
79 <paramdef>sd_bus_track* <parameter>t</parameter></paramdef>
80 </funcprototype>
81
82 <funcprototype>
83 <funcdef>int <function>sd_bus_track_count_name</function></funcdef>
84 <paramdef>sd_bus_track* <parameter>t</parameter></paramdef>
85 <paramdef>const char* <parameter>name</parameter></paramdef>
86 </funcprototype>
87
88 <funcprototype>
89 <funcdef>int <function>sd_bus_track_count_sender</function></funcdef>
90 <paramdef>sd_bus_track* <parameter>t</parameter></paramdef>
91 <paramdef>sd_bus_message* <parameter>message</parameter></paramdef>
92 </funcprototype>
93
94 <funcprototype>
95 <funcdef>int <function>sd_bus_track_contains</function></funcdef>
96 <paramdef>sd_bus_track* <parameter>t</parameter></paramdef>
97 <paramdef>const char* <parameter>name</parameter></paramdef>
98 </funcprototype>
99
100 <funcprototype>
101 <funcdef>const char* <function>sd_bus_track_first</function></funcdef>
102 <paramdef>sd_bus_track* <parameter>t</parameter></paramdef>
103 </funcprototype>
104
105 <funcprototype>
106 <funcdef>const char* <function>sd_bus_track_next</function></funcdef>
107 <paramdef>sd_bus_track* <parameter>t</parameter></paramdef>
108 </funcprototype>
109
110 </funcsynopsis>
111 </refsynopsisdiv>
112
113 <refsect1>
114 <title>Description</title>
115
116 <para><function>sd_bus_track_add_name()</function> adds a peer to track to a bus peer tracking object. The first
117 argument should refer to a bus peer tracking object created with
118 <citerefentry><refentrytitle>sd_bus_track_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>, the second
119 name should refer to a D-Bus peer name to track, either in unique or well-known service format. If the name is not
120 tracked yet it will be added to the list of names to track. If it already is being tracked and non-recursive mode
121 is enabled, no operation is executed by this call. If recursive mode is enabled a per-name counter is increased by
122 one each time this call is invoked, and <function>sd_bus_track_remove_name()</function> has to be called as many
123 times as <function>sd_bus_track_add_name()</function> was invoked before in order to stop tracking of the name. Use
124 <citerefentry><refentrytitle>sd_bus_track_set_recursive</refentrytitle><manvolnum>3</manvolnum></citerefentry> to
125 switch from the default non-recursive mode to recursive mode, or back. Note that the specified name is tracked as
126 it is, well-known names are not resolved to unique names by this call. Note that multiple bus peer tracking objects
127 may track the same name.</para>
128
129 <para><function>sd_bus_track_remove_name()</function> undoes the effect of
130 <function>sd_bus_track_add_name()</function> and removes a bus peer name from the list of peers to watch. Depending
131 on whether non-recursive or recursive mode is enabled for the bus peer tracking object this call will either remove
132 the name fully from the tracking object, or will simply decrement the per-name counter by one, removing the name
133 only when the counter reaches zero (see above). Note that a bus peer disconnecting from the bus will implicitly
134 remove its names fully from the bus peer tracking object, regardless of the current per-name counter.</para>
135
136 <para><function>sd_bus_track_add_sender()</function> and <function>sd_bus_track_remove_sender()</function> are
137 similar to <function>sd_bus_track_add_name()</function> and <function>sd_bus_track_remove_name()</function> but
138 take a bus message as argument. The sender of this bus message is determined and added to/removed from the bus peer
139 tracking object. As messages always originate from unique names, and never from well-known names this means that
140 this call will effectively only add unique names to the bus peer tracking object.</para>
141
142 <para><function>sd_bus_track_count()</function> returns the number of names currently being tracked by the
143 specified bus peer tracking object. Note that this function always returns the actual number of names tracked, and
144 hence if <function>sd_bus_track_add_name()</function> has been invoked multiple times for the same name it is only
145 counted as one, regardless if recursive mode is used or not.</para>
146
147 <para><function>sd_bus_track_count_name()</function> returns the current per-name counter for the specified
148 name. If non-recursive mode is used this returns either 1 or 0, depending on whether the specified name has been
149 added to the tracking object before, or not. If recursive mode has been enabled, values larger than 1 may be
150 returned too, in case <function>sd_bus_track_add_name()</function> has been called multiple times for the same
151 name.</para>
152
153 <para><function>sd_bus_track_count_sender()</function> is similar to
154 <function>sd_bus_track_count_name()</function>, but takes a bus message object and returns the per-name counter
155 matching the sender of the message.</para>
156
157 <para><function>sd_bus_track_contains()</function> may be used to determine whether the specified name has been
158 added at least once to the specified bus peer tracking object.</para>
159
160 <para><function>sd_bus_track_first()</function> and <function>sd_bus_track_next()</function> may be used to
161 enumerate all names currently being tracked by the passed bus peer tracking
162 object. <function>sd_bus_track_first()</function> returns the first entry in the object, and resets an internally
163 maintained read index. Each subsequent invocation of <function>sd_bus_track_next()</function> returns the next name
164 contained in the bus object. If the end is reached <constant>NULL</constant> is returned. If no names have been
165 added to the object yet <function>sd_bus_track_first()</function> will return <constant>NULL</constant>
166 immediately. The order in which names are returned is undefined; in particular which name is considered the first
167 returned is not defined. If recursive mode is enabled and the same name has been added multiple times to the bus
168 peer tracking object it is only returned once by this enumeration. If new names are added to or existing names
169 removed from the bus peer tracking object while it is being enumerated the enumeration ends on the next invocation
170 of <function>sd_bus_track_next()</function> as <constant>NULL</constant> is returned.</para>
171 </refsect1>
172
173 <refsect1>
174 <title>Return Value</title>
175
176 <para>On success, <function>sd_bus_track_add_name()</function> and <function>sd_bus_track_add_sender()</function>
177 return 0 if the specified name has already been added to the bus peer tracking object before and positive if it
178 hasn't. On failure, they return a negative errno-style error code.</para>
179
180 <para><function>sd_bus_track_remove_name()</function> and <function>sd_bus_track_remove_sender()</function> return
181 positive if the specified name was previously tracked by the bus peer tracking object and has now been removed. In
182 non-recursive mode, 0 is returned if the specified name was not being tracked yet. In recursive mode
183 <constant>-EUNATCH</constant> is returned in this case. On failure, they return a negative errno-style error
184 code.</para>
185
186 <para><function>sd_bus_track_count()</function> returns the number of names currently being tracked, or 0 on
187 failure.</para>
188
189 <para><function>sd_bus_track_count_name()</function> and <function>sd_bus_track_count_sender()</function> return
190 the current per-name counter for the specified name or the sender of the specified message. Zero is returned for
191 names that are not being tracked yet, a positive value for names added at least once. Larger values than 1 are only
192 returned in recursive mode. On failure, a negative errno-style error code is returned.</para>
193
194 <para><function>sd_bus_track_contains()</function> returns the passed name if it exists in the bus peer tracking
195 object. On failure, and if the name has not been added yet <constant>NULL</constant> is returned.</para>
196
197 <para><function>sd_bus_track_first()</function> and <function>sd_bus_track_next()</function> return the first/next
198 name contained in the bus peer tracking object, and <constant>NULL</constant> if the end of the enumeration is
199 reached and on error.</para>
200 </refsect1>
201
202 <refsect1>
203 <title>Errors</title>
204
205 <para>Returned errors may indicate the following problems:</para>
206
207 <variablelist>
208
209 <varlistentry>
210 <term><constant>-EUNATCH</constant></term>
211
212 <listitem><para><function>sd_bus_track_remove_name()</function> or
213 <function>sd_bus_track_remove_sender()</function> have been invoked for a name not previously added to the bus
214 peer object.</para></listitem>
215 </varlistentry>
216
217 <varlistentry>
218 <term><constant>-EINVAL</constant></term>
219
220 <listitem><para>Specified parameter is invalid.</para></listitem>
221 </varlistentry>
222
223 <varlistentry>
224 <term><constant>-ENOMEM</constant></term>
225
226 <listitem><para>Memory allocation failed.</para></listitem>
227 </varlistentry>
228
229 </variablelist>
230 </refsect1>
231
7d6b2723 232 <xi:include href="libsystemd-pkgconfig.xml" />
ecddb2b5
LP
233
234 <refsect1>
235 <title>See Also</title>
236
237 <para>
238 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
239 <citerefentry><refentrytitle>sd-bus</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
240 <citerefentry><refentrytitle>sd_bus_track_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>
241 </para>
242 </refsect1>
243
244</refentry>