X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fat-func.c;h=c7963fe3d24b67539068947676ec6d3ebbc8fd0b;hb=2fd7e9189c239ef737105bc085ace4dc80435533;hp=2bdea7b9355404ae023b6720169bdd80b45ad42a;hpb=8b3f78cdd40155b5864692b63b6a368c7dabd050;p=gnulib.git diff --git a/lib/at-func.c b/lib/at-func.c index 2bdea7b93..c7963fe3d 100644 --- a/lib/at-func.c +++ b/lib/at-func.c @@ -1,10 +1,10 @@ /* Define an at-style functions like fstatat, unlinkat, fchownat, etc. Copyright (C) 2006 Free Software Foundation, Inc. - This program is free software; you can redistribute it and/or modify + This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -12,8 +12,7 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + along with this program. If not, see . */ /* written by Jim Meyering */ @@ -39,14 +38,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)