Use fstatat to avoid extraneous syscalls.