From d369ad760d0a2bc585cb5b076a67d565573ee915 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Sun, 12 Feb 2006 21:41:44 +0000 Subject: [BZ #2226] 2006-02-12 Ulrich Drepper * io/ftw.c: Start using *at functions. * io/ftw64.c: Likewise. * sysdeps/generic/not-cancel.h: Define openat_not_cancel, openat_not_cancel_3, openat64_not_cancel, and openat64_not_cancel_3. * sysdeps/unix/sysv/linux/not-cancel.h: Likewise. * sysdeps/unix/sysv/linux/openat.c: Create separate _nocancel functions. * io/fxstatat.c: Add __fxstatat alias. * sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c: Likewise. * sysdeps/unix/sysv/linux/fxstatat.c: Likewise. Add support for newfstatat syscall. * sysdeps/unix/sysv/linux/i386/fxstatat.c: Add __fxstatat alias. Add support for fstatat64 syscall. * include/sys/stat.h: Declare __fxstatat. * io/fxstatat64.c: Add __fxstatat64 alias. * sysdeps/unix/sysv/linux/fxstatat64.c: Add support for fstatat64 syscall. * dirent/fdopendir.c: Add __fdopendir alias. * sysdeps/unix/fdopendir.c: Likewise. * sysdeps/mach/hurd/fdopendir.c: Likewise. * include/dirent.h: Add __fdopendir declaration. [BZ #2226] * libio/wgenops.c (_IO_wsetb): Use correct size of wide char buffer in FREE_BUF call. --- sysdeps/unix/sysv/linux/openat.c | 75 +++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 32 deletions(-) (limited to 'sysdeps/unix/sysv/linux/openat.c') diff --git a/sysdeps/unix/sysv/linux/openat.c b/sysdeps/unix/sysv/linux/openat.c index 4c1f302ab0..38ffe85b56 100644 --- a/sysdeps/unix/sysv/linux/openat.c +++ b/sysdeps/unix/sysv/linux/openat.c @@ -25,6 +25,7 @@ #include #include #include +#include #if !defined OPENAT && !defined __ASSUME_ATFCTS @@ -62,23 +63,19 @@ __atfct_seterrno (int errval, int fd, const char *buf) int __have_atfcts; #endif -/* Open FILE with access OFLAG. Interpret relative paths relative to - the directory associated with FD. If OFLAG includes O_CREAT, a - third argument is the file protection. */ + +#define OPENAT_NOT_CANCEL CONCAT (OPENAT) +#define CONCAT(name) CONCAT2 (name) +#define CONCAT2(name) __##name##_nocancel + + int -OPENAT (fd, file, oflag) +OPENAT_NOT_CANCEL (fd, file, oflag, mode) int fd; const char *file; int oflag; + mode_t mode; { - mode_t mode = 0; - if (oflag & O_CREAT) - { - va_list arg; - va_start (arg, oflag); - mode = va_arg (arg, mode_t); - va_end (arg); - } /* We have to add the O_LARGEFILE flag for openat64. */ #ifdef MORE_OFLAGS @@ -93,16 +90,7 @@ OPENAT (fd, file, oflag) if (__have_atfcts >= 0) # endif { - if (SINGLE_THREAD_P) - res = INLINE_SYSCALL (openat, 4, fd, file, oflag, mode); - else - { - int oldtype = LIBC_CANCEL_ASYNC (); - - res = INLINE_SYSCALL (openat, 4, fd, file, oflag, mode); - - LIBC_CANCEL_RESET (oldtype); - } + res = INLINE_SYSCALL (openat, 4, fd, file, oflag, mode); # ifndef __ASSUME_ATFCTS if (res == -1 && errno == ENOSYS) @@ -130,20 +118,12 @@ OPENAT (fd, file, oflag) size_t buflen = sizeof (procfd) + sizeof (int) * 3 + filelen; buf = alloca (buflen); + /* Note: snprintf cannot be canceled. */ __snprintf (buf, buflen, procfd, fd, file); file = buf; } - if (SINGLE_THREAD_P) - res = INTERNAL_SYSCALL (open, err, 3, file, oflag, mode); - else - { - int oldtype = LIBC_CANCEL_ASYNC (); - - res = INTERNAL_SYSCALL (open, err, 3, file, oflag, mode); - - LIBC_CANCEL_RESET (oldtype); - } + res = INTERNAL_SYSCALL (open, err, 3, file, oflag, mode); if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (res, err), 0)) { @@ -154,3 +134,34 @@ OPENAT (fd, file, oflag) return res; #endif } + + +/* Open FILE with access OFLAG. Interpret relative paths relative to + the directory associated with FD. If OFLAG includes O_CREAT, a + third argument is the file protection. */ +int +OPENAT (fd, file, oflag) + int fd; + const char *file; + int oflag; +{ + mode_t mode = 0; + if (oflag & O_CREAT) + { + va_list arg; + va_start (arg, oflag); + mode = va_arg (arg, mode_t); + va_end (arg); + } + + if (SINGLE_THREAD_P) + return OPENAT_NOT_CANCEL (fd, file, oflag, mode); + + int oldtype = LIBC_CANCEL_ASYNC (); + + int res = OPENAT_NOT_CANCEL (fd, file, oflag, mode); + + LIBC_CANCEL_RESET (oldtype); + + return res; +} -- cgit v1.2.3