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