X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fat-func.c;h=f98c207e72c5cf01367e06d16a82037a111cecff;hb=d2b0c77abf5b72cbf78ec4e4e404c851950b0fef;hp=2bdea7b9355404ae023b6720169bdd80b45ad42a;hpb=8b3f78cdd40155b5864692b63b6a368c7dabd050;p=gnulib.git diff --git a/lib/at-func.c b/lib/at-func.c index 2bdea7b93..f98c207e7 100644 --- a/lib/at-func.c +++ b/lib/at-func.c @@ -39,14 +39,25 @@ AT_FUNC_NAME (int fd, char const *file AT_FUNC_POST_FILE_PARAM_DECLS) return CALL_FUNC (file); { - char *proc_file; - BUILD_PROC_NAME (proc_file, fd, file); - err = CALL_FUNC (proc_file); - /* If the syscall succeeds, or if it fails with an unexpected - errno value, then return right away. Otherwise, fall through - and resort to using save_cwd/restore_cwd. */ - if (0 <= err || ! EXPECTED_ERRNO (errno)) - return err; + char buf[OPENAT_BUFFER_SIZE]; + char *proc_file = openat_proc_name (buf, fd, file); + if (proc_file) + { + int proc_result = CALL_FUNC (proc_file); + int proc_errno = errno; + if (proc_file != buf) + free (proc_file); + /* If the syscall succeeds, or if it fails with an unexpected + errno value, then return right away. Otherwise, fall through + and resort to using save_cwd/restore_cwd. */ + if (0 <= proc_result) + return proc_result; + if (! EXPECTED_ERRNO (proc_errno)) + { + errno = proc_errno; + return proc_result; + } + } } if (save_cwd (&saved_cwd) != 0)