diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2018-07-02 21:55:02 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2018-07-02 21:55:02 -0400 |
commit | 7e0cafb70135a68066ff72227613df9eeb2512fb (patch) | |
tree | 92abdd07fe5070eda794c03b291ba9b05b1dbb49 /stat.c | |
parent | 6d9f3667bb9c73b775ded64f8ea43f23b5c2d1af (diff) | |
download | bfs-7e0cafb70135a68066ff72227613df9eeb2512fb.tar.xz |
stat: Handle platforms that don't support AT_EMPTY_PATH for fstatat()
In particular, this caused -fprint to break on Hurd since AT_EMPTY_PATH
is defined and works for some syscalls but not fstatat().
Should fix:
https://buildd.debian.org/status/fetch.php?pkg=bfs&arch=hurd-i386&ver=1.2.2-1&stamp=1529920401&raw=0
Diffstat (limited to 'stat.c')
-rw-r--r-- | stat.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -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 } |