ce426f
commit cc0e6ed81fa3ab0eeecfc576098b4522f0323c4b
ce426f
Author: Roland McGrath <roland@hack.frob.com>
ce426f
Date:   Fri May 3 16:33:26 2013 -0700
ce426f
ce426f
    Consolidate definitions of _FORTIFY_SOURCE wrappers for open{,64}{,at}.
ce426f
ce426f
Index: b/io/Makefile
ce426f
===================================================================
ce426f
--- a/io/Makefile
ce426f
+++ b/io/Makefile
ce426f
@@ -36,10 +36,10 @@ routines :=								\
ce426f
 	statvfs fstatvfs statvfs64 fstatvfs64				\
ce426f
 	umask chmod fchmod lchmod fchmodat				\
ce426f
 	mkdir mkdirat							\
ce426f
-	open open64 openat openat64 close				\
ce426f
+	open open_2 open64 open64_2 openat openat_2 openat64 openat64_2	\
ce426f
 	read write lseek lseek64 access euidaccess faccessat		\
ce426f
 	fcntl flock lockf lockf64					\
ce426f
-	dup dup2 dup3 pipe pipe2					\
ce426f
+	close dup dup2 dup3 pipe pipe2					\
ce426f
 	creat creat64							\
ce426f
 	chdir fchdir							\
ce426f
 	getcwd getwd getdirname						\
ce426f
Index: b/io/open.c
ce426f
===================================================================
ce426f
--- a/io/open.c
ce426f
+++ b/io/open.c
ce426f
@@ -22,7 +22,6 @@
ce426f
 #include <stddef.h>
ce426f
 #include <stdio.h>
ce426f
 
ce426f
-extern char **__libc_argv attribute_hidden;
ce426f
 
ce426f
 /* Open FILE with access OFLAG.  If OFLAG includes O_CREAT,
ce426f
    a third argument is the file protection.  */
ce426f
@@ -57,15 +56,6 @@ weak_alias (__libc_open, open)
ce426f
 
ce426f
 stub_warning (open)
ce426f
 
ce426f
-
ce426f
-int
ce426f
-__open_2 (file, oflag)
ce426f
-     const char *file;
ce426f
-     int oflag;
ce426f
-{
ce426f
-  if (oflag & O_CREAT)
ce426f
-    __fortify_fail ("invalid open call: O_CREAT without mode");
ce426f
-
ce426f
-  return __open (file, oflag);
ce426f
-}
ce426f
+/* __open_2 is a generic wrapper that calls __open.
ce426f
+   So give a stub warning for that symbol too.  */
ce426f
 stub_warning (__open_2)
ce426f
Index: b/io/open64.c
ce426f
===================================================================
ce426f
--- a/io/open64.c
ce426f
+++ b/io/open64.c
ce426f
@@ -54,15 +54,6 @@ weak_alias (__libc_open64, open64)
ce426f
 
ce426f
 stub_warning (open64)
ce426f
 
ce426f
-
ce426f
-int
ce426f
-__open64_2 (file, oflag)
ce426f
-     const char *file;
ce426f
-     int oflag;
ce426f
-{
ce426f
-  if (oflag & O_CREAT)
ce426f
-    __fortify_fail ("invalid open64 call: O_CREAT without mode");
ce426f
-
ce426f
-  return __open64 (file, oflag);
ce426f
-}
ce426f
+/* __open64_2 is a generic wrapper that calls __open64.
ce426f
+   So give a stub warning for that symbol too.  */
ce426f
 stub_warning (__open64_2)
ce426f
Index: b/io/open64_2.c
ce426f
===================================================================
ce426f
--- /dev/null
ce426f
+++ b/io/open64_2.c
ce426f
@@ -0,0 +1,29 @@
ce426f
+/* _FORTIFY_SOURCE wrapper for open64.
ce426f
+   Copyright (C) 2013 Free Software Foundation, Inc.
ce426f
+   This file is part of the GNU C Library.
ce426f
+
ce426f
+   The GNU C Library is free software; you can redistribute it and/or
ce426f
+   modify it under the terms of the GNU Lesser General Public
ce426f
+   License as published by the Free Software Foundation; either
ce426f
+   version 2.1 of the License, or (at your option) any later version.
ce426f
+
ce426f
+   The GNU C Library is distributed in the hope that it will be useful,
ce426f
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
ce426f
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ce426f
+   Lesser General Public License for more details.
ce426f
+
ce426f
+   You should have received a copy of the GNU Lesser General Public
ce426f
+   License along with the GNU C Library; if not, see
ce426f
+   <http://www.gnu.org/licenses/>.  */
ce426f
+
ce426f
+#include <fcntl.h>
ce426f
+#include <stdio.h>
ce426f
+
ce426f
+int
ce426f
+__open64_2 (const char *file, int oflag)
ce426f
+{
ce426f
+  if (oflag & O_CREAT)
ce426f
+    __fortify_fail ("invalid open64 call: O_CREAT without mode");
ce426f
+
ce426f
+  return __open64 (file, oflag);
ce426f
+}
ce426f
Index: b/io/open_2.c
ce426f
===================================================================
ce426f
--- /dev/null
ce426f
+++ b/io/open_2.c
ce426f
@@ -0,0 +1,29 @@
ce426f
+/* _FORTIFY_SOURCE wrapper for open.
ce426f
+   Copyright (C) 2013 Free Software Foundation, Inc.
ce426f
+   This file is part of the GNU C Library.
ce426f
+
ce426f
+   The GNU C Library is free software; you can redistribute it and/or
ce426f
+   modify it under the terms of the GNU Lesser General Public
ce426f
+   License as published by the Free Software Foundation; either
ce426f
+   version 2.1 of the License, or (at your option) any later version.
ce426f
+
ce426f
+   The GNU C Library is distributed in the hope that it will be useful,
ce426f
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
ce426f
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ce426f
+   Lesser General Public License for more details.
ce426f
+
ce426f
+   You should have received a copy of the GNU Lesser General Public
ce426f
+   License along with the GNU C Library; if not, see
ce426f
+   <http://www.gnu.org/licenses/>.  */
ce426f
+
ce426f
+#include <fcntl.h>
ce426f
+#include <stdio.h>
ce426f
+
ce426f
+int
ce426f
+__open_2 (const char *file, int oflag)
ce426f
+{
ce426f
+  if (oflag & O_CREAT)
ce426f
+    __fortify_fail ("invalid open call: O_CREAT without mode");
ce426f
+
ce426f
+  return __open (file, oflag);
ce426f
+}
ce426f
Index: b/io/openat.c
ce426f
===================================================================
ce426f
--- a/io/openat.c
ce426f
+++ b/io/openat.c
ce426f
@@ -75,16 +75,6 @@ libc_hidden_def (__openat)
ce426f
 weak_alias (__openat, openat)
ce426f
 stub_warning (openat)
ce426f
 
ce426f
-
ce426f
-int
ce426f
-__openat_2 (fd, file, oflag)
ce426f
-     int fd;
ce426f
-     const char *file;
ce426f
-     int oflag;
ce426f
-{
ce426f
-  if (oflag & O_CREAT)
ce426f
-    __fortify_fail ("invalid openat call: O_CREAT without mode");
ce426f
-
ce426f
-  return __openat (fd, file, oflag);
ce426f
-}
ce426f
+/* __openat_2 is a generic wrapper that calls __openat.
ce426f
+   So give a stub warning for that symbol too.  */
ce426f
 stub_warning (__openat_2)
ce426f
Index: b/io/openat64.c
ce426f
===================================================================
ce426f
--- a/io/openat64.c
ce426f
+++ b/io/openat64.c
ce426f
@@ -68,16 +68,6 @@ libc_hidden_def (__openat64)
ce426f
 weak_alias (__openat64, openat64)
ce426f
 stub_warning (openat64)
ce426f
 
ce426f
-
ce426f
-int
ce426f
-__openat64_2 (fd, file, oflag)
ce426f
-     int fd;
ce426f
-     const char *file;
ce426f
-     int oflag;
ce426f
-{
ce426f
-  if (oflag & O_CREAT)
ce426f
-    __fortify_fail ("invalid openat64 call: O_CREAT without mode");
ce426f
-
ce426f
-  return __openat64 (fd, file, oflag);
ce426f
-}
ce426f
+/* __openat64_2 is a generic wrapper that calls __openat64.
ce426f
+   So give a stub warning for that symbol too.  */
ce426f
 stub_warning (__openat_2)
ce426f
Index: b/io/openat64_2.c
ce426f
===================================================================
ce426f
--- /dev/null
ce426f
+++ b/io/openat64_2.c
ce426f
@@ -0,0 +1,29 @@
ce426f
+/* _FORTIFY_SOURCE wrapper for openat64.
ce426f
+   Copyright (C) 2013 Free Software Foundation, Inc.
ce426f
+   This file is part of the GNU C Library.
ce426f
+
ce426f
+   The GNU C Library is free software; you can redistribute it and/or
ce426f
+   modify it under the terms of the GNU Lesser General Public
ce426f
+   License as published by the Free Software Foundation; either
ce426f
+   version 2.1 of the License, or (at your option) any later version.
ce426f
+
ce426f
+   The GNU C Library is distributed in the hope that it will be useful,
ce426f
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
ce426f
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ce426f
+   Lesser General Public License for more details.
ce426f
+
ce426f
+   You should have received a copy of the GNU Lesser General Public
ce426f
+   License along with the GNU C Library; if not, see
ce426f
+   <http://www.gnu.org/licenses/>.  */
ce426f
+
ce426f
+#include <fcntl.h>
ce426f
+#include <stdio.h>
ce426f
+
ce426f
+int
ce426f
+__openat64_2 (int fd, const char *file, int oflag)
ce426f
+{
ce426f
+  if (oflag & O_CREAT)
ce426f
+    __fortify_fail ("invalid openat64 call: O_CREAT without mode");
ce426f
+
ce426f
+  return __openat64 (fd, file, oflag);
ce426f
+}
ce426f
Index: b/io/openat_2.c
ce426f
===================================================================
ce426f
--- /dev/null
ce426f
+++ b/io/openat_2.c
ce426f
@@ -0,0 +1,29 @@
ce426f
+/* _FORTIFY_SOURCE wrapper for openat.
ce426f
+   Copyright (C) 2013 Free Software Foundation, Inc.
ce426f
+   This file is part of the GNU C Library.
ce426f
+
ce426f
+   The GNU C Library is free software; you can redistribute it and/or
ce426f
+   modify it under the terms of the GNU Lesser General Public
ce426f
+   License as published by the Free Software Foundation; either
ce426f
+   version 2.1 of the License, or (at your option) any later version.
ce426f
+
ce426f
+   The GNU C Library is distributed in the hope that it will be useful,
ce426f
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
ce426f
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ce426f
+   Lesser General Public License for more details.
ce426f
+
ce426f
+   You should have received a copy of the GNU Lesser General Public
ce426f
+   License along with the GNU C Library; if not, see
ce426f
+   <http://www.gnu.org/licenses/>.  */
ce426f
+
ce426f
+#include <fcntl.h>
ce426f
+#include <stdio.h>
ce426f
+
ce426f
+int
ce426f
+__openat_2 (int fd, const char *file, int oflag)
ce426f
+{
ce426f
+  if (oflag & O_CREAT)
ce426f
+    __fortify_fail ("invalid openat call: O_CREAT without mode");
ce426f
+
ce426f
+  return __openat (fd, file, oflag);
ce426f
+}
ce426f
Index: b/sysdeps/mach/hurd/open.c
ce426f
===================================================================
ce426f
--- a/sysdeps/mach/hurd/open.c
ce426f
+++ b/sysdeps/mach/hurd/open.c
ce426f
@@ -52,20 +52,9 @@ weak_alias (__libc_open, __open)
ce426f
 libc_hidden_weak (__open)
ce426f
 weak_alias (__libc_open, open)
ce426f
 
ce426f
-int
ce426f
-__open_2 (file, oflag)
ce426f
-     const char *file;
ce426f
-     int oflag;
ce426f
-{
ce426f
-  if (oflag & O_CREAT)
ce426f
-    __fortify_fail ("invalid open call: O_CREAT without mode");
ce426f
-
ce426f
-  return __open (file, oflag);
ce426f
-}
ce426f
 
ce426f
 /* open64 is just the same as open for us.  */
ce426f
 weak_alias (__libc_open, __libc_open64)
ce426f
 weak_alias (__libc_open, __open64)
ce426f
 libc_hidden_weak (_open64)
ce426f
 weak_alias (__libc_open, open64)
ce426f
-strong_alias (__open_2, __open64_2)
ce426f
Index: b/sysdeps/mach/hurd/openat.c
ce426f
===================================================================
ce426f
--- a/sysdeps/mach/hurd/openat.c
ce426f
+++ b/sysdeps/mach/hurd/openat.c
ce426f
@@ -56,20 +56,7 @@ __openat (fd, file, oflag)
ce426f
 libc_hidden_def (__openat)
ce426f
 weak_alias (__openat, openat)
ce426f
 
ce426f
-int
ce426f
-__openat_2 (fd, file, oflag)
ce426f
-     int fd;
ce426f
-     const char *file;
ce426f
-     int oflag;
ce426f
-{
ce426f
-  if (oflag & O_CREAT)
ce426f
-    __fortify_fail ("invalid openat call: O_CREAT without mode");
ce426f
-
ce426f
-  return __openat (fd, file, oflag);
ce426f
-}
ce426f
-
ce426f
 /* openat64 is just the same as openat for us.  */
ce426f
 weak_alias (__openat, __openat64)
ce426f
 libc_hidden_weak (__openat64)
ce426f
 weak_alias (__openat, openat64)
ce426f
-strong_alias (__openat_2, __openat64_2)
ce426f
Index: b/sysdeps/unix/sysv/linux/Makefile
ce426f
===================================================================
ce426f
--- a/sysdeps/unix/sysv/linux/Makefile
ce426f
+++ b/sysdeps/unix/sysv/linux/Makefile
ce426f
@@ -158,7 +158,7 @@ endif
ce426f
 
ce426f
 ifeq ($(subdir),io)
ce426f
 sysdep_routines += xstatconv internal_statvfs internal_statvfs64 \
ce426f
-		   sync_file_range open_2 open64_2 fallocate fallocate64
ce426f
+		   sync_file_range fallocate fallocate64
ce426f
 sysdep_headers += bits/fcntl-linux.h
ce426f
 endif
ce426f
 
ce426f
Index: b/sysdeps/unix/sysv/linux/open64_2.c
ce426f
===================================================================
ce426f
--- a/sysdeps/unix/sysv/linux/open64_2.c
ce426f
+++ /dev/null
ce426f
@@ -1,31 +0,0 @@
ce426f
-/* Copyright (C) 2007 Free Software Foundation, Inc.
ce426f
-   This file is part of the GNU C Library.
ce426f
-
ce426f
-   The GNU C Library is free software; you can redistribute it and/or
ce426f
-   modify it under the terms of the GNU Lesser General Public
ce426f
-   License as published by the Free Software Foundation; either
ce426f
-   version 2.1 of the License, or (at your option) any later version.
ce426f
-
ce426f
-   The GNU C Library is distributed in the hope that it will be useful,
ce426f
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
ce426f
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ce426f
-   Lesser General Public License for more details.
ce426f
-
ce426f
-   You should have received a copy of the GNU Lesser General Public
ce426f
-   License along with the GNU C Library; if not, see
ce426f
-   <http://www.gnu.org/licenses/>.  */
ce426f
-
ce426f
-#include <fcntl.h>
ce426f
-#include <stdio.h>
ce426f
-
ce426f
-
ce426f
-int
ce426f
-__open64_2 (file, oflag)
ce426f
-     const char *file;
ce426f
-     int oflag;
ce426f
-{
ce426f
-  if (oflag & O_CREAT)
ce426f
-    __fortify_fail ("invalid open64 call: O_CREAT without mode");
ce426f
-
ce426f
-  return __open64 (file, oflag);
ce426f
-}
ce426f
Index: b/sysdeps/unix/sysv/linux/open_2.c
ce426f
===================================================================
ce426f
--- a/sysdeps/unix/sysv/linux/open_2.c
ce426f
+++ /dev/null
ce426f
@@ -1,31 +0,0 @@
ce426f
-/* Copyright (C) 2007 Free Software Foundation, Inc.
ce426f
-   This file is part of the GNU C Library.
ce426f
-
ce426f
-   The GNU C Library is free software; you can redistribute it and/or
ce426f
-   modify it under the terms of the GNU Lesser General Public
ce426f
-   License as published by the Free Software Foundation; either
ce426f
-   version 2.1 of the License, or (at your option) any later version.
ce426f
-
ce426f
-   The GNU C Library is distributed in the hope that it will be useful,
ce426f
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
ce426f
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ce426f
-   Lesser General Public License for more details.
ce426f
-
ce426f
-   You should have received a copy of the GNU Lesser General Public
ce426f
-   License along with the GNU C Library; if not, see
ce426f
-   <http://www.gnu.org/licenses/>.  */
ce426f
-
ce426f
-#include <fcntl.h>
ce426f
-#include <stdio.h>
ce426f
-
ce426f
-
ce426f
-int
ce426f
-__open_2 (file, oflag)
ce426f
-     const char *file;
ce426f
-     int oflag;
ce426f
-{
ce426f
-  if (oflag & O_CREAT)
ce426f
-    __fortify_fail ("invalid open call: O_CREAT without mode");
ce426f
-
ce426f
-  return __open (file, oflag);
ce426f
-}
ce426f
Index: b/sysdeps/unix/sysv/linux/openat.c
ce426f
===================================================================
ce426f
--- a/sysdeps/unix/sysv/linux/openat.c
ce426f
+++ b/sysdeps/unix/sysv/linux/openat.c
ce426f
@@ -29,7 +29,6 @@
ce426f
 
ce426f
 #ifndef OPENAT
ce426f
 # define OPENAT openat
ce426f
-# define __OPENAT_2 __openat_2
ce426f
 
ce426f
 # ifndef __ASSUME_ATFCTS
ce426f
 /* Set errno after a failed call.  If BUF is not null,
ce426f
@@ -179,18 +178,3 @@ __OPENAT (fd, file, oflag)
ce426f
 }
ce426f
 libc_hidden_def (__OPENAT)
ce426f
 weak_alias (__OPENAT, OPENAT)
ce426f
-
ce426f
-
ce426f
-int
ce426f
-__OPENAT_2 (fd, file, oflag)
ce426f
-     int fd;
ce426f
-     const char *file;
ce426f
-     int oflag;
ce426f
-{
ce426f
-  if (oflag & O_CREAT)
ce426f
-#define MSG(s) MSG2 (s)
ce426f
-#define MSG2(s) "invalid " #s " call: O_CREAT without mode"
ce426f
-    __fortify_fail (MSG (OPENAT));
ce426f
-
ce426f
-  return __OPENAT (fd, file, oflag);
ce426f
-}
ce426f
Index: b/sysdeps/unix/sysv/linux/openat64.c
ce426f
===================================================================
ce426f
--- a/sysdeps/unix/sysv/linux/openat64.c
ce426f
+++ b/sysdeps/unix/sysv/linux/openat64.c
ce426f
@@ -1,5 +1,4 @@
ce426f
 #define OPENAT openat64
ce426f
-#define __OPENAT_2 __openat64_2
ce426f
 #define MORE_OFLAGS O_LARGEFILE
ce426f
 
ce426f
 #include "openat.c"
ce426f
Index: b/sysdeps/unix/sysv/linux/wordsize-64/openat.c
ce426f
===================================================================
ce426f
--- a/sysdeps/unix/sysv/linux/wordsize-64/openat.c
ce426f
+++ b/sysdeps/unix/sysv/linux/wordsize-64/openat.c
ce426f
@@ -1,16 +1,14 @@
ce426f
 #define __openat64 __rename___openat64
ce426f
-#define __openat64_2 __rename___openat64_2
ce426f
 #define __openat64_nocancel __rename___openat64_nocancel
ce426f
 #define openat64 __rename_openat64
ce426f
 
ce426f
 #include "../openat.c"
ce426f
 
ce426f
 #undef __openat64
ce426f
-#undef __openat64_2
ce426f
 #undef __openat64_nocancel
ce426f
 #undef openat64
ce426f
 
ce426f
-weak_alias (__openat, __openat64)
ce426f
-weak_alias (__openat_2, __openat64_2)
ce426f
-weak_alias (__openat_nocancel, __openat64_nocancel)
ce426f
+strong_alias (__openat, __openat64)
ce426f
+hidden_ver (__openat, __openat64)
ce426f
+strong_alias (__openat_nocancel, __openat64_nocancel)
ce426f
 weak_alias (openat, openat64)