1SD_IS_FIFO(3)                     sd_is_fifo                     SD_IS_FIFO(3)
2
3
4

NAME

6       sd_is_fifo, sd_is_socket, sd_is_socket_inet, sd_is_socket_unix,
7       sd_is_socket_sockaddr, sd_is_mq, sd_is_special - Check the type of a
8       file descriptor
9

SYNOPSIS

11       #include <systemd/sd-daemon.h>
12
13       int sd_is_fifo(int fd, const char *path);
14
15       int sd_is_socket(int fd, int family, int type, int listening);
16
17       int sd_is_socket_inet(int fd, int family, int type, int listening,
18                             uint16_t port);
19
20       int sd_is_socket_sockaddr(int fd, int type,
21                                 const struct sockaddr *addr,
22                                 unsigned addr_len, int listening);
23
24       int sd_is_socket_unix(int fd, int type, int listening,
25                             const char *path, size_t length);
26
27       int sd_is_mq(int fd, const char *path);
28
29       int sd_is_special(int fd, const char *path);
30

DESCRIPTION

32       sd_is_fifo() may be called to check whether the specified file
33       descriptor refers to a FIFO or pipe. If the path parameter is not NULL,
34       it is checked whether the FIFO is bound to the specified file system
35       path.
36
37       sd_is_socket() may be called to check whether the specified file
38       descriptor refers to a socket. If the family parameter is not
39       AF_UNSPEC, it is checked whether the socket is of the specified family
40       (AF_UNIX, AF_INET, ...). If the type parameter is not 0, it is checked
41       whether the socket is of the specified type (SOCK_STREAM, SOCK_DGRAM,
42       ...). If the listening parameter is positive, it is checked whether the
43       socket is in accepting mode, i.e.  listen() has been called for it. If
44       listening is 0, it is checked whether the socket is not in this mode.
45       If the parameter is negative, no such check is made. The listening
46       parameter should only be used for stream sockets and should be set to a
47       negative value otherwise.
48
49       sd_is_socket_inet() is similar to sd_is_socket(), but optionally checks
50       the IPv4 or IPv6 port number the socket is bound to, unless port is
51       zero. For this call family must be passed as either AF_UNSPEC, AF_INET,
52       or AF_INET6.
53
54       sd_is_socket_sockaddr() is similar to sd_is_socket_inet(), but checks
55       if the socket is bound to the address specified by addr. The family
56       specified by addr must be either AF_INET or AF_INET6 and addr_len must
57       be large enough for that family. If addr specifies a non-zero port, it
58       is also checked if the socket is bound to this port. In addition, for
59       IPv6, if addr specifies non-zero sin6_flowinfo or sin6_scope_id, it is
60       checked if the socket has the same values.
61
62       sd_is_socket_unix() is similar to sd_is_socket() but optionally checks
63       the AF_UNIX path the socket is bound to, unless the path parameter is
64       NULL. For normal file system AF_UNIX sockets, set the length parameter
65       to 0. For Linux abstract namespace sockets, set the length to the size
66       of the address, including the initial 0 byte, and set the path to the
67       initial 0 byte of the socket address.
68
69       sd_is_mq() may be called to check whether the specified file descriptor
70       refers to a POSIX message queue. If the path parameter is not NULL, it
71       is checked whether the message queue is bound to the specified name.
72
73       sd_is_special() may be called to check whether the specified file
74       descriptor refers to a special file. If the path parameter is not NULL,
75       it is checked whether the file descriptor is bound to the specified
76       filename. Special files in this context are character device nodes and
77       files in /proc/ or /sys/.
78

RETURN VALUE

80       On failure, these calls return a negative errno-style error code. If
81       the file descriptor is of the specified type and bound to the specified
82       address, a positive return value is returned, otherwise zero.
83

NOTES

85       Functions described here are available as a shared library, which can
86       be compiled against and linked to with the libsystemd pkg-config(1)
87       file.
88
89       Internally, these functions use a combination of fstat(2) and
90       getsockname(2) to check the file descriptor type and where it is bound
91       to.
92

SEE ALSO

94       systemd(1), sd-daemon(3), sd_listen_fds(3), systemd.service(5),
95       systemd.socket(5), ip(7), ipv6(7), unix(7), fifo(7), mq_overview(7),
96       socket(7).
97
98
99
100systemd 254                                                      SD_IS_FIFO(3)
Impressum