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