chiark / gitweb /
fd-util: introduce fd_reopen() helper for reopening an fd
authorLennart Poettering <lennart@poettering.net>
Mon, 26 Mar 2018 11:25:51 +0000 (13:25 +0200)
committerSven Eden <yamakuzure@gmx.net>
Fri, 24 Aug 2018 14:47:08 +0000 (16:47 +0200)
We have the same code for this in place at various locations, let's
unify that. Also, let's repurpose test-fs-util.c as a test for this new
helper cal..

src/basic/fd-util.h

index db259e6d137c170c03896b693cef52761f29eca5..0f5a950f175a7a6fb7feb673f3e857ba4105f136 100644 (file)
@@ -102,10 +102,6 @@ int acquire_data_fd(const void *data, size_t size, unsigned flags);
 #define ERRNO_IS_DISCONNECT(r) \
         IN_SET(r, ENOTCONN, ECONNRESET, ECONNREFUSED, ECONNABORTED, EPIPE, ENETUNREACH)
 
-/* Resource exhaustion, could be our fault or general system trouble */
-#define ERRNO_IS_RESOURCE(r) \
-        IN_SET(r, ENOMEM, EMFILE, ENFILE)
-
 int fd_move_above_stdio(int fd);
 
 int rearrange_stdio(int original_input_fd, int original_output_fd, int original_error_fd);
@@ -121,3 +117,5 @@ static inline int make_null_stdio(void) {
                 (fd) = -1;                      \
                 _fd_;                           \
         })
+
+int fd_reopen(int fd, int flags);