X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fbasic%2Ffd-util.h;h=fe92b76c405c5880987e31dea53ff16076f61649;hb=4a7059686430f596810f0c83e4897154828fd352;hp=0d742b50b24c798c94813dd32a0cb4b3180d2054;hpb=bccdfb431a266e7671d518fd5a42362a5ce724c9;p=elogind.git diff --git a/src/basic/fd-util.h b/src/basic/fd-util.h index 0d742b50b..fe92b76c4 100644 --- a/src/basic/fd-util.h +++ b/src/basic/fd-util.h @@ -1,5 +1,3 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - #pragma once /*** @@ -21,9 +19,9 @@ along with systemd; If not, see . ***/ -#include #include #include +#include #include #include "macro.h" @@ -40,7 +38,9 @@ void close_many(const int fds[], unsigned n_fd); int fclose_nointr(FILE *f); FILE* safe_fclose(FILE *f); -// UNNEEDED DIR* safe_closedir(DIR *f); +#if 0 /// UNNEEDED by elogind +DIR* safe_closedir(DIR *f); +#endif // 0 static inline void closep(int *fd) { safe_close(*fd); @@ -65,11 +65,20 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(DIR*, closedir); int fd_nonblock(int fd, bool nonblock); int fd_cloexec(int fd, bool cloexec); +void stdio_unset_cloexec(void); int close_all_fds(const int except[], unsigned n_except); -// UNNEEDED int same_fd(int a, int b); +#if 0 /// UNNEEDED by elogind +int same_fd(int a, int b); + +void cmsg_close_all(struct msghdr *mh); + +bool fdname_is_valid(const char *s); -// UNNEEDED void cmsg_close_all(struct msghdr *mh); +int fd_get_path(int fd, char **ret); +#endif // 0 -// UNNEEDED bool fdname_is_valid(const char *s); +/* Hint: ENETUNREACH happens if we try to connect to "non-existing" special IP addresses, such as ::5 */ +#define ERRNO_IS_DISCONNECT(r) \ + IN_SET(r, ENOTCONN, ECONNRESET, ECONNREFUSED, ECONNABORTED, EPIPE, ENETUNREACH)