openat: avoid using wrong fd