diff options
Diffstat (limited to 'sysdeps/unix/sysv')
-rw-r--r-- | sysdeps/unix/sysv/linux/Versions | 1 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/fips-private.h | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/gethostid.c | 4 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/getloadavg.c | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/getlogin_r.c | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/getsysstats.c | 6 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/grantpt.c | 4 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/smp.h | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/ia64/has_cpuclock.c | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/libc_fatal.c | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/malloc-sysdep.h | 4 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/not-cancel.h | 20 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/open.c | 21 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/open64.c | 38 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/pthread_getname.c | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/pthread_setname.c | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/spawni.c | 2 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/sysconf.c | 2 |
19 files changed, 82 insertions, 38 deletions
diff --git a/sysdeps/unix/sysv/linux/Versions b/sysdeps/unix/sysv/linux/Versions index 202ffccc29..3c64077f05 100644 --- a/sysdeps/unix/sysv/linux/Versions +++ b/sysdeps/unix/sysv/linux/Versions @@ -169,6 +169,7 @@ libc { GLIBC_PRIVATE { # functions used in other libraries __syscall_rt_sigqueueinfo; + __open_nocancel; # functions used by nscd __netlink_assert_response; } diff --git a/sysdeps/unix/sysv/linux/fips-private.h b/sysdeps/unix/sysv/linux/fips-private.h index c9fe26695c..3a83a0f158 100644 --- a/sysdeps/unix/sysv/linux/fips-private.h +++ b/sysdeps/unix/sysv/linux/fips-private.h @@ -42,7 +42,7 @@ fips_enabled_p (void) if (checked == FIPS_UNTESTED) { - int fd = open_not_cancel_2 ("/proc/sys/crypto/fips_enabled", O_RDONLY); + int fd = __open_nocancel ("/proc/sys/crypto/fips_enabled", O_RDONLY); if (fd != -1) { diff --git a/sysdeps/unix/sysv/linux/gethostid.c b/sysdeps/unix/sysv/linux/gethostid.c index cc108aa2d6..3ea8656b05 100644 --- a/sysdeps/unix/sysv/linux/gethostid.c +++ b/sysdeps/unix/sysv/linux/gethostid.c @@ -47,7 +47,7 @@ sethostid (long int id) } /* Open file for writing. Everybody is allowed to read this file. */ - fd = open_not_cancel (HOSTIDFILE, O_CREAT|O_WRONLY|O_TRUNC, 0644); + fd = __open_nocancel (HOSTIDFILE, O_CREAT|O_WRONLY|O_TRUNC, 0644); if (fd < 0) return -1; @@ -77,7 +77,7 @@ gethostid (void) int fd; /* First try to get the ID from a former invocation of sethostid. */ - fd = open_not_cancel (HOSTIDFILE, O_RDONLY|O_LARGEFILE, 0); + fd = __open_nocancel (HOSTIDFILE, O_RDONLY|O_LARGEFILE, 0); if (fd >= 0) { ssize_t n = read_not_cancel (fd, &id, sizeof (id)); diff --git a/sysdeps/unix/sysv/linux/getloadavg.c b/sysdeps/unix/sysv/linux/getloadavg.c index 117f8c2b38..0bfe41dae4 100644 --- a/sysdeps/unix/sysv/linux/getloadavg.c +++ b/sysdeps/unix/sysv/linux/getloadavg.c @@ -33,7 +33,7 @@ getloadavg (double loadavg[], int nelem) { int fd; - fd = open_not_cancel_2 ("/proc/loadavg", O_RDONLY); + fd = __open_nocancel ("/proc/loadavg", O_RDONLY); if (fd < 0) return -1; else diff --git a/sysdeps/unix/sysv/linux/getlogin_r.c b/sysdeps/unix/sysv/linux/getlogin_r.c index 05ac36b491..2519792267 100644 --- a/sysdeps/unix/sysv/linux/getlogin_r.c +++ b/sysdeps/unix/sysv/linux/getlogin_r.c @@ -34,7 +34,7 @@ int attribute_hidden __getlogin_r_loginuid (char *name, size_t namesize) { - int fd = open_not_cancel_2 ("/proc/self/loginuid", O_RDONLY); + int fd = __open_nocancel ("/proc/self/loginuid", O_RDONLY); if (fd == -1) return -1; diff --git a/sysdeps/unix/sysv/linux/getsysstats.c b/sysdeps/unix/sysv/linux/getsysstats.c index a0dd6ebe93..e21a34cb9b 100644 --- a/sysdeps/unix/sysv/linux/getsysstats.c +++ b/sysdeps/unix/sysv/linux/getsysstats.c @@ -143,7 +143,7 @@ __get_nprocs (void) char *re = buffer_end; const int flags = O_RDONLY | O_CLOEXEC; - int fd = open_not_cancel_2 ("/sys/devices/system/cpu/online", flags); + int fd = __open_nocancel ("/sys/devices/system/cpu/online", flags); char *l; int result = 0; if (fd != -1) @@ -194,7 +194,7 @@ __get_nprocs (void) result = 2; /* The /proc/stat format is more uniform, use it by default. */ - fd = open_not_cancel_2 ("/proc/stat", flags); + fd = __open_nocancel ("/proc/stat", flags); if (fd != -1) { result = 0; @@ -211,7 +211,7 @@ __get_nprocs (void) } else { - fd = open_not_cancel_2 ("/proc/cpuinfo", flags); + fd = __open_nocancel ("/proc/cpuinfo", flags); if (fd != -1) { GET_NPROCS_PARSER (fd, buffer, cp, re, buffer_end, result); diff --git a/sysdeps/unix/sysv/linux/grantpt.c b/sysdeps/unix/sysv/linux/grantpt.c index 8cebde36ed..97c6ba7997 100644 --- a/sysdeps/unix/sysv/linux/grantpt.c +++ b/sysdeps/unix/sysv/linux/grantpt.c @@ -31,9 +31,9 @@ close_all_fds (void) __closedir (dir); - int nullfd = open_not_cancel_2 (_PATH_DEVNULL, O_RDONLY); + int nullfd = __open_nocancel (_PATH_DEVNULL, O_RDONLY); assert (nullfd == STDIN_FILENO); - nullfd = open_not_cancel_2 (_PATH_DEVNULL, O_WRONLY); + nullfd = __open_nocancel (_PATH_DEVNULL, O_WRONLY); assert (nullfd == STDOUT_FILENO); __dup2 (STDOUT_FILENO, STDERR_FILENO); } diff --git a/sysdeps/unix/sysv/linux/i386/smp.h b/sysdeps/unix/sysv/linux/i386/smp.h index 3109ea9937..c24f2fd748 100644 --- a/sysdeps/unix/sysv/linux/i386/smp.h +++ b/sysdeps/unix/sysv/linux/i386/smp.h @@ -41,7 +41,7 @@ is_smp_system (void) else { /* This was not successful. Now try reading the /proc filesystem. */ - int fd = open_not_cancel_2 ("/proc/sys/kernel/version", O_RDONLY); + int fd = __open_nocancel ("/proc/sys/kernel/version", O_RDONLY); if (__builtin_expect (fd, 0) == -1 || read_not_cancel (fd, u.buf, sizeof (u.buf)) <= 0) /* This also didn't work. We give up and say it's a UP machine. */ diff --git a/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c b/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c index 2207c88c47..04e395bc8d 100644 --- a/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c +++ b/sysdeps/unix/sysv/linux/ia64/has_cpuclock.c @@ -30,7 +30,7 @@ has_cpuclock (void) if (__builtin_expect (itc_usable == 0, 0)) { int newval = 1; - int fd = open_not_cancel_2 ("/proc/sal/itc_drift", O_RDONLY); + int fd = __open_nocancel ("/proc/sal/itc_drift", O_RDONLY); if (__builtin_expect (fd != -1, 1)) { char buf[16]; diff --git a/sysdeps/unix/sysv/linux/libc_fatal.c b/sysdeps/unix/sysv/linux/libc_fatal.c index d22bfdcc67..5b484cf591 100644 --- a/sysdeps/unix/sysv/linux/libc_fatal.c +++ b/sysdeps/unix/sysv/linux/libc_fatal.c @@ -53,7 +53,7 @@ backtrace_and_maps (int do_abort, bool written, int fd) __backtrace_symbols_fd (addrs + 1, n - 1, fd); writestr (strnsize ("======= Memory map: ========\n")); - int fd2 = open_not_cancel_2 ("/proc/self/maps", O_RDONLY); + int fd2 = __open_nocancel ("/proc/self/maps", O_RDONLY); char buf[1024]; ssize_t n2; while ((n2 = read_not_cancel (fd2, buf, sizeof (buf))) > 0) diff --git a/sysdeps/unix/sysv/linux/malloc-sysdep.h b/sysdeps/unix/sysv/linux/malloc-sysdep.h index 48cf7c157c..cb87b58637 100644 --- a/sysdeps/unix/sysv/linux/malloc-sysdep.h +++ b/sysdeps/unix/sysv/linux/malloc-sysdep.h @@ -42,8 +42,8 @@ check_may_shrink_heap (void) if (__builtin_expect (may_shrink_heap == 0, 1)) { - int fd = open_not_cancel_2 ("/proc/sys/vm/overcommit_memory", - O_RDONLY | O_CLOEXEC); + int fd = __open_nocancel ("/proc/sys/vm/overcommit_memory", + O_RDONLY | O_CLOEXEC); if (fd >= 0) { char val; diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h index 43959bad83..8d897f0a4c 100644 --- a/sysdeps/unix/sysv/linux/not-cancel.h +++ b/sysdeps/unix/sysv/linux/not-cancel.h @@ -20,23 +20,19 @@ #ifndef NOT_CANCEL_H # define NOT_CANCEL_H +#include <fcntl.h> #include <sysdep.h> #include <errno.h> #include <unistd.h> #include <sys/syscall.h> -/* Uncancelable open. */ -#ifdef __NR_open -# define open_not_cancel(name, flags, mode) \ - INLINE_SYSCALL (open, 3, name, flags, mode) -# define open_not_cancel_2(name, flags) \ - INLINE_SYSCALL (open, 2, name, flags) -#else -# define open_not_cancel(name, flags, mode) \ - INLINE_SYSCALL (openat, 4, AT_FDCWD, name, flags, mode) -# define open_not_cancel_2(name, flags) \ - INLINE_SYSCALL (openat, 3, AT_FDCWD, name, flags) -#endif +/* Non cancellable open syscall. */ +__typeof (open) __open_nocancel; +libc_hidden_proto (__open_nocancel) + +/* Non cancellable open syscall (LFS version). */ +__typeof (open64) __open64_nocancel; +libc_hidden_proto (__open64_nocancel) /* Uncancelable read. */ #define __read_nocancel(fd, buf, len) \ diff --git a/sysdeps/unix/sysv/linux/open.c b/sysdeps/unix/sysv/linux/open.c index b3912d5554..3ef0e53e4c 100644 --- a/sysdeps/unix/sysv/linux/open.c +++ b/sysdeps/unix/sysv/linux/open.c @@ -22,6 +22,7 @@ #include <stdarg.h> #include <sysdep-cancel.h> +#include <not-cancel.h> #ifndef __OFF_T_MATCHES_OFF64_T @@ -48,4 +49,24 @@ weak_alias (__libc_open, __open) libc_hidden_weak (__open) weak_alias (__libc_open, open) +# if !IS_IN (rtld) +int +__open_nocancel (const char *file, int oflag, ...) +{ + int mode = 0; + + if (__OPEN_NEEDS_MODE (oflag)) + { + va_list arg; + va_start (arg, oflag); + mode = va_arg (arg, int); + va_end (arg); + } + + return INLINE_SYSCALL_CALL (openat, AT_FDCWD, file, oflag, mode); +} +# else +strong_alias (__libc_open, __open_nocancel) +# endif +libc_hidden_def (__open_nocancel) #endif diff --git a/sysdeps/unix/sysv/linux/open64.c b/sysdeps/unix/sysv/linux/open64.c index fcac984d22..b4702c33b7 100644 --- a/sysdeps/unix/sysv/linux/open64.c +++ b/sysdeps/unix/sysv/linux/open64.c @@ -21,6 +21,13 @@ #include <stdarg.h> #include <sysdep-cancel.h> +#include <not-cancel.h> + +#ifdef __OFF_T_MATCHES_OFF64_T +# define EXTRA_OPEN_FLAGS 0 +#else +# define EXTRA_OPEN_FLAGS O_LARGEFILE +#endif /* Open FILE with access OFLAG. If O_CREAT or O_TMPFILE is in OFLAG, a third argument is the file protection. */ @@ -37,12 +44,6 @@ __libc_open64 (const char *file, int oflag, ...) va_end (arg); } -#ifdef __OFF_T_MATCHES_OFF64_T -# define EXTRA_OPEN_FLAGS 0 -#else -# define EXTRA_OPEN_FLAGS O_LARGEFILE -#endif - return SYSCALL_CANCEL (openat, AT_FDCWD, file, oflag | EXTRA_OPEN_FLAGS, mode); } @@ -51,9 +52,34 @@ strong_alias (__libc_open64, __open64) libc_hidden_weak (__open64) weak_alias (__libc_open64, open64) +# if !IS_IN (rtld) +int +__open64_nocancel (const char *file, int oflag, ...) +{ + int mode = 0; + + if (__OPEN_NEEDS_MODE (oflag)) + { + va_list arg; + va_start (arg, oflag); + mode = va_arg (arg, int); + va_end (arg); + } + + return INLINE_SYSCALL_CALL (openat, AT_FDCWD, file, oflag | EXTRA_OPEN_FLAGS, + mode); +} +#else +strong_alias (__libc_open64, __open64_nocancel) +#endif +libc_hidden_def (__open64_nocancel) + #ifdef __OFF_T_MATCHES_OFF64_T strong_alias (__libc_open64, __libc_open) strong_alias (__libc_open64, __open) libc_hidden_weak (__open) weak_alias (__libc_open64, open) + +strong_alias (__open64_nocancel, __open_nocancel) +libc_hidden_weak (__open_nocancel) #endif diff --git a/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c b/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c index b8d01d8ca6..c99e7de23a 100644 --- a/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c +++ b/sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c @@ -40,7 +40,7 @@ __get_clockfreq (void) contains at least one line like: timebase : 33333333 We search for this line and convert the number into an integer. */ - int fd = open_not_cancel_2 ("/proc/cpuinfo", O_RDONLY); + int fd = __open_nocancel ("/proc/cpuinfo", O_RDONLY); if (__glibc_likely (fd != -1)) return result; diff --git a/sysdeps/unix/sysv/linux/pthread_getname.c b/sysdeps/unix/sysv/linux/pthread_getname.c index 9a5343a1d5..caab2ccb25 100644 --- a/sysdeps/unix/sysv/linux/pthread_getname.c +++ b/sysdeps/unix/sysv/linux/pthread_getname.c @@ -45,7 +45,7 @@ pthread_getname_np (pthread_t th, char *buf, size_t len) char fname[sizeof (FMT) + 8]; sprintf (fname, FMT, (unsigned int) pd->tid); - int fd = open_not_cancel_2 (fname, O_RDONLY); + int fd = __open_nocancel (fname, O_RDONLY); if (fd == -1) return errno; diff --git a/sysdeps/unix/sysv/linux/pthread_setname.c b/sysdeps/unix/sysv/linux/pthread_setname.c index 5769c5b460..93f0e9ddde 100644 --- a/sysdeps/unix/sysv/linux/pthread_setname.c +++ b/sysdeps/unix/sysv/linux/pthread_setname.c @@ -46,7 +46,7 @@ pthread_setname_np (pthread_t th, const char *name) char fname[sizeof (FMT) + 8]; sprintf (fname, FMT, (unsigned int) pd->tid); - int fd = open_not_cancel_2 (fname, O_RDWR); + int fd = __open_nocancel (fname, O_RDWR); if (fd == -1) return errno; diff --git a/sysdeps/unix/sysv/linux/spawni.c b/sysdeps/unix/sysv/linux/spawni.c index c56f894a82..4994a07491 100644 --- a/sysdeps/unix/sysv/linux/spawni.c +++ b/sysdeps/unix/sysv/linux/spawni.c @@ -230,7 +230,7 @@ __spawni_child (void *arguments) paths (like /dev/watchdog). */ close_not_cancel (action->action.open_action.fd); - int ret = open_not_cancel (action->action.open_action.path, + int ret = __open_nocancel (action->action.open_action.path, action->action. open_action.oflag | O_LARGEFILE, action->action.open_action.mode); diff --git a/sysdeps/unix/sysv/linux/sysconf.c b/sysdeps/unix/sysv/linux/sysconf.c index db20977cb8..ab068ab43f 100644 --- a/sysdeps/unix/sysv/linux/sysconf.c +++ b/sysdeps/unix/sysv/linux/sysconf.c @@ -115,7 +115,7 @@ __sysconf (int name) if (procfname != NULL) { - int fd = open_not_cancel_2 (procfname, O_RDONLY); + int fd = __open_nocancel (procfname, O_RDONLY); if (fd != -1) { /* This is more than enough, the file contains a single integer. */ |