summaryrefslogtreecommitdiffstats
path: root/upstream/fedora-rawhide/man3/sd_is_fifo.3
blob: 76736e7d093f0cbbb30ed14f4dba8916ece363fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
'\" t
.TH "SD_IS_FIFO" "3" "" "systemd 255" "sd_is_fifo"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
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
.SH "SYNOPSIS"
.sp
.ft B
.nf
#include <systemd/sd\-daemon\&.h>
.fi
.ft
.HP \w'int\ sd_is_fifo('u
.BI "int sd_is_fifo(int\ " "fd" ", const\ char\ *" "path" ");"
.HP \w'int\ sd_is_socket('u
.BI "int sd_is_socket(int\ " "fd" ", int\ " "family" ", int\ " "type" ", int\ " "listening" ");"
.HP \w'int\ sd_is_socket_inet('u
.BI "int sd_is_socket_inet(int\ " "fd" ", int\ " "family" ", int\ " "type" ", int\ " "listening" ", uint16_t\ " "port" ");"
.HP \w'int\ sd_is_socket_sockaddr('u
.BI "int sd_is_socket_sockaddr(int\ " "fd" ", int\ " "type" ", const\ struct\ sockaddr\ *" "addr" ", unsigned\ " "addr_len" ", int\ " "listening" ");"
.HP \w'int\ sd_is_socket_unix('u
.BI "int sd_is_socket_unix(int\ " "fd" ", int\ " "type" ", int\ " "listening" ", const\ char\ *" "path" ", size_t\ " "length" ");"
.HP \w'int\ sd_is_mq('u
.BI "int sd_is_mq(int\ " "fd" ", const\ char\ *" "path" ");"
.HP \w'int\ sd_is_special('u
.BI "int sd_is_special(int\ " "fd" ", const\ char\ *" "path" ");"
.SH "DESCRIPTION"
.PP
\fBsd_is_fifo()\fR
may be called to check whether the specified file descriptor refers to a FIFO or pipe\&. If the
\fIpath\fR
parameter is not
\fBNULL\fR, it is checked whether the FIFO is bound to the specified file system path\&.
.PP
\fBsd_is_socket()\fR
may be called to check whether the specified file descriptor refers to a socket\&. If the
\fIfamily\fR
parameter is not
\fBAF_UNSPEC\fR, it is checked whether the socket is of the specified family (\fBAF_UNIX\fR,
\fBAF_INET\fR, \&...)\&. If the
\fItype\fR
parameter is not 0, it is checked whether the socket is of the specified type (\fBSOCK_STREAM\fR,
\fBSOCK_DGRAM\fR, \&...)\&. If the
\fIlistening\fR
parameter is positive, it is checked whether the socket is in accepting mode, i\&.e\&.
\fBlisten()\fR
has been called for it\&. If
\fIlistening\fR
is 0, it is checked whether the socket is not in this mode\&. If the parameter is negative, no such check is made\&. The
\fIlistening\fR
parameter should only be used for stream sockets and should be set to a negative value otherwise\&.
.PP
\fBsd_is_socket_inet()\fR
is similar to
\fBsd_is_socket()\fR, but optionally checks the IPv4 or IPv6 port number the socket is bound to, unless
\fIport\fR
is zero\&. For this call
\fIfamily\fR
must be passed as either
\fBAF_UNSPEC\fR,
\fBAF_INET\fR, or
\fBAF_INET6\fR\&.
.PP
\fBsd_is_socket_sockaddr()\fR
is similar to
\fBsd_is_socket_inet()\fR, but checks if the socket is bound to the address specified by
\fIaddr\fR\&. The
\fIfamily\fR
specified by
\fIaddr\fR
must be either
\fBAF_INET\fR
or
\fBAF_INET6\fR
and
\fIaddr_len\fR
must be large enough for that family\&. If
\fIaddr\fR
specifies a non\-zero port, it is also checked if the socket is bound to this port\&. In addition, for IPv6, if
\fIaddr\fR
specifies non\-zero
\fIsin6_flowinfo\fR
or
\fIsin6_scope_id\fR, it is checked if the socket has the same values\&.
.PP
\fBsd_is_socket_unix()\fR
is similar to
\fBsd_is_socket()\fR
but optionally checks the
\fBAF_UNIX\fR
path the socket is bound to, unless the
\fIpath\fR
parameter is
\fBNULL\fR\&. For normal file system
\fBAF_UNIX\fR
sockets, set the
\fIlength\fR
parameter to 0\&. For Linux abstract namespace sockets, set the
\fIlength\fR
to the size of the address, including the initial 0 byte, and set the
\fIpath\fR
to the initial 0 byte of the socket address\&.
.PP
\fBsd_is_mq()\fR
may be called to check whether the specified file descriptor refers to a POSIX message queue\&. If the
\fIpath\fR
parameter is not
\fBNULL\fR, it is checked whether the message queue is bound to the specified name\&.
.PP
\fBsd_is_special()\fR
may be called to check whether the specified file descriptor refers to a special file\&. If the
\fIpath\fR
parameter is not
\fBNULL\fR, 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/\&.
.SH "RETURN VALUE"
.PP
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\&.
.SH "NOTES"
.PP
Functions described here are available as a shared library, which can be compiled against and linked to with the
\fBlibsystemd\fR\ \&\fBpkg-config\fR(1)
file\&.
.PP
Internally, these functions use a combination of
\fBfstat\fR(2)
and
\fBgetsockname\fR(2)
to check the file descriptor type and where it is bound to\&.
.SH "HISTORY"
.PP
\fBsd_is_special()\fR
was added in version 209\&.
.PP
\fBsd_is_socket_sockaddr()\fR
was added in version 233\&.
.SH "SEE ALSO"
.PP
\fBsystemd\fR(1),
\fBsd-daemon\fR(3),
\fBsd_listen_fds\fR(3),
\fBsystemd.service\fR(5),
\fBsystemd.socket\fR(5),
\fBip\fR(7),
\fBipv6\fR(7),
\fBunix\fR(7),
\fBfifo\fR(7),
\fBmq_overview\fR(7),
\fBsocket\fR(7)\&.