summaryrefslogtreecommitdiffstats
path: root/stat.c
diff options
context:
space:
mode:
Diffstat (limited to 'stat.c')
-rw-r--r--stat.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/stat.c b/stat.c
index 3b90d04..1897bb3 100644
--- a/stat.c
+++ b/stat.c
@@ -231,13 +231,22 @@ int bfs_stat(int at_fd, const char *at_path, int at_flags, enum bfs_stat_flag fl
int bfs_fstat(int fd, struct bfs_stat *buf) {
#ifdef AT_EMPTY_PATH
- return bfs_stat(fd, "", AT_EMPTY_PATH, 0, buf);
-#else
+ static bool has_at_ep = true;
+
+ if (has_at_ep) {
+ int ret = bfs_stat(fd, "", AT_EMPTY_PATH, 0, buf);
+ if (ret != 0 && errno == EINVAL) {
+ has_at_ep = false;
+ } else {
+ return ret;
+ }
+ }
+#endif
+
struct stat statbuf;
int ret = fstat(fd, &statbuf);
if (ret == 0) {
bfs_stat_convert(&statbuf, buf);
}
return ret;
-#endif
}