diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2016-11-10 09:28:00 -0200 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2016-11-16 15:53:58 -0200 |
commit | afcf3cd8ebff8fed79238a2d1b95338c4606b1ee (patch) | |
tree | 0e21226d1c0fac1db0af0c829c093d59b121eb85 /sysdeps/nacl | |
parent | 530862a63e0929128dc98fbbd463b120934434fb (diff) | |
download | glibc-afcf3cd8ebff8fed79238a2d1b95338c4606b1ee.tar.gz |
New internal function __access_noerrno
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.
Diffstat (limited to 'sysdeps/nacl')
-rw-r--r-- | sysdeps/nacl/access.c | 7 | ||||
-rw-r--r-- | sysdeps/nacl/nacl-interfaces.h | 4 |
2 files changed, 11 insertions, 0 deletions
diff --git a/sysdeps/nacl/access.c b/sysdeps/nacl/access.c index 95a0fb726b..e07d5582d6 100644 --- a/sysdeps/nacl/access.c +++ b/sysdeps/nacl/access.c @@ -19,6 +19,13 @@ #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) diff --git a/sysdeps/nacl/nacl-interfaces.h b/sysdeps/nacl/nacl-interfaces.h index b7b45bbf38..edd3217489 100644 --- a/sysdeps/nacl/nacl-interfaces.h +++ b/sysdeps/nacl/nacl-interfaces.h @@ -113,4 +113,8 @@ __nacl_fail (int err) #define NACL_CALL(err, val) \ ({ int _err = (err); _err ? __nacl_fail (_err) : (val); }) +/* Same as NACL_CALL but without setting errno. */ +#define NACL_CALL_NOERRNO(err, val) \ + ({ int _err = (err); _err ? _err : (val); }) + #endif /* nacl-interfaces.h */ |