man-pages/man3/sd_is_fifo.3.html
2021-03-31 01:06:50 +01:00

222 lines
6.5 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of SD_IS_FIFO</TITLE>
</HEAD><BODY>
<H1>SD_IS_FIFO</H1>
Section: sd_is_fifo (3)<BR>Updated: <BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
sd_is_fifo, sd_is_socket, sd_is_socket_inet, sd_is_socket_unix, sd_is_socket_sockaddr, sd_is_mq, sd_is_special - Check the type of a file descriptor
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<P>
<B>
</B><PRE>
#include &lt;<A HREF="file:///usr/include/systemd/sd-daemon.h">systemd/sd-daemon.h</A>&gt;
</PRE>
<DL COMPACT>
<DT id="1">
<B>int sd_is_fifo(int&nbsp;</B><I>fd</I><B>, const&nbsp;char&nbsp;*</B><I>path</I><B>);</B>
<DT id="2">
<B>int sd_is_socket(int&nbsp;</B><I>fd</I><B>, int&nbsp;</B><I>family</I><B>, int&nbsp;</B><I>type</I><B>, int&nbsp;</B><I>listening</I><B>);</B>
<DT id="3">
<B>int sd_is_socket_inet(int&nbsp;</B><I>fd</I><B>, int&nbsp;</B><I>family</I><B>, int&nbsp;</B><I>type</I><B>, int&nbsp;</B><I>listening</I><B>, uint16_t&nbsp;</B><I>port</I><B>);</B>
<DT id="4">
<B>int sd_is_socket_sockaddr(int&nbsp;</B><I>fd</I><B>, int&nbsp;</B><I>type</I><B>, const&nbsp;struct&nbsp;sockaddr&nbsp;*</B><I>addr</I><B>, unsigned&nbsp;</B><I>addr_len</I><B>, int&nbsp;</B><I>listening</I><B>);</B>
<DT id="5">
<B>int sd_is_socket_unix(int&nbsp;</B><I>fd</I><B>, int&nbsp;</B><I>type</I><B>, int&nbsp;</B><I>listening</I><B>, const&nbsp;char&nbsp;*</B><I>path</I><B>, size_t&nbsp;</B><I>length</I><B>);</B>
<DT id="6">
<B>int sd_is_mq(int&nbsp;</B><I>fd</I><B>, const&nbsp;char&nbsp;*</B><I>path</I><B>);</B>
<DT id="7">
<B>int sd_is_special(int&nbsp;</B><I>fd</I><B>, const&nbsp;char&nbsp;*</B><I>path</I><B>);</B>
</DL>
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
<P>
<B>sd_is_fifo()</B>
<DD>may be called to check whether the specified file descriptor refers to a FIFO or pipe. If the
<I>path</I>
parameter is not
<B>NULL</B>, it is checked whether the FIFO is bound to the specified file system path.
<P>
<B>sd_is_socket()</B>
may be called to check whether the specified file descriptor refers to a socket. If the
<I>family</I>
parameter is not
<B>AF_UNSPEC</B>, it is checked whether the socket is of the specified family (<B>AF_UNIX</B>,
<B>AF_INET</B>, ...). If the
<I>type</I>
parameter is not 0, it is checked whether the socket is of the specified type (<B>SOCK_STREAM</B>,
<B>SOCK_DGRAM</B>, ...). If the
<I>listening</I>
parameter is positive, it is checked whether the socket is in accepting mode, i.e.
<B>listen()</B>
has been called for it. If
<I>listening</I>
is 0, it is checked whether the socket is not in this mode. If the parameter is negative, no such check is made. The
<I>listening</I>
parameter should only be used for stream sockets and should be set to a negative value otherwise.
<P>
<B>sd_is_socket_inet()</B>
is similar to
<B>sd_is_socket()</B>, but optionally checks the IPv4 or IPv6 port number the socket is bound to, unless
<I>port</I>
is zero. For this call
<I>family</I>
must be passed as either
<B>AF_UNSPEC</B>,
<B>AF_INET</B>, or
<B>AF_INET6</B>.
<P>
<B>sd_is_socket_sockaddr()</B>
is similar to
<B>sd_is_socket_inet()</B>, but checks if the socket is bound to the address specified by
<I>addr</I>. The
<I>family</I>
specified by
<I>addr</I>
must be either
<B>AF_INET</B>
or
<B>AF_INET6</B>
and
<I>addr_len</I>
must be large enough for that family. If
<I>addr</I>
specifies a non-zero port, it is also checked if the socket is bound to this port. In addition, for IPv6, if
<I>addr</I>
specifies non-zero
<I>sin6_flowinfo</I>
or
<I>sin6_scope_id</I>, it is checked if the socket has the same values.
<P>
<B>sd_is_socket_unix()</B>
is similar to
<B>sd_is_socket()</B>
but optionally checks the
<B>AF_UNIX</B>
path the socket is bound to, unless the
<I>path</I>
parameter is
<B>NULL</B>. For normal file system
<B>AF_UNIX</B>
sockets, set the
<I>length</I>
parameter to 0. For Linux abstract namespace sockets, set the
<I>length</I>
to the size of the address, including the initial 0 byte, and set the
<I>path</I>
to the initial 0 byte of the socket address.
<P>
<B>sd_is_mq()</B>
may be called to check whether the specified file descriptor refers to a POSIX message queue. If the
<I>path</I>
parameter is not
<B>NULL</B>, it is checked whether the message queue is bound to the specified name.
<P>
<B>sd_is_special()</B>
may be called to check whether the specified file descriptor refers to a special file. If the
<I>path</I>
parameter is not
<B>NULL</B>, it is checked whether the file descriptor is bound to the specified filename. Special files in this context are character device nodes and files in
/proc
or
/sys.
<A NAME="lbAE">&nbsp;</A>
<H2>RETURN VALUE</H2>
<P>
On failure, these calls return a negative errno-style error code. If the file descriptor is of the specified type and bound to the specified address, a positive return value is returned, otherwise zero.
<A NAME="lbAF">&nbsp;</A>
<H2>NOTES</H2>
<P>
These APIs are implemented as a shared library, which can be compiled and linked to with the
<B>libsystemd</B>&nbsp;<B><A HREF="/cgi-bin/man/man2html?1+pkg-config">pkg-config</A></B>(1)
file.
<P>
Internally, these function use a combination of
fstat()
and
getsockname()
to check the file descriptor type and where it is bound to.
<A NAME="lbAG">&nbsp;</A>
<H2>SEE ALSO</H2>
<P>
<B><A HREF="/cgi-bin/man/man2html?1+systemd">systemd</A></B>(1),
<B><A HREF="/cgi-bin/man/man2html?3+sd-daemon">sd-daemon</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?3+sd_listen_fds">sd_listen_fds</A></B>(3),
<B><A HREF="/cgi-bin/man/man2html?5+systemd.service">systemd.service</A></B>(5),
<B><A HREF="/cgi-bin/man/man2html?5+systemd.socket">systemd.socket</A></B>(5),
<B><A HREF="/cgi-bin/man/man2html?7+ip">ip</A></B>(7),
<B><A HREF="/cgi-bin/man/man2html?7+ipv6">ipv6</A></B>(7),
<B><A HREF="/cgi-bin/man/man2html?7+unix">unix</A></B>(7),
<B><A HREF="/cgi-bin/man/man2html?7+fifo">fifo</A></B>(7),
<B><A HREF="/cgi-bin/man/man2html?7+mq_overview">mq_overview</A></B>(7),
<B><A HREF="/cgi-bin/man/man2html?7+socket">socket</A></B>(7).
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="8"><A HREF="#lbAB">NAME</A><DD>
<DT id="9"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="10"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="11"><A HREF="#lbAE">RETURN VALUE</A><DD>
<DT id="12"><A HREF="#lbAF">NOTES</A><DD>
<DT id="13"><A HREF="#lbAG">SEE ALSO</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:55 GMT, March 31, 2021
</BODY>
</HTML>