about summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/generic/not-cancel.h10
-rw-r--r--sysdeps/mach/hurd/fdopendir.c5
-rw-r--r--sysdeps/unix/fdopendir.c3
-rw-r--r--sysdeps/unix/sysv/linux/fxstatat.c44
-rw-r--r--sysdeps/unix/sysv/linux/fxstatat64.c54
-rw-r--r--sysdeps/unix/sysv/linux/i386/fxstatat.c51
-rw-r--r--sysdeps/unix/sysv/linux/not-cancel.h17
-rw-r--r--sysdeps/unix/sysv/linux/openat.c75
-rw-r--r--sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c1
9 files changed, 191 insertions, 69 deletions
diff --git a/sysdeps/generic/not-cancel.h b/sysdeps/generic/not-cancel.h
index 396e0421f9..427be6475f 100644
--- a/sysdeps/generic/not-cancel.h
+++ b/sysdeps/generic/not-cancel.h
@@ -1,5 +1,5 @@
 /* Uncancelable versions of cancelable interfaces.  Generic version.
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
 
@@ -23,6 +23,14 @@
   __libc_open (name, flags, mode)
 #define open_not_cancel_2(name, flags) \
   __libc_open (name, flags)
+#define openat_not_cancel(fd, name, flags, mode) \
+  __openat (fd, name, flags, mode)
+#define openat_not_cancel_3(fd, name, flags) \
+  __openat (fd, name, flags, 0)
+#define openat64_not_cancel(fd, name, flags, mode) \
+  __openat64 (fd, name, flags, mode)
+#define openat64_not_cancel_3(fd, name, flags) \
+  __openat64 (fd, name, flags, 0)
 #define close_not_cancel(fd) \
   __close (fd)
 #define close_not_cancel_no_status(fd) \
diff --git a/sysdeps/mach/hurd/fdopendir.c b/sysdeps/mach/hurd/fdopendir.c
index 37dd4bc82e..c9caac30d7 100644
--- a/sysdeps/mach/hurd/fdopendir.c
+++ b/sysdeps/mach/hurd/fdopendir.c
@@ -1,5 +1,5 @@
 /* Open a directory stream from a file descriptor.  Hurd version.
-   Copyright (C) 2005 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006 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
@@ -27,7 +27,7 @@ DIR *_hurd_fd_opendir (struct hurd_fd *d); /* opendir.c */
 
 /* Open a directory stream on FD.  */
 DIR *
-fdopendir (int fd)
+__fdopendir (int fd)
 {
   struct hurd_fd *d = _hurd_fd_get (fd);
 
@@ -54,3 +54,4 @@ fdopendir (int fd)
 
   return _hurd_fd_opendir (d);
 }
+weak_alias (__fdopendir, fdopendir)
diff --git a/sysdeps/unix/fdopendir.c b/sysdeps/unix/fdopendir.c
index 528f180fcb..565ce1ed72 100644
--- a/sysdeps/unix/fdopendir.c
+++ b/sysdeps/unix/fdopendir.c
@@ -25,7 +25,7 @@
 
 
 DIR *
-fdopendir (int fd)
+__fdopendir (int fd)
 {
   struct stat64 statbuf;
 
@@ -49,3 +49,4 @@ fdopendir (int fd)
 
   return __alloc_dir (fd, false, &statbuf);
 }
+weak_alias (__fdopendir, fdopendir)
diff --git a/sysdeps/unix/sysv/linux/fxstatat.c b/sysdeps/unix/sysv/linux/fxstatat.c
index 77debf71d3..c1c416abd7 100644
--- a/sysdeps/unix/sysv/linux/fxstatat.c
+++ b/sysdeps/unix/sysv/linux/fxstatat.c
@@ -37,6 +37,42 @@
 int
 __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
 {
+  int result;
+  INTERNAL_SYSCALL_DECL (err);
+#ifdef STAT_IS_KERNEL_STAT
+# define kst (*st)
+#else
+  struct kernel_stat kst;
+#endif
+
+#ifdef __NR_newfstatat
+# ifndef __ASSUME_ATFCTS
+  if (__have_atfcts >= 0)
+# endif
+    {
+      result = INTERNAL_SYSCALL (newfstatat, err, 4, fd, file, &kst, flag);
+# ifndef __ASSUME_ATFCTS
+      if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 1)
+	  && INTERNAL_SYSCALL_ERRNO (result, err) == ENOSYS)
+	__have_atfcts = -1;
+      else
+# endif
+	if (!__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 1))
+	  {
+#ifdef STAT_IS_KERNEL_STAT
+	    return 0;
+#else
+	    return __xstat_conv (vers, &kst, st);
+#endif
+	  }
+	else
+	  {
+	    __set_errno (INTERNAL_SYSCALL_ERRNO (result, err));
+	    return -1;
+	  }
+    }
+#endif
+
   if (flag & ~AT_SYMLINK_NOFOLLOW)
     {
       __set_errno (EINVAL);
@@ -63,9 +99,6 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
       file = buf;
     }
 
-  int result;
-  INTERNAL_SYSCALL_DECL (err);
-
   if (vers == _STAT_VER_KERNEL)
     {
       if (flag & AT_SYMLINK_NOFOLLOW)
@@ -85,8 +118,6 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
       return -1;
     }
 #else
-  struct kernel_stat kst;
-
   if (flag & AT_SYMLINK_NOFOLLOW)
     result = INTERNAL_SYSCALL (lstat, err, 2, CHECK_STRING (file),
 			       __ptrvalue (&kst));
@@ -102,8 +133,9 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
 
   return -1;
 }
+libc_hidden_def (__fxstatat)
 #ifdef XSTAT_IS_XSTAT64
 # undef __fxstatat64
 strong_alias (__fxstatat, __fxstatat64);
-libc_hidden_ver (__fxstatat, __fxstatat64)
+libc_hidden_def (__fxstatat64)
 #endif
diff --git a/sysdeps/unix/sysv/linux/fxstatat64.c b/sysdeps/unix/sysv/linux/fxstatat64.c
index 220d4abfcf..cb932b8e59 100644
--- a/sysdeps/unix/sysv/linux/fxstatat64.c
+++ b/sysdeps/unix/sysv/linux/fxstatat64.c
@@ -47,6 +47,38 @@ extern int __have_no_stat64;
 int
 __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
 {
+  if (__builtin_expect (vers != _STAT_VER_LINUX, 0))
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  int result;
+  INTERNAL_SYSCALL_DECL (err);
+
+#ifdef __NR_fstatat64
+# ifndef __ASSUME_ATFCTS
+  if (__have_atfcts >= 0)
+# endif
+    {
+      result = INTERNAL_SYSCALL (fstatat64, err, 4, fd, file, st, flag);
+# ifndef __ASSUME_ATFCTS
+      if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 1)
+	  && INTERNAL_SYSCALL_ERRNO (result, err) == ENOSYS)
+	__have_atfcts = -1;
+      else
+# endif
+	if (!__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 1))
+	  return 0;
+	else
+	  {
+	    __set_errno (INTERNAL_SYSCALL_ERRNO (result, err));
+	    return -1;
+	  }
+    }
+#endif
+
+#ifndef __ASSUME_ATFCTS
   if (flag & ~AT_SYMLINK_NOFOLLOW)
     {
       __set_errno (EINVAL);
@@ -73,10 +105,7 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
       file = buf;
     }
 
-  int result;
-  INTERNAL_SYSCALL_DECL (err);
-
-#if __ASSUME_STAT64_SYSCALL > 0
+# if __ASSUME_STAT64_SYSCALL > 0
   if (flag & AT_SYMLINK_NOFOLLOW)
     result = INTERNAL_SYSCALL (lstat64, err, 2, CHECK_STRING (file),
 			       CHECK_1 (st));
@@ -85,15 +114,15 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
 			       CHECK_1 (st));
   if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
     {
-# if defined _HAVE_STAT64___ST_INO && __ASSUME_ST_INO_64_BIT == 0
+#  if defined _HAVE_STAT64___ST_INO && __ASSUME_ST_INO_64_BIT == 0
       if (st->__st_ino != (__ino_t) st->st_ino)
 	st->st_ino = st->__st_ino;
-# endif
+#  endif
       return result;
     }
-#else
+# else
   struct kernel_stat kst;
-# if defined __NR_stat64
+#  ifdef __NR_stat64
   if (! __have_no_stat64)
     {
       if (flag & AT_SYMLINK_NOFOLLOW)
@@ -105,10 +134,10 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
 
       if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
 	{
-#  if defined _HAVE_STAT64___ST_INO && __ASSUME_ST_INO_64_BIT == 0
+#   if defined _HAVE_STAT64___ST_INO && __ASSUME_ST_INO_64_BIT == 0
 	  if (st->__st_ino != (__ino_t) st->st_ino)
 	    st->st_ino = st->__st_ino;
-#  endif
+#   endif
 	  return result;
 	}
       if (INTERNAL_SYSCALL_ERRNO (result, err) != ENOSYS)
@@ -116,7 +145,7 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
 
       __have_no_stat64 = 1;
     }
-# endif
+#  endif
 
   if (flag & AT_SYMLINK_NOFOLLOW)
     result = INTERNAL_SYSCALL (lstat, err, 2, CHECK_STRING (file),
@@ -129,9 +158,10 @@ __fxstatat64 (int vers, int fd, const char *file, struct stat64 *st, int flag)
     return __xstat64_conv (vers, &kst, st);
 
  fail:
-#endif
+# endif
   __atfct_seterrno (INTERNAL_SYSCALL_ERRNO (result, err), fd, buf);
 
   return -1;
+#endif
 }
 libc_hidden_def (__fxstatat64)
diff --git a/sysdeps/unix/sysv/linux/i386/fxstatat.c b/sysdeps/unix/sysv/linux/i386/fxstatat.c
index 65fab5179c..b077435553 100644
--- a/sysdeps/unix/sysv/linux/i386/fxstatat.c
+++ b/sysdeps/unix/sysv/linux/i386/fxstatat.c
@@ -48,6 +48,33 @@ extern int __have_no_stat64;
 int
 __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
 {
+  int result;
+  INTERNAL_SYSCALL_DECL (err);
+  struct stat64 st64;
+
+#ifdef __NR_fstatat64
+# ifndef __ASSUME_ATFCTS
+  if (__have_atfcts >= 0)
+# endif
+    {
+      result = INTERNAL_SYSCALL (fstatat64, err, 4, fd, file, &st64, flag);
+# ifndef __ASSUME_ATFCTS
+      if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 1)
+	  && INTERNAL_SYSCALL_ERRNO (result, err) == ENOSYS)
+	__have_atfcts = -1;
+      else
+# endif
+	if (!__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 1))
+	  return __xstat32_conv (vers, &st64, st);
+	else
+	  {
+	    __set_errno (INTERNAL_SYSCALL_ERRNO (result, err));
+	    return -1;
+	  }
+    }
+#endif
+
+#ifndef __ASSUME_ATFCTS
   if (__builtin_expect (flag & ~AT_SYMLINK_NOFOLLOW, 0))
     {
       __set_errno (EINVAL);
@@ -74,12 +101,9 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
       file = buf;
     }
 
-#if __ASSUME_STAT64_SYSCALL == 0
+# if __ASSUME_STAT64_SYSCALL == 0
   struct kernel_stat kst;
-#endif
-  int result;
-  INTERNAL_SYSCALL_DECL (err);
-
+# endif
   if (vers == _STAT_VER_KERNEL)
     {
       if (flag & AT_SYMLINK_NOFOLLOW)
@@ -91,8 +115,7 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
       goto out;
     }
 
-#if __ASSUME_STAT64_SYSCALL > 0
-  struct stat64 st64;
+# if __ASSUME_STAT64_SYSCALL > 0
 
   if (flag & AT_SYMLINK_NOFOLLOW)
     result = INTERNAL_SYSCALL (lstat64, err, 2, CHECK_STRING (file),
@@ -102,14 +125,12 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
 			       __ptrvalue (&st64));
   if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
     return __xstat32_conv (vers, &st64, st);
-#else
-# if defined __NR_stat64
+# else
+#  if defined __NR_stat64
   /* To support 32 bit UIDs, we have to use stat64.  The normal stat
      call only returns 16 bit UIDs.  */
   if (! __have_no_stat64)
     {
-      struct stat64 st64;
-
       if (flag & AT_SYMLINK_NOFOLLOW)
 	result = INTERNAL_SYSCALL (lstat64, err, 2, CHECK_STRING (file),
 				   __ptrvalue (&st64));
@@ -126,7 +147,7 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
 
       __have_no_stat64 = 1;
     }
-# endif
+#  endif
   if (flag & AT_SYMLINK_NOFOLLOW)
     result = INTERNAL_SYSCALL (lstat, err, 2, CHECK_STRING (file),
 			       __ptrvalue (&kst));
@@ -135,7 +156,7 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
 			       __ptrvalue (&kst));
   if (__builtin_expect (!INTERNAL_SYSCALL_ERROR_P (result, err), 1))
     return __xstat_conv (vers, &kst, st);
-#endif  /* __ASSUME_STAT64_SYSCALL  */
+# endif  /* __ASSUME_STAT64_SYSCALL  */
 
  out:
   if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (result, err), 0))
@@ -145,9 +166,11 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
     }
 
   return result;
+#endif
 }
+libc_hidden_def (__fxstatat)
 #ifdef XSTAT_IS_XSTAT64
 # undef __fxstatat64
 strong_alias (__fxstatat, __fxstatat64);
-libc_hidden_ver (__fxstatat, __fxstatat64)
+libc_hidden_def (__fxstatat64)
 #endif
diff --git a/sysdeps/unix/sysv/linux/not-cancel.h b/sysdeps/unix/sysv/linux/not-cancel.h
index 9418417b45..ece8d69ecf 100644
--- a/sysdeps/unix/sysv/linux/not-cancel.h
+++ b/sysdeps/unix/sysv/linux/not-cancel.h
@@ -1,5 +1,5 @@
 /* Uncancelable versions of cancelable interfaces.  Linux version.
-   Copyright (C) 2003 Free Software Foundation, Inc.
+   Copyright (C) 2003, 2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
 
@@ -18,6 +18,7 @@
    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA.  */
 
+#include <sys/types.h>
 #include <sysdep.h>
 
 /* Uncancelable open.  */
@@ -26,6 +27,20 @@
 #define open_not_cancel_2(name, flags) \
    INLINE_SYSCALL (open, 2, (const char *) (name), (flags))
 
+/* Uncancelable openat.  */
+extern int __openat_not_cancel (int fd, const char *fname, int oflag,
+				mode_t mode) attribute_hidden;
+#define openat_not_cancel(fd, fname, oflag, mode) \
+  __openat_not_cancel (fd, fname, oflag, mode)
+#define openat_not_cancel_3(fd, fname, oflag) \
+  __openat_not_cancel (fd, fname, oflag, 0)
+extern int __openat64_not_cancel (int fd, const char *fname, int oflag,
+				  mode_t mode) attribute_hidden;
+#define openat64_not_cancel(fd, fname, oflag, mode) \
+  __openat64_not_cancel (fd, fname, oflag, mode)
+#define openat64_not_cancel_3(fd, fname, oflag) \
+  __openat64_not_cancel (fd, fname, oflag, 0)
+
 /* Uncancelable close.  */
 #define close_not_cancel(fd) \
   INLINE_SYSCALL (close, 1, fd)
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 <sys/stat.h>
 #include <kernel-features.h>
 #include <sysdep-cancel.h>
+#include <not-cancel.h>
 
 
 #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;
+}
diff --git a/sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c b/sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c
index 0c37495575..8b1c932ba9 100644
--- a/sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c
+++ b/sysdeps/unix/sysv/linux/wordsize-64/fxstatat.c
@@ -103,6 +103,7 @@ __fxstatat (int vers, int fd, const char *file, struct stat *st, int flag)
   return res;
 #endif
 }
+libc_hidden_def (__fxstatat)
 #undef __fxstatat64
 strong_alias (__fxstatat, __fxstatat64);
 strong_alias (__fxstatat64, __GI___fxstatat64)