diff --git a/src/basic/fd-util.h b/src/basic/fd-util.h index bb9669a84e..2663ff8aac 100644 --- a/src/basic/fd-util.h +++ b/src/basic/fd-util.h @@ -57,6 +57,13 @@ #define NR_OPEN_MINIMUM ((unsigned) (sizeof(long) * 8)) #define NR_OPEN_MAXIMUM ((unsigned) (CONST_MIN((size_t) INT_MAX, SIZE_MAX / __SIZEOF_POINTER__) & ~(sizeof(long) * 8 - 1))) +/* A special fd that can be passed in various helpers instead of an fd indicating the root dir. Inspired by, + * and an alternative to AT_FDCWD. We use specific negative value that is outside of the negative errno + * range, to avoid any potential ambiguities. */ +#define XAT_FDROOT -8192 +assert_cc(XAT_FDROOT != AT_FDCWD); +assert_cc(XAT_FDROOT < -ERRNO_MAX); + int close_nointr(int fd); int safe_close(int fd); void safe_close_pair(int p[static 2]);