[PATCH v2 05/46] access: Use faccessat if arch does not have the access syscall

Markos Chandras markos.chandras at gmail.com
Tue Nov 27 11:48:51 UTC 2012


On 27 November 2012 11:45, Vineet Gupta <Vineet.Gupta1 at synopsys.com> wrote:
> On Monday 26 November 2012 07:53 PM, Markos Chandras wrote:
>> From: Markos Chandras <markos.chandras at imgtec.com>
>>
>> Signed-off-by: Markos Chandras <markos.chandras at imgtec.com>
>> ---
>>  include/unistd.h                      |  1 +
>>  libc/sysdeps/linux/common/access.c    | 10 ++++++++++
>>  libc/sysdeps/linux/common/faccessat.c |  1 +
>>  3 files changed, 12 insertions(+)
>>
>> diff --git a/include/unistd.h b/include/unistd.h
>> index 766fcf3..1540aa9 100644
>> --- a/include/unistd.h
>> +++ b/include/unistd.h
>> @@ -274,6 +274,7 @@ extern int eaccess (__const char *__name, int __type)
>>     otherwise use real IDs like `access'.  */
>>  extern int faccessat (int __fd, __const char *__file, int __type, int __flag)
>>       __THROW __nonnull ((2)) __wur;
>> +libc_hidden_proto(faccessat)
>>  #endif /* Use GNU.  */
>>
>>
>> diff --git a/libc/sysdeps/linux/common/access.c b/libc/sysdeps/linux/common/access.c
>> index a075d42..fd676d9 100644
>> --- a/libc/sysdeps/linux/common/access.c
>> +++ b/libc/sysdeps/linux/common/access.c
>> @@ -8,5 +8,15 @@
>>   */
>>
>>  #include <sys/syscall.h>
>> +#include <fcntl.h>
>>  #include <unistd.h>
>> +
>> +#if defined(__NR_faccessat) && !defined(__NR_access)
>> +int access(const char *pathname, int mode)
>> +{
>> +     return faccessat(AT_FDCWD, pathname, mode, 0);
>> +}
>> +
>> +#else
>>  _syscall2(int, access, const char *, pathname, int, mode)
>> +#endif
>> diff --git a/libc/sysdeps/linux/common/faccessat.c b/libc/sysdeps/linux/common/faccessat.c
>> index 09ca129..ba84953 100644
>> --- a/libc/sysdeps/linux/common/faccessat.c
>> +++ b/libc/sysdeps/linux/common/faccessat.c
>> @@ -12,5 +12,6 @@
>>  #ifdef __NR_faccessat
>>  _syscall4(int, faccessat, int, fd, const char *, file, int, type, int, flag)
>>  #else
>> +libc_hidden_def(faccessat)
>
> Shouldn't this be in the #ifdef part !
>
>>  /* should add emulation with faccess() and /proc/self/fd/ ... */
>>  #endif
>>
>

Yes that is correct.  Thanks

-- 
Regards,
Markos


More information about the uClibc mailing list