]>
Commit | Line | Data |
---|---|---|
663996b3 MS |
1 | <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>sd_is_fifo</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><style> |
2 | a.headerlink { | |
3 | color: #c60f0f; | |
4 | font-size: 0.8em; | |
5 | padding: 0 4px 0 4px; | |
6 | text-decoration: none; | |
7 | visibility: hidden; | |
8 | } | |
9 | ||
10 | a.headerlink:hover { | |
11 | background-color: #c60f0f; | |
12 | color: white; | |
13 | } | |
14 | ||
15 | h1:hover > a.headerlink, h2:hover > a.headerlink, h3:hover > a.headerlink, dt:hover > a.headerlink { | |
16 | visibility: visible; | |
17 | } | |
18 | </style><a href="index.html">Index </a>· | |
19 | <a href="systemd.directives.html">Directives </a>· | |
20 | <a href="../python-systemd/index.html">Python </a>· | |
21 | <a href="../libudev/index.html">libudev </a>· | |
e735f4d4 MP |
22 | <a href="../libudev/index.html">gudev </a><span style="float:right">systemd 219</span><hr><div class="refentry"><a name="sd_is_fifo"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>sd_is_fifo, sd_is_socket, sd_is_socket_inet, sd_is_socket_unix, sd_is_mq, sd_is_special — Check the type of a file descriptor</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include <systemd/sd-daemon.h></pre><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_is_fifo</b>(</code></td><td>int <var class="pdparam">fd</var>, </td></tr><tr><td> </td><td>const char *<var class="pdparam">path</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_is_socket</b>(</code></td><td>int <var class="pdparam">fd</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">family</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">type</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">listening</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_is_socket_inet</b>(</code></td><td>int <var class="pdparam">fd</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">family</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">type</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">listening</var>, </td></tr><tr><td> </td><td>uint16_t <var class="pdparam">port</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_is_socket_unix</b>(</code></td><td>int <var class="pdparam">fd</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">type</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">listening</var>, </td></tr><tr><td> </td><td>const char *<var class="pdparam">path</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">length</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_is_mq</b>(</code></td><td>int <var class="pdparam">fd</var>, </td></tr><tr><td> </td><td>const char *<var class="pdparam">path</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">sd_is_special</b>(</code></td><td>int <var class="pdparam">fd</var>, </td></tr><tr><td> </td><td>const char *<var class="pdparam">path</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="idm139770415154944"></a><h2 id="Description">Description<a class="headerlink" title="Permalink to this headline" href="#Description">¶</a></h2><p><code class="function">sd_is_fifo()</code> may be called to check |
23 | whether the specified file descriptor refers to a FIFO or pipe. If | |
24 | the <em class="parameter"><code>path</code></em> parameter is not | |
25 | <code class="constant">NULL</code>, it is checked whether the FIFO is bound | |
26 | to the specified file system path.</p><p><code class="function">sd_is_socket()</code> may be called to check | |
27 | whether the specified file descriptor refers to a socket. If the | |
28 | <em class="parameter"><code>family</code></em> parameter is not | |
29 | <code class="constant">AF_UNSPEC</code>, it is checked whether the socket | |
30 | is of the specified family (AF_UNIX, <code class="constant">AF_INET</code>, | |
31 | ...). If the <em class="parameter"><code>type</code></em> parameter is not 0, it is | |
32 | checked whether the socket is of the specified type | |
33 | (<code class="constant">SOCK_STREAM</code>, | |
34 | <code class="constant">SOCK_DGRAM</code>, ...). If the | |
35 | <em class="parameter"><code>listening</code></em> parameter is positive, it is | |
36 | checked whether the socket is in accepting mode, i.e. | |
37 | <code class="function">listen()</code> has been called for it. If | |
38 | <em class="parameter"><code>listening</code></em> is 0, it is checked whether the | |
39 | socket is not in this mode. If the parameter is negative, no such | |
40 | check is made. The <em class="parameter"><code>listening</code></em> parameter | |
41 | should only be used for stream sockets and should be set to a | |
42 | negative value otherwise.</p><p><code class="function">sd_is_socket_inet()</code> is similar to | |
43 | <code class="function">sd_is_socket()</code>, but optionally checks the | |
44 | IPv4 or IPv6 port number the socket is bound to, unless | |
45 | <em class="parameter"><code>port</code></em> is zero. For this call | |
46 | <em class="parameter"><code>family</code></em> must be passed as either | |
47 | <code class="constant">AF_UNSPEC</code>, <code class="constant">AF_INET</code>, or | |
48 | <code class="constant">AF_INET6</code>.</p><p><code class="function">sd_is_socket_unix()</code> is similar to | |
49 | <code class="function">sd_is_socket()</code> but optionally checks the | |
50 | <code class="constant">AF_UNIX</code> path the socket is bound to, unless | |
51 | the <em class="parameter"><code>path</code></em> parameter is | |
52 | <code class="constant">NULL</code>. For normal file system | |
53 | <code class="constant">AF_UNIX</code> sockets, set the | |
54 | <em class="parameter"><code>length</code></em> parameter to 0. For Linux abstract | |
55 | namespace sockets, set the <em class="parameter"><code>length</code></em> to the | |
56 | size of the address, including the initial 0 byte, and set the | |
57 | <em class="parameter"><code>path</code></em> to the initial 0 byte of the socket | |
58 | address.</p><p><code class="function">sd_is_mq()</code> may be called to check | |
59 | whether the specified file descriptor refers to a POSIX message | |
60 | queue. If the <em class="parameter"><code>path</code></em> parameter is not | |
61 | <code class="constant">NULL</code>, it is checked whether the message queue | |
62 | is bound to the specified name.</p><p><code class="function">sd_is_special()</code> may be called to check | |
63 | whether the specified file descriptor refers to a special file. If | |
64 | the <em class="parameter"><code>path</code></em> parameter is not | |
65 | <code class="constant">NULL</code>, it is checked whether the file | |
66 | descriptor is bound to the specified file name. Special files in | |
67 | this context are character device nodes and files in | |
68 | <code class="filename">/proc</code> or <code class="filename">/sys</code>.</p></div><div class="refsect1"><a name="idm139770415120688"></a><h2 id="Return Value">Return Value<a class="headerlink" title="Permalink to this headline" href="#Return%20Value">¶</a></h2><p>On failure, these calls return a negative errno-style error | |
69 | code. If the file descriptor is of the specified type and bound to | |
70 | the specified address, a positive return value is returned, | |
71 | otherwise zero.</p></div><div class="refsect1"><a name="idm139770410205136"></a><h2 id="Notes">Notes<a class="headerlink" title="Permalink to this headline" href="#Notes">¶</a></h2><p><a name="pkgconfig-text"></a>These APIs are implemented as a shared | |
60f067b4 | 72 | library, which can be compiled and linked to with the |
5eef597e | 73 | <code class="constant">libsystemd</code> <a href="http://linux.die.net/man/1/pkg-config"><span class="citerefentry"><span class="refentrytitle">pkg-config</span>(1)</span></a> |
60f067b4 | 74 | file.</p><p>Internally, these function use a combination of |
e735f4d4 MP |
75 | <code class="filename">fstat()</code> and |
76 | <code class="filename">getsockname()</code> to check the file descriptor | |
77 | type and where it is bound to.</p></div><div class="refsect1"><a name="idm139770410202000"></a><h2 id="See Also">See Also<a class="headerlink" title="Permalink to this headline" href="#See%20Also">¶</a></h2><p> | |
78 | <a href="systemd.html"><span class="citerefentry"><span class="refentrytitle">systemd</span>(1)</span></a>, | |
79 | <a href="sd-daemon.html"><span class="citerefentry"><span class="refentrytitle">sd-daemon</span>(3)</span></a>, | |
80 | <a href="sd_listen_fds.html"><span class="citerefentry"><span class="refentrytitle">sd_listen_fds</span>(3)</span></a>, | |
81 | <a href="systemd.service.html"><span class="citerefentry"><span class="refentrytitle">systemd.service</span>(5)</span></a>, | |
82 | <a href="systemd.socket.html"><span class="citerefentry"><span class="refentrytitle">systemd.socket</span>(5)</span></a> | |
83 | </p></div></div></body></html> |