]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/basic/fd-util.h
tree-wide: introduce PIPE_EBADF macro
[thirdparty/systemd.git] / src / basic / fd-util.h
index 8543d0d5eaa4d13f17160a5f4a2a8501f7e18b81..1faefe6a0e6b1682f404971183c37ebc1a6f1923 100644 (file)
@@ -15,6 +15,7 @@
 /* Make sure we can distinguish fd 0 and NULL */
 #define FD_TO_PTR(fd) INT_TO_PTR((fd)+1)
 #define PTR_TO_FD(p) (PTR_TO_INT(p)-1)
+#define PIPE_EBADF { -EBADF, -EBADF }
 
 int close_nointr(int fd);
 int safe_close(int fd);
@@ -56,6 +57,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC_FULL(DIR*, closedir, NULL);
 
 int fd_nonblock(int fd, bool nonblock);
 int fd_cloexec(int fd, bool cloexec);
+int fd_cloexec_many(const int fds[], size_t n_fds, bool cloexec);
 
 int get_max_fd(void);
 
@@ -93,7 +95,7 @@ static inline int make_null_stdio(void) {
         ({                                      \
                 int *_fd_ = &(fd);              \
                 int _ret_ = *_fd_;              \
-                *_fd_ = -1;                     \
+                *_fd_ = -EBADF;                 \
                 _ret_;                          \
         })
 
@@ -107,8 +109,8 @@ static inline int make_null_stdio(void) {
         })
 
 int fd_reopen(int fd, int flags);
+int fd_reopen_condition(int fd, int flags, int mask, int *ret_new_fd);
 int read_nr_open(void);
-int btrfs_defrag_fd(int fd);
 int fd_get_diskseq(int fd, uint64_t *ret);
 
 /* The maximum length a buffer for a /proc/self/fd/<fd> path needs */