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