From 49e767ccb9dcfd2161b89f0d7a980eb85f056c5d Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sun, 4 Dec 2016 11:39:55 -0500 Subject: Move portability code into util.h --- util.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'util.h') diff --git a/util.h b/util.h index fbcadbd..e814f23 100644 --- a/util.h +++ b/util.h @@ -14,6 +14,27 @@ #include #include +#include + +// Some portability concerns + +#if __APPLE__ +# define st_atim st_atimespec +# define st_ctim st_ctimespec +# define st_mtim st_mtimespec +#endif + +#ifndef S_ISDOOR +# define S_ISDOOR(mode) false +#endif + +#ifndef S_ISPORT +# define S_ISPORT(mode) false +#endif + +#ifndef S_ISWHT +# define S_ISWHT(mode) false +#endif /** * readdir() wrapper that makes error handling cleaner. @@ -40,4 +61,13 @@ bool isopen(int fd); */ int redirect(int fd, const char *path, int flags, ...); +/** + * Like dup(), but set the FD_CLOEXEC flag. + * + * @param fd + * The file descriptor to duplicate. + * @return A duplicated file descriptor, or -1 on failure. + */ +int dup_cloexec(int fd); + #endif // BFS_UTIL_H -- cgit v1.2.3