Debian Codegraph @

man/sd_varlink_push_fd.xml

raw
1 <?xml version='1.0'?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
5
6 <refentry id="sd_varlink_push_fd" xmlns:xi="http://www.w3.org/2001/XInclude">
7
8 <refentryinfo>
9 <title>sd_varlink_push_fd</title>
10 <productname>systemd</productname>
11 </refentryinfo>
12
13 <refmeta>
14 <refentrytitle>sd_varlink_push_fd</refentrytitle>
15 <manvolnum>3</manvolnum>
16 </refmeta>
17
18 <refnamediv>
19 <refname>sd_varlink_push_fd</refname>
20 <refname>sd_varlink_push_dup_fd</refname>
21
22 <refpurpose>Submit a file descriptor to send along with the next outgoing Varlink message</refpurpose>
23 </refnamediv>
24
25 <refsynopsisdiv>
26 <funcsynopsis>
27 <funcsynopsisinfo>#include &lt;systemd/sd-varlink.h&gt;</funcsynopsisinfo>
28
29 <funcprototype>
30 <funcdef>int <function>sd_varlink_push_fd</function></funcdef>
31 <paramdef>sd_varlink *<parameter>link</parameter></paramdef>
32 <paramdef>int <parameter>fd</parameter></paramdef>
33 </funcprototype>
34
35 <funcprototype>
36 <funcdef>int <function>sd_varlink_push_dup_fd</function></funcdef>
37 <paramdef>sd_varlink *<parameter>link</parameter></paramdef>
38 <paramdef>int <parameter>fd</parameter></paramdef>
39 </funcprototype>
40 </funcsynopsis>
41 </refsynopsisdiv>
42
43 <refsect1>
44 <title>Description</title>
45
46 <para><function>sd_varlink_push_fd()</function> submits a file descriptor to send along with the next
47 outgoing Varlink message. Takes a Varlink connection object and a file descriptor as parameter. The file
48 descriptor is not duplicated, and hence ownership of the file descriptor is passed to the Varlink
49 connection object (only on success; on failure the caller retains ownership). Once the file descriptor
50 has been written to the underlying transport socket it is automatically closed. The calling application
51 code should not touch the file descriptor or close it on its own, otherwise it will interfere with the
52 Varlink protocol implementation. This call is only supported if the backing transport supports file
53 descriptor passing (effectively this means the functionality is supported on local
54 <constant>AF_UNIX</constant> only), and the concept is not part of the Varlink protocol, but simply a
55 feature of the underlying transport.</para>
56
57 <para><function>sd_varlink_push_dup_fd()</function> is identical to
58 <function>sd_varlink_push_fd()</function>, except that the file descriptor is duplicated automatically,
59 and the calling application code hence retains ownership of the provided file descriptor, and must close
60 it on its own.</para>
61
62 <para>Note that file descriptor passing is only permitted after a call to
63 <function>sd_varlink_set_allow_fd_passing_output()</function> that enables it, otherwise these calls will
64 fail with <constant>-EPERM</constant>.</para>
65
66 <para>Note that on Linux a maximum of 253 file descriptors may be enqueued on
67 <constant>AF_UNIX</constant> sockets at once. Attempting to enqueue more on a single Varlink message will
68 fail with <constant>-ENOBUFS</constant>.</para>
69 </refsect1>
70
71 <refsect1>
72 <title>Return Value</title>
73
74 <para>On success, <function>sd_varlink_push_fd()</function> and
75 <function>sd_varlink_push_dup_fd()</function> return a non-negative integer. On failure, they return a
76 negative errno-style error code. </para>
77
78 <refsect2>
79 <title>Errors</title>
80
81 <para>Returned errors may indicate the following problems:</para>
82
83 <variablelist>
84 <varlistentry>
85 <term><constant>-EINVAL</constant></term>
86
87 <listitem><para>An argument is invalid.</para></listitem>
88 </varlistentry>
89
90 <varlistentry>
91 <term><constant>-EBADF</constant></term>
92
93 <listitem><para>The provided file descriptor is not valid.</para></listitem>
94 </varlistentry>
95
96 <varlistentry>
97 <term><constant>-EPERM</constant></term>
98
99 <listitem><para>File descriptor passing has not been enabled via
100 <function>sd_varlink_set_allow_fd_passing_output()</function>.</para></listitem>
101 </varlistentry>
102
103 <varlistentry>
104 <term><constant>-ENOBUFS</constant></term>
105
106 <listitem><para>The maximum of 253 file descriptors have already been submitted for the next
107 outgoing Varlink message, no further descriptors may be enqueued for this message.</para></listitem>
108 </varlistentry>
109
110 <varlistentry>
111 <term><constant>-ENOMEM</constant></term>
112
113 <listitem><para>Memory allocation failed.</para></listitem>
114 </varlistentry>
115 </variablelist>
116 </refsect2>
117 </refsect1>
118
119 <xi:include href="libsystemd-pkgconfig.xml" />
120
121 <refsect1>
122 <title>History</title>
123 <para><function>sd_varlink_push_fd()</function> and <function>sd_varlink_push_dup_fd()</function> were added in version 257.</para>
124 </refsect1>
125
126 <refsect1>
127 <title>See Also</title>
128
129 <para><simplelist type="inline">
130 <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
131 <member><citerefentry><refentrytitle>sd-varlink</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
132 </simplelist></para>
133 </refsect1>
134 </refentry>