file_utils: move dup_cloexec() to header

parent 858f6225
......@@ -564,20 +564,6 @@ int fd_cloexec(int fd, bool cloexec)
return 0;
}
static inline int dup_cloexec(int fd)
{
__do_close int fd_dup = -EBADF;
fd_dup = dup(fd);
if (fd_dup < 0)
return -errno;
if (fd_cloexec(fd_dup, true))
return -errno;
return move_fd(fd_dup);
}
FILE *fdopen_at(int dfd, const char *path, const char *mode,
unsigned int o_flags, unsigned int resolve_flags)
{
......
......@@ -105,4 +105,18 @@ __hidden extern ssize_t lxc_read_try_buf_at(int dfd, const char *path,
*/
__hidden extern bool same_file_lax(int fda, int fdb);
static inline int dup_cloexec(int fd)
{
__do_close int fd_dup = -EBADF;
fd_dup = dup(fd);
if (fd_dup < 0)
return -errno;
if (fd_cloexec(fd_dup, true))
return -errno;
return move_fd(fd_dup);
}
#endif /* __LXC_FILE_UTILS_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment