diff options
Diffstat (limited to 'src/shared/util.c')
-rw-r--r-- | src/shared/util.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/shared/util.c b/src/shared/util.c index 75dc58b63d..4fda31c838 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -3604,6 +3604,17 @@ int null_or_empty_path(const char *fn) { return null_or_empty(&st); } +int null_or_empty_fd(int fd) { + struct stat st; + + assert(fd >= 0); + + if (fstat(fd, &st) < 0) + return -errno; + + return null_or_empty(&st); +} + DIR *xopendirat(int fd, const char *name, int flags) { int nfd; DIR *d; |