chiark / gitweb /
networkd: support route scopes
[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   This file is part of systemd.
7
8   Copyright 2010 Lennart Poettering
9
10   systemd is free software; you can redistribute it and/or modify it
11   under the terms of the GNU Lesser General Public License as published by
12   the Free Software Foundation; either version 2.1 of the License, or
13   (at your option) any later version.
14
15   systemd is distributed in the hope that it will be useful, but
16   WITHOUT ANY WARRANTY; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18   Lesser General Public License for more details.
19
20   You should have received a copy of the GNU Lesser General Public License
21   along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 -->
23
24 <refentry id="sd_is_fifo"
25   xmlns:xi="http://www.w3.org/2001/XInclude">
26
27   <refentryinfo>
28     <title>sd_is_fifo</title>
29     <productname>systemd</productname>
30
31     <authorgroup>
32       <author>
33         <contrib>Developer</contrib>
34         <firstname>Lennart</firstname>
35         <surname>Poettering</surname>
36         <email>lennart@poettering.net</email>
37       </author>
38     </authorgroup>
39   </refentryinfo>
40
41   <refmeta>
42     <refentrytitle>sd_is_fifo</refentrytitle>
43     <manvolnum>3</manvolnum>
44   </refmeta>
45
46   <refnamediv>
47     <refname>sd_is_fifo</refname>
48     <refname>sd_is_socket</refname>
49     <refname>sd_is_socket_inet</refname>
50     <refname>sd_is_socket_unix</refname>
51     <refname>sd_is_mq</refname>
52     <refname>sd_is_special</refname>
53     <refpurpose>Check the type of a file descriptor</refpurpose>
54   </refnamediv>
55
56   <refsynopsisdiv>
57     <funcsynopsis>
58       <funcsynopsisinfo>#include &lt;systemd/sd-daemon.h&gt;</funcsynopsisinfo>
59
60       <funcprototype>
61         <funcdef>int <function>sd_is_fifo</function></funcdef>
62         <paramdef>int <parameter>fd</parameter></paramdef>
63         <paramdef>const char *<parameter>path</parameter></paramdef>
64       </funcprototype>
65
66       <funcprototype>
67         <funcdef>int <function>sd_is_socket</function></funcdef>
68         <paramdef>int <parameter>fd</parameter></paramdef>
69         <paramdef>int <parameter>family</parameter></paramdef>
70         <paramdef>int <parameter>type</parameter></paramdef>
71         <paramdef>int <parameter>listening</parameter></paramdef>
72       </funcprototype>
73
74       <funcprototype>
75         <funcdef>int <function>sd_is_socket_inet</function></funcdef>
76         <paramdef>int <parameter>fd</parameter></paramdef>
77         <paramdef>int <parameter>family</parameter></paramdef>
78         <paramdef>int <parameter>type</parameter></paramdef>
79         <paramdef>int <parameter>listening</parameter></paramdef>
80         <paramdef>uint16_t <parameter>port</parameter></paramdef>
81       </funcprototype>
82
83       <funcprototype>
84         <funcdef>int <function>sd_is_socket_unix</function></funcdef>
85         <paramdef>int <parameter>fd</parameter></paramdef>
86         <paramdef>int <parameter>type</parameter></paramdef>
87         <paramdef>int <parameter>listening</parameter></paramdef>
88         <paramdef>const char *<parameter>path</parameter></paramdef>
89         <paramdef>size_t <parameter>length</parameter></paramdef>
90       </funcprototype>
91
92       <funcprototype>
93         <funcdef>int <function>sd_is_mq</function></funcdef>
94         <paramdef>int <parameter>fd</parameter></paramdef>
95         <paramdef>const char *<parameter>path</parameter></paramdef>
96       </funcprototype>
97
98       <funcprototype>
99         <funcdef>int <function>sd_is_special</function></funcdef>
100         <paramdef>int <parameter>fd</parameter></paramdef>
101         <paramdef>const char *<parameter>path</parameter></paramdef>
102       </funcprototype>
103
104     </funcsynopsis>
105   </refsynopsisdiv>
106
107   <refsect1>
108     <title>Description</title>
109
110     <para><function>sd_is_fifo()</function> may be called to check
111     whether the specified file descriptor refers to a FIFO or pipe. If
112     the <parameter>path</parameter> parameter is not
113     <constant>NULL</constant>, it is checked whether the FIFO is bound
114     to the specified file system path.</para>
115
116     <para><function>sd_is_socket()</function> may be called to check
117     whether the specified file descriptor refers to a socket. If the
118     <parameter>family</parameter> parameter is not
119     <constant>AF_UNSPEC</constant>, it is checked whether the socket
120     is of the specified family (AF_UNIX, <constant>AF_INET</constant>,
121     ...). If the <parameter>type</parameter> parameter is not 0, it is
122     checked whether the socket is of the specified type
123     (<constant>SOCK_STREAM</constant>,
124     <constant>SOCK_DGRAM</constant>, ...). If the
125     <parameter>listening</parameter> parameter is positive, it is
126     checked whether the socket is in accepting mode, i.e.
127     <function>listen()</function> has been called for it. If
128     <parameter>listening</parameter> is 0, it is checked whether the
129     socket is not in this mode. If the parameter is negative, no such
130     check is made. The <parameter>listening</parameter> parameter
131     should only be used for stream sockets and should be set to a
132     negative value otherwise.</para>
133
134     <para><function>sd_is_socket_inet()</function> is similar to
135     <function>sd_is_socket()</function>, but optionally checks the
136     IPv4 or IPv6 port number the socket is bound to, unless
137     <parameter>port</parameter> is zero. For this call
138     <parameter>family</parameter> must be passed as either
139     <constant>AF_UNSPEC</constant>, <constant>AF_INET</constant>, or
140     <constant>AF_INET6</constant>.</para>
141
142     <para><function>sd_is_socket_unix()</function> is similar to
143     <function>sd_is_socket()</function> but optionally checks the
144     <constant>AF_UNIX</constant> path the socket is bound to, unless
145     the <parameter>path</parameter> parameter is
146     <constant>NULL</constant>. For normal file system
147     <constant>AF_UNIX</constant> sockets, set the
148     <parameter>length</parameter> parameter to 0. For Linux abstract
149     namespace sockets, set the <parameter>length</parameter> to the
150     size of the address, including the initial 0 byte, and set the
151     <parameter>path</parameter> to the initial 0 byte of the socket
152     address.</para>
153
154     <para><function>sd_is_mq()</function> may be called to check
155     whether the specified file descriptor refers to a POSIX message
156     queue. If the <parameter>path</parameter> parameter is not
157     <constant>NULL</constant>, it is checked whether the message queue
158     is bound to the specified name.</para>
159
160     <para><function>sd_is_special()</function> may be called to check
161     whether the specified file descriptor refers to a special file. If
162     the <parameter>path</parameter> parameter is not
163     <constant>NULL</constant>, it is checked whether the file
164     descriptor is bound to the specified file name. Special files in
165     this context are character device nodes and files in
166     <filename>/proc</filename> or <filename>/sys</filename>.</para>
167   </refsect1>
168
169   <refsect1>
170     <title>Return Value</title>
171
172     <para>On failure, these calls return a negative errno-style error
173     code. If the file descriptor is of the specified type and bound to
174     the specified address, a positive return value is returned,
175     otherwise zero.</para>
176   </refsect1>
177
178   <refsect1>
179     <title>Notes</title>
180
181     <xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
182
183     <para>Internally, these function use a combination of
184     <filename>fstat()</filename> and
185     <filename>getsockname()</filename> to check the file descriptor
186     type and where it is bound to.</para>
187   </refsect1>
188
189   <refsect1>
190     <title>See Also</title>
191     <para>
192       <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
193       <citerefentry><refentrytitle>sd-daemon</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
194       <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
195       <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
196       <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>
197     </para>
198   </refsect1>
199
200 </refentry>