chiark / gitweb /
networkd: add basic [Link] settings to .network files
[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
111                 to check whether the specified file descriptor refers
112                 to a FIFO or pipe. If the <parameter>path</parameter>
113                 parameter is not <constant>NULL</constant>, it is
114                 checked whether the FIFO is bound to the specified
115                 file system path.</para>
116
117                 <para><function>sd_is_socket()</function> may be
118                 called to check whether the specified file descriptor
119                 refers to a socket. If the
120                 <parameter>family</parameter> parameter is not
121                 <constant>AF_UNSPEC</constant>, it is checked whether
122                 the socket is of the specified family (AF_UNIX,
123                 <constant>AF_INET</constant>, ...). If the
124                 <parameter>type</parameter> parameter is not 0, it is
125                 checked whether the socket is of the specified type
126                 (<constant>SOCK_STREAM</constant>,
127                 <constant>SOCK_DGRAM</constant>, ...). If the
128                 <parameter>listening</parameter> parameter is positive,
129                 it is checked whether the socket is in accepting mode,
130                 i.e. <function>listen()</function> has been called for
131                 it. If <parameter>listening</parameter> is 0, it is
132                 checked whether the socket is not in this mode. If the
133                 parameter is negative, no such check is made. The
134                 <parameter>listening</parameter> parameter should only
135                 be used for stream sockets and should be set to a
136                 negative value otherwise.</para>
137
138                 <para><function>sd_is_socket_inet()</function> is
139                 similar to <function>sd_is_socket()</function>, but
140                 optionally checks the IPv4 or IPv6 port number the
141                 socket is bound to, unless <parameter>port</parameter>
142                 is zero. For this call <parameter>family</parameter>
143                 must be passed as either <constant>AF_UNSPEC</constant>, <constant>AF_INET</constant>, or
144                 <constant>AF_INET6</constant>.</para>
145
146                 <para><function>sd_is_socket_unix()</function> is
147                 similar to <function>sd_is_socket()</function> but
148                 optionally checks the <constant>AF_UNIX</constant> path the socket is bound
149                 to, unless the <parameter>path</parameter> parameter
150                 is <constant>NULL</constant>. For normal file system <constant>AF_UNIX</constant> sockets,
151                 set the <parameter>length</parameter> parameter to 0. For
152                 Linux abstract namespace sockets, set the
153                 <parameter>length</parameter> to the size of the
154                 address, including the initial 0 byte, and set the
155                 <parameter>path</parameter> to the initial 0 byte of
156                 the socket address.</para>
157
158                 <para><function>sd_is_mq()</function> may be called to
159                 check whether the specified file descriptor refers to
160                 a POSIX message queue. If the
161                 <parameter>path</parameter> parameter is not
162                 <constant>NULL</constant>, it is checked whether the
163                 message queue is bound to the specified name.</para>
164
165                 <para><function>sd_is_special()</function> may be
166                 called to check whether the specified file descriptor
167                 refers to a special file. If the
168                 <parameter>path</parameter> parameter is not
169                 <constant>NULL</constant>, it is checked whether the file
170                 descriptor is bound to the specified file
171                 name. Special files in this context are character
172                 device nodes and files in <filename>/proc</filename>
173                 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
180                 errno-style error code. If the file descriptor is of
181                 the specified type and bound to the specified address,
182                 a positive return value is returned, otherwise
183                 zero.</para>
184         </refsect1>
185
186         <refsect1>
187                 <title>Notes</title>
188
189                 <xi:include href="libsystemd-pkgconfig.xml" xpointer="pkgconfig-text"/>
190
191                 <para>Internally, these function use a combination of
192                 <filename>fstat()</filename> and
193                 <filename>getsockname()</filename> to check the file
194                 descriptor type and where it is bound to.</para>
195         </refsect1>
196
197         <refsect1>
198                 <title>See Also</title>
199                 <para>
200                         <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
201                         <citerefentry><refentrytitle>sd-daemon</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
202                         <citerefentry><refentrytitle>sd_listen_fds</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
203                         <citerefentry><refentrytitle>systemd.service</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
204                         <citerefentry><refentrytitle>systemd.socket</refentrytitle><manvolnum>5</manvolnum></citerefentry>
205                 </para>
206         </refsect1>
207
208 </refentry>