mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-25 06:20:06 +00:00
afcf3cd8eb
Implement an internal version of __access called __access_noerrno that avoids setting errno. This is useful to check accessibility of files very early on in process startup i.e. before TLS setup. This allows tunables to replace MALLOC_CHECK_ safely (i.e. check existence of /etc/suid-debug to enable/disable MALLOC_CHECK) and at the same time initialize very early so that it can override IFUNCs. Checked on x86_64. * hurd/hurd.h (__hurd_fail_noerrno): New function. * include/unistd.h [IS_IN (rtld) || !defined SHARED]: Declare __access_noerrno. * io/access.c (__access_noerrno): New function. * sysdeps/mach/hurd/access.c (hurd_fail_seterrno): New function. (hurd_fail_seterrno): Likewise. (access_common): Likewise. (__access_noerrno): Likewise. * sysdeps/nacl/access.c (__access_noerrno): Likewise. * sysdeps/unix/sysv/linux/access.c (__access_noerrno): Likewise. * sysdeps/nacl/nacl-interfaces.h (NACL_CALL_NOERRNO): New macro.
36 lines
1.2 KiB
C
36 lines
1.2 KiB
C
/* Check file access permission. NaCl version.
|
|
Copyright (C) 2015-2016 Free Software Foundation, Inc.
|
|
This file is part of the GNU C Library.
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
modify it under the terms of the GNU Lesser General Public
|
|
License as published by the Free Software Foundation; either
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
License along with the GNU C Library; if not, see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
#include <unistd.h>
|
|
#include <nacl-interfaces.h>
|
|
|
|
/* Test for access to FILE without setting errno. */
|
|
int
|
|
__access_noerrno (const char *file, int type)
|
|
{
|
|
return NACL_CALL_NOERRNO (__nacl_irt_dev_filename.access (file, type), 0);
|
|
}
|
|
|
|
/* Test for access to FILE. */
|
|
int
|
|
__access (const char *file, int type)
|
|
{
|
|
return NACL_CALL (__nacl_irt_dev_filename.access (file, type), 0);
|
|
}
|
|
weak_alias (__access, access)
|