chiark / gitweb /
tree-wide: remove Lennart's copyright lines
[elogind.git] / man / sd_is_fifo.xml
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">
4
5 <!--
6   SPDX-License-Identifier: LGPL-2.1+
7 -->
8
9 <refentry id="sd_is_fifo"
10   xmlns:xi="http://www.w3.org/2001/XInclude">
11
12   <refentryinfo>
13     <title>sd_is_fifo</title>
14     <productname>systemd</productname>
15
16     <authorgroup>
17       <author>
18         <contrib>Developer</contrib>
19         <firstname>Lennart</firstname>
20         <surname>Poettering</surname>
21         <email>lennart@poettering.net</email>
22       </author>
23     </authorgroup>
24   </refentryinfo>
25
26   <refmeta>
27     <refentrytitle>sd_is_fifo</refentrytitle>
28     <manvolnum>3</manvolnum>
29   </refmeta>
30
31   <refnamediv>
32     <refname>sd_is_fifo</refname>
33     <refname>sd_is_socket</refname>
34     <refname>sd_is_socket_inet</refname>
35     <refname>sd_is_socket_unix</refname>
36     <refname>sd_is_socket_sockaddr</refname>
37     <refname>sd_is_mq</refname>
38     <refname>sd_is_special</refname>
39     <refpurpose>Check the type of a file descriptor</refpurpose>
40   </refnamediv>
41
42   <refsynopsisdiv>
43     <funcsynopsis>
44       <funcsynopsisinfo>#include &lt;systemd/sd-daemon.h&gt;</funcsynopsisinfo>
45
46       <funcprototype>
47         <funcdef>int <function>sd_is_fifo</function></funcdef>
48         <paramdef>int <parameter>fd</parameter></paramdef>
49         <paramdef>const char *<parameter>path</parameter></paramdef>
50       </funcprototype>
51
52       <funcprototype>
53         <funcdef>int <function>sd_is_socket</function></funcdef>
54         <paramdef>int <parameter>fd</parameter></paramdef>
55         <paramdef>int <parameter>family</parameter></paramdef>
56         <paramdef>int <parameter>type</parameter></paramdef>
57         <paramdef>int <parameter>listening</parameter></paramdef>
58       </funcprototype>
59
60       <funcprototype>
61         <funcdef>int <function>sd_is_socket_inet</function></funcdef>
62         <paramdef>int <parameter>fd</parameter></paramdef>
63         <paramdef>int <parameter>family</parameter></paramdef>
64         <paramdef>int <parameter>type</parameter></paramdef>
65         <paramdef>int <parameter>listening</parameter></paramdef>
66         <paramdef>uint16_t <parameter>port</parameter></paramdef>
67       </funcprototype>
68
69       <funcprototype>
70         <funcdef>int <function>sd_is_socket_sockaddr</function></funcdef>
71         <paramdef>int <parameter>fd</parameter></paramdef>
72         <paramdef>int <parameter>type</parameter></paramdef>
73         <paramdef>const struct sockaddr *<parameter>addr</parameter></paramdef>
74         <paramdef>unsigned <parameter>addr_len</parameter></paramdef>
75         <paramdef>int <parameter>listening</parameter></paramdef>
76       </funcprototype>
77
78       <funcprototype>
79         <funcdef>int <function>sd_is_socket_unix</function></funcdef>
80         <paramdef>int <parameter>fd</parameter></paramdef>
81         <paramdef>int <parameter>type</parameter></paramdef>
82         <paramdef>int <parameter>listening</parameter></paramdef>
83         <paramdef>const char *<parameter>path</parameter></paramdef>
84         <paramdef>size_t <parameter>length</parameter></paramdef>
85       </funcprototype>
86
87       <funcprototype>
88         <funcdef>int <function>sd_is_mq</function></funcdef>
89         <paramdef>int <parameter>fd</parameter></paramdef>
90         <paramdef>const char *<parameter>path</parameter></paramdef>
91       </funcprototype>
92
93       <funcprototype>
94         <funcdef>int <function>sd_is_special</function></funcdef>
95         <paramdef>int <parameter>fd</parameter></paramdef>
96         <paramdef>const char *<parameter>path</parameter></paramdef>
97       </funcprototype>
98
99     </funcsynopsis>
100   </refsynopsisdiv>
101
102   <refsect1>
103     <title>Description</title>
104
105     <para><function>sd_is_fifo()</function> may be called to check
106     whether the specified file descriptor refers to a FIFO or pipe. If
107     the <parameter>path</parameter> parameter is not
108     <constant>NULL</constant>, it is checked whether the FIFO is bound
109     to the specified file system path.</para>
110
111     <para><function>sd_is_socket()</function> may be called to check
112     whether the specified file descriptor refers to a socket. If the
113     <parameter>family</parameter> parameter is not
114     <constant>AF_UNSPEC</constant>, it is checked whether the socket
115     is of the specified family (<constant>AF_UNIX</constant>,
116     <constant>AF_INET</constant>, …). If the <parameter>type</parameter>
117     parameter is not 0, it is checked whether the socket is of the
118     specified type (<constant>SOCK_STREAM</constant>,
119     <constant>SOCK_DGRAM</constant>, …). If the
120     <parameter>listening</parameter> parameter is positive, it is
121     checked whether the socket is in accepting mode, i.e.
122     <function>listen()</function> has been called for it. If
123     <parameter>listening</parameter> is 0, it is checked whether the
124     socket is not in this mode. If the parameter is negative, no such
125     check is made. The <parameter>listening</parameter> parameter
126     should only be used for stream sockets and should be set to a
127     negative value otherwise.</para>
128
129     <para><function>sd_is_socket_inet()</function> is similar to
130     <function>sd_is_socket()</function>, but optionally checks the
131     IPv4 or IPv6 port number the socket is bound to, unless
132     <parameter>port</parameter> is zero. For this call
133     <parameter>family</parameter> must be passed as either
134     <constant>AF_UNSPEC</constant>, <constant>AF_INET</constant>, or
135     <constant>AF_INET6</constant>.</para>
136
137     <para><function>sd_is_socket_sockaddr()</function> is similar to
138     <function>sd_is_socket_inet()</function>, but checks if the socket is bound to the
139     address specified by <parameter>addr</parameter>. The
140     <structfield>family</structfield> specified by <parameter>addr</parameter> must be
141     either <constant>AF_INET</constant> or <constant>AF_INET6</constant> and
142     <parameter>addr_len</parameter> must be large enough for that family. If
143     <parameter>addr</parameter> specifies a non-zero port, it is also checked if the
144     socket is bound to this port. In addition, for IPv6, if <parameter>addr</parameter>
145     specifies non-zero <structfield>sin6_flowinfo</structfield> or
146     <structfield>sin6_scope_id</structfield>, it is checked if the socket has the same
147     values.</para>
148
149     <para><function>sd_is_socket_unix()</function> is similar to
150     <function>sd_is_socket()</function> but optionally checks the
151     <constant>AF_UNIX</constant> path the socket is bound to, unless
152     the <parameter>path</parameter> parameter is
153     <constant>NULL</constant>. For normal file system
154     <constant>AF_UNIX</constant> sockets, set the
155     <parameter>length</parameter> parameter to 0. For Linux abstract
156     namespace sockets, set the <parameter>length</parameter> to the
157     size of the address, including the initial 0 byte, and set the
158     <parameter>path</parameter> to the initial 0 byte of the socket
159     address.</para>
160
161     <para><function>sd_is_mq()</function> may be called to check
162     whether the specified file descriptor refers to a POSIX message
163     queue. If the <parameter>path</parameter> parameter is not
164     <constant>NULL</constant>, it is checked whether the message queue
165     is bound to the specified name.</para>
166
167     <para><function>sd_is_special()</function> may be called to check
168     whether the specified file descriptor refers to a special file. If
169     the <parameter>path</parameter> parameter is not
170     <constant>NULL</constant>, it is checked whether the file
171     descriptor is bound to the specified filename. Special files in
172     this context are character device nodes and files in
173     <filename>/proc</filename> or <filename>/sys</filename>.</para>
174   </refsect1>
175
176   <refsect1>
177     <title>Return Value</title>
178
179     <para>On failure, these calls return a negative errno-style error
180     code. If the file descriptor is of the specified type and bound to
181     the specified address, a positive return value is returned,
182     otherwise zero.</para>
183   </refsect1>
184
185   <refsect1>
186     <title>Notes</title>
187
188     <xi:include href="libelogind-pkgconfig.xml" xpointer="pkgconfig-text"/>
189
190     <para>Internally, these function use a combination of
191     <filename>fstat()</filename> and
192     <filename>getsockname()</filename> to check the file descriptor
193     type and where it is bound to.</para>
194   </refsect1>
195
196   <refsect1>
197     <title>See Also</title>
198     <para>
199       <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
200       <citerefentry><refentrytitle>sd-daemon</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
201       <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
202       <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
203       <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
204       <citerefentry project='man-pages'><refentrytitle>ip</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
205       <citerefentry project='man-pages'><refentrytitle>ipv6</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
206       <citerefentry project='man-pages'><refentrytitle>unix</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
207       <citerefentry project='man-pages'><refentrytitle>fifo</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
208       <citerefentry project='man-pages'><refentrytitle>mq_overview</refentrytitle><manvolnum>7</manvolnum></citerefentry>,
209       <citerefentry project='man-pages'><refentrytitle>socket</refentrytitle><manvolnum>7</manvolnum></citerefentry>.
210     </para>
211   </refsect1>
212
213 </refentry>