[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commits] r3108 - in /fsf/trunk/libc: ./ include/ libio/ misc/ nscd/ nss/ nss/nss_files/ shadow/ stdio-common/ stdlib/ sysdeps/ieee754...
- To: commits@xxxxxxxxxx
- Subject: [commits] r3108 - in /fsf/trunk/libc: ./ include/ libio/ misc/ nscd/ nss/ nss/nss_files/ shadow/ stdio-common/ stdlib/ sysdeps/ieee754...
- From: eglibc@xxxxxxxxxx
- Date: Sat, 11 Aug 2007 07:02:40 -0000
Author: eglibc
Date: Sat Aug 11 00:02:39 2007
New Revision: 3108
Log:
Import glibc-mainline for 2007-08-11
Added:
fsf/trunk/libc/misc/mkostemp.c
fsf/trunk/libc/misc/mkostemp64.c
fsf/trunk/libc/nss/nss_files/files-have_o_cloexec.c
Modified:
fsf/trunk/libc/ChangeLog
fsf/trunk/libc/include/stdio.h
fsf/trunk/libc/libio/oldtmpfile.c
fsf/trunk/libc/misc/Makefile
fsf/trunk/libc/misc/Versions
fsf/trunk/libc/misc/mkdtemp.c
fsf/trunk/libc/misc/mkstemp.c
fsf/trunk/libc/misc/mkstemp64.c
fsf/trunk/libc/misc/mktemp.c
fsf/trunk/libc/nscd/connections.c
fsf/trunk/libc/nss/Makefile
fsf/trunk/libc/nss/nss_files/files-XXX.c
fsf/trunk/libc/nss/nss_files/files-alias.c
fsf/trunk/libc/shadow/lckpwdf.c
fsf/trunk/libc/stdio-common/tempnam.c
fsf/trunk/libc/stdio-common/tempname.c
fsf/trunk/libc/stdio-common/tmpfile.c
fsf/trunk/libc/stdio-common/tmpfile64.c
fsf/trunk/libc/stdio-common/tmpnam.c
fsf/trunk/libc/stdio-common/tmpnam_r.c
fsf/trunk/libc/stdlib/stdlib.h
fsf/trunk/libc/sysdeps/ieee754/ldbl-128ibm/strtold_l.c
fsf/trunk/libc/sysdeps/mach/hurd/bits/ioctls.h
fsf/trunk/libc/sysdeps/posix/tempname.c
fsf/trunk/libc/sysdeps/unix/sysv/linux/shm_open.c
Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Sat Aug 11 00:02:39 2007
@@ -1,3 +1,56 @@
+2007-08-10 Ulrich Drepper <drepper@xxxxxxxxxx>
+
+ * shadow/lckpwdf.c (__lckpwdf): Use O_CLOEXEC if possible.
+
+ * nscd/connections.c: Use O_CLOEXEC is possible. Use mkostemp
+ instead of mkstemp.
+
+ * misc/Makefile (routines): Add mkostemp and mkostemp64.
+ * misc/Versions: Export mkostemp and mkostemp64 for GLIBC_2.7.
+ * misc/mkostemp.c: New file.
+ * misc/mkostemp64.c: New file.
+ * stdlib/stdlib.h: Declare the new functions.
+ * sysdeps/posix/tempname.c: Add new parameter which is added to
+ the flags for open. Remove __GT_BIGFILE handling.
+ * stdio-common/tempname.c: Likewise.
+ * include/stdio.h: Adjust __gen_tempname prototype.
+ Renumber __GT_* constants.
+ * libio/oldtmpfile.c: Adjust for __gen_tempname interface change.
+ * misc/mkdtemp.c: Likewise.
+ * misc/mkstemp.c: Likewise.
+ * misc/mkstemp64.c: Likewise.
+ * misc/mktemp.c: Likewise.
+ * stdio-common/tempnam.c: Likewise.
+ * stdio-common/tmpfile.c: Likewise.
+ * stdio-common/tmpfile64.c: Likewise.
+ * stdio-common/tmpnam.c: Likewise.
+ * stdio-common/tmpnam_r.c: Likewise.
+
+2007-08-10 Roland McGrath <roland@xxxxxxxx>
+
+ * sysdeps/mach/hurd/bits/ioctls.h (NLDLY, TABDLY, BSDLY, VTDLY):
+ New macros.
+ (NLDELAY, CRDELAY, TBDELAY, BSDELAY, VTDELAY): Define to those.
+ Reported by Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>.
+
+2007-08-10 Ulrich Drepper <drepper@xxxxxxxxxx>
+
+ * nss/nss_files/files-XXX.c (internal_setent): Use O_CLOEXEC if
+ possible.
+ * nss/nss_files/files-alias.c (internal_setent): Likewise.
+ * nss/Makefile (libnss_files-routines): Add files-have_o_cloexec.
+ * nss/nss_files/files-have_o_cloexec.c: New file.
+
+ * sysdeps/unix/sysv/linux/shm_open.c (shm_open): Use O_CLOEXEC if
+ available.
+
+2007-08-10 Jakub Jelinek <jakub@xxxxxxxxxx>
+
+ * sysdeps/ieee754/ldbl-128ibm/strtold_l.c (___new_strtold_l,
+ ___new_wcstold_l): New weak aliases.
+ (strtold_l, wcstold_l): Use them as second argument for
+ long_double_symbol.
+
2007-08-09 Ulrich Drepper <drepper@xxxxxxxxxx>
* sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S: Use correct
Modified: fsf/trunk/libc/include/stdio.h
==============================================================================
--- fsf/trunk/libc/include/stdio.h (original)
+++ fsf/trunk/libc/include/stdio.h Sat Aug 11 00:02:39 2007
@@ -54,12 +54,11 @@
__const char *__dir, __const char *__pfx,
int __try_tempdir);
-extern int __gen_tempname (char *__tmpl, int __kind);
+extern int __gen_tempname (char *__tmpl, int __flags, int __kind);
/* The __kind argument to __gen_tempname may be one of: */
# define __GT_FILE 0 /* create a file */
-# define __GT_BIGFILE 1 /* create a file, using open64 */
-# define __GT_DIR 2 /* create a directory */
-# define __GT_NOCREATE 3 /* just find a name not currently in use */
+# define __GT_DIR 1 /* create a directory */
+# define __GT_NOCREATE 2 /* just find a name not currently in use */
/* Print out MESSAGE on the error output and abort. */
extern void __libc_fatal (__const char *__message)
Modified: fsf/trunk/libc/libio/oldtmpfile.c
==============================================================================
--- fsf/trunk/libc/libio/oldtmpfile.c (original)
+++ fsf/trunk/libc/libio/oldtmpfile.c Sat Aug 11 00:02:39 2007
@@ -1,4 +1,5 @@
-/* Copyright (C) 1991,1993,1996-2000,2003,2004 Free Software Foundation, Inc.
+/* Copyright (C) 1991,1993,1996-2000,2003,2004,2007
+ 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
@@ -38,7 +39,7 @@
if (__path_search (buf, FILENAME_MAX, NULL, "tmpf", 0))
return NULL;
- fd = __gen_tempname (buf, __GT_FILE);
+ fd = __gen_tempname (buf, 0, __GT_FILE);
if (fd < 0)
return NULL;
Modified: fsf/trunk/libc/misc/Makefile
==============================================================================
--- fsf/trunk/libc/misc/Makefile (original)
+++ fsf/trunk/libc/misc/Makefile Sat Aug 11 00:02:39 2007
@@ -1,4 +1,4 @@
-# Copyright (C) 1991-2002,2003,2004,2005,2006 Free Software Foundation, Inc.
+# Copyright (C) 1991-2006, 2007 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
@@ -45,6 +45,7 @@
gethostid sethostid \
revoke vhangup \
swapon swapoff mktemp mkstemp mkstemp64 mkdtemp \
+ mkostemp mkostemp64 \
ualarm usleep \
gtty stty \
ptrace \
Modified: fsf/trunk/libc/misc/Versions
==============================================================================
--- fsf/trunk/libc/misc/Versions (original)
+++ fsf/trunk/libc/misc/Versions Sat Aug 11 00:02:39 2007
@@ -134,4 +134,7 @@
futimesat;
__syslog_chk; __vsyslog_chk;
}
+ GLIBC_2.7 {
+ mkostemp; mkostemp64;
+ }
}
Modified: fsf/trunk/libc/misc/mkdtemp.c
==============================================================================
--- fsf/trunk/libc/misc/mkdtemp.c (original)
+++ fsf/trunk/libc/misc/mkdtemp.c Sat Aug 11 00:02:39 2007
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1999, 2007 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
@@ -28,7 +28,7 @@
mkdtemp (template)
char *template;
{
- if (__gen_tempname (template, __GT_DIR))
+ if (__gen_tempname (template, 0, __GT_DIR))
return NULL;
else
return template;
Added: fsf/trunk/libc/misc/mkostemp.c
==============================================================================
--- fsf/trunk/libc/misc/mkostemp.c (added)
+++ fsf/trunk/libc/misc/mkostemp.c Sat Aug 11 00:02:39 2007
@@ -1,0 +1,36 @@
+/* Copyright (C) 1998, 1999, 2001, 2007 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#ifndef __GT_FILE
+# define __GT_FILE 0
+#endif
+
+/* Generate a unique temporary file name from TEMPLATE.
+ The last six characters of TEMPLATE must be "XXXXXX";
+ they are replaced with a string that makes the filename unique.
+ Then open the file and return a fd. */
+int
+mkostemp (template, flags)
+ char *template;
+ int flags;
+{
+ return __gen_tempname (template, flags, __GT_FILE);
+}
Added: fsf/trunk/libc/misc/mkostemp64.c
==============================================================================
--- fsf/trunk/libc/misc/mkostemp64.c (added)
+++ fsf/trunk/libc/misc/mkostemp64.c Sat Aug 11 00:02:39 2007
@@ -1,0 +1,33 @@
+/* Copyright (C) 2000, 2007 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+/* Generate a unique temporary file name from TEMPLATE.
+ The last six characters of TEMPLATE must be "XXXXXX";
+ they are replaced with a string that makes the filename unique.
+ Then open the file and return a fd. */
+int
+mkostemp64 (template, flags)
+ char *template;
+ int flags;
+{
+ return __gen_tempname (template, flags | O_LARGEFILE, __GT_FILE);
+}
Modified: fsf/trunk/libc/misc/mkstemp.c
==============================================================================
--- fsf/trunk/libc/misc/mkstemp.c (original)
+++ fsf/trunk/libc/misc/mkstemp.c Sat Aug 11 00:02:39 2007
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 1999, 2001, 2007 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
@@ -31,5 +31,5 @@
mkstemp (template)
char *template;
{
- return __gen_tempname (template, __GT_FILE);
+ return __gen_tempname (template, 0, __GT_FILE);
}
Modified: fsf/trunk/libc/misc/mkstemp64.c
==============================================================================
--- fsf/trunk/libc/misc/mkstemp64.c (original)
+++ fsf/trunk/libc/misc/mkstemp64.c Sat Aug 11 00:02:39 2007
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000 Free Software Foundation, Inc.
+/* Copyright (C) 2000, 2007 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
@@ -16,6 +16,7 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
@@ -27,5 +28,5 @@
mkstemp64 (template)
char *template;
{
- return __gen_tempname (template, __GT_BIGFILE);
+ return __gen_tempname (template, O_LARGEFILE, __GT_FILE);
}
Modified: fsf/trunk/libc/misc/mktemp.c
==============================================================================
--- fsf/trunk/libc/misc/mktemp.c (original)
+++ fsf/trunk/libc/misc/mktemp.c Sat Aug 11 00:02:39 2007
@@ -1,4 +1,4 @@
-/* Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1998, 1999, 2000, 2007 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
@@ -26,7 +26,7 @@
mktemp (template)
char *template;
{
- if (__gen_tempname (template, __GT_NOCREATE) < 0)
+ if (__gen_tempname (template, 0, __GT_NOCREATE) < 0)
/* We return the null string if we can't find a unique file name. */
template[0] = '\0';
Modified: fsf/trunk/libc/nscd/connections.c
==============================================================================
--- fsf/trunk/libc/nscd/connections.c (original)
+++ fsf/trunk/libc/nscd/connections.c Sat Aug 11 00:02:39 2007
@@ -468,6 +468,13 @@
}
+#ifdef O_CLOEXEC
+# define EXTRA_O_FLAGS O_CLOEXEC
+#else
+# define EXTRA_O_FLAGS 0
+#endif
+
+
/* Initialize database information structures. */
void
nscd_init (void)
@@ -490,7 +497,7 @@
if (dbs[cnt].persistent)
{
/* Try to open the appropriate file on disk. */
- int fd = open (dbs[cnt].db_filename, O_RDWR);
+ int fd = open (dbs[cnt].db_filename, O_RDWR | EXTRA_O_FLAGS);
if (fd != -1)
{
struct stat64 st;
@@ -569,7 +576,8 @@
/* We also need a read-only descriptor. */
if (dbs[cnt].shared)
{
- dbs[cnt].ro_fd = open (dbs[cnt].db_filename, O_RDONLY);
+ dbs[cnt].ro_fd = open (dbs[cnt].db_filename,
+ O_RDONLY | EXTRA_O_FLAGS);
if (dbs[cnt].ro_fd == -1)
dbg_log (_("\
cannot create read-only descriptor for \"%s\"; no mmap"),
@@ -606,22 +614,23 @@
if (dbs[cnt].persistent)
{
fd = open (dbs[cnt].db_filename,
- O_RDWR | O_CREAT | O_EXCL | O_TRUNC,
+ O_RDWR | O_CREAT | O_EXCL | O_TRUNC | EXTRA_O_FLAGS,
S_IRUSR | S_IWUSR);
if (fd != -1 && dbs[cnt].shared)
- ro_fd = open (dbs[cnt].db_filename, O_RDONLY);
+ ro_fd = open (dbs[cnt].db_filename,
+ O_RDONLY | EXTRA_O_FLAGS);
}
else
{
char fname[] = _PATH_NSCD_XYZ_DB_TMP;
- fd = mkstemp (fname);
+ fd = mkostemp (fname, EXTRA_O_FLAGS);
/* We do not need the file name anymore after we
opened another file descriptor in read-only mode. */
if (fd != -1)
{
if (dbs[cnt].shared)
- ro_fd = open (fname, O_RDONLY);
+ ro_fd = open (fname, O_RDONLY | EXTRA_O_FLAGS);
unlink (fname);
}
@@ -740,6 +749,11 @@
}
}
+#if !defined O_CLOEXEC || !defined __ASSUME_O_CLOEXEC
+ /* We do not check here whether the O_CLOEXEC provided to the
+ open call was successful or not. The two fcntl calls are
+ only performed once each per process start-up and therefore
+ is not noticeable at all. */
if (paranoia
&& ((dbs[cnt].wr_fd != -1
&& fcntl (dbs[cnt].wr_fd, F_SETFD, FD_CLOEXEC) == -1)
@@ -751,6 +765,7 @@
strerror (errno));
paranoia = 0;
}
+#endif
if (dbs[cnt].head == NULL)
{
Modified: fsf/trunk/libc/nss/Makefile
==============================================================================
--- fsf/trunk/libc/nss/Makefile (original)
+++ fsf/trunk/libc/nss/Makefile Sat Aug 11 00:02:39 2007
@@ -1,4 +1,4 @@
-# Copyright (C) 1996,1997,1998,2000,2001,2002 Free Software Foundation, Inc.
+# Copyright (C) 1996-1998,2000,2001,2002,2007 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
@@ -62,7 +62,8 @@
vpath %.c $(subdir-dirs)
-libnss_files-routines := $(addprefix files-,$(databases))
+libnss_files-routines := $(addprefix files-,$(databases)) \
+ files-have_o_cloexec
distribute += files-XXX.c files-parse.c
Modified: fsf/trunk/libc/nss/nss_files/files-XXX.c
==============================================================================
--- fsf/trunk/libc/nss/nss_files/files-XXX.c (original)
+++ fsf/trunk/libc/nss/nss_files/files-XXX.c Sat Aug 11 00:02:39 2007
@@ -1,5 +1,5 @@
/* Common code for file-based databases in nss_files module.
- Copyright (C) 1996-1999,2001,2002,2004 Free Software Foundation, Inc.
+ Copyright (C) 1996-1999,2001,2002,2004,2007 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
@@ -23,6 +23,8 @@
#include <fcntl.h>
#include <bits/libc-lock.h>
#include "nsswitch.h"
+
+#include <kernel-features.h>
/* These symbols are defined by the including source file:
@@ -74,29 +76,44 @@
if (stream == NULL)
{
- stream = fopen (DATAFILE, "r");
+ stream = fopen (DATAFILE, "re");
if (stream == NULL)
status = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
else
{
- /* We have to make sure the file is `closed on exec'. */
- int result, flags;
-
- result = flags = fcntl (fileno (stream), F_GETFD, 0);
- if (result >= 0)
+#if !defined O_CLOEXEC || !defined __ASSUME_O_CLOEXEC
+# ifdef O_CLOEXEC
+ if (__have_o_cloexec <= 0)
+# endif
{
- flags |= FD_CLOEXEC;
- result = fcntl (fileno (stream), F_SETFD, flags);
+ /* We have to make sure the file is `closed on exec'. */
+ int result;
+ int flags;
+
+ result = flags = fcntl (fileno (stream), F_GETFD, 0);
+ if (result >= 0)
+ {
+# ifdef O_CLOEXEC
+ if (__have_o_cloexec == 0)
+ __have_o_cloexec = (flags & FD_CLOEXEC) == 0 ? -1 : 1;
+ if (__have_o_cloexec < 0)
+# endif
+ {
+ flags |= FD_CLOEXEC;
+ result = fcntl (fileno (stream), F_SETFD, flags);
+ }
+ }
+ if (result < 0)
+ {
+ /* Something went wrong. Close the stream and return a
+ failure. */
+ fclose (stream);
+ stream = NULL;
+ status = NSS_STATUS_UNAVAIL;
+ }
}
- if (result < 0)
- {
- /* Something went wrong. Close the stream and return a
- failure. */
- fclose (stream);
- stream = NULL;
- status = NSS_STATUS_UNAVAIL;
- }
+#endif
}
}
else
Modified: fsf/trunk/libc/nss/nss_files/files-alias.c
==============================================================================
--- fsf/trunk/libc/nss/nss_files/files-alias.c (original)
+++ fsf/trunk/libc/nss/nss_files/files-alias.c Sat Aug 11 00:02:39 2007
@@ -1,5 +1,5 @@
/* Mail alias file parser in nss_files module.
- Copyright (C) 1996,97,98,99,2002,2006 Free Software Foundation, Inc.
+ Copyright (C) 1996,97,98,99,2002,2006,2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 1996.
@@ -27,6 +27,8 @@
#include <stdio.h>
#include <string.h>
+#include <kernel-features.h>
+
#include "nsswitch.h"
/* Locks the static variables in this file. */
@@ -46,29 +48,44 @@
if (stream == NULL)
{
- stream = fopen ("/etc/aliases", "r");
+ stream = fopen ("/etc/aliases", "re");
if (stream == NULL)
status = errno == EAGAIN ? NSS_STATUS_TRYAGAIN : NSS_STATUS_UNAVAIL;
else
{
- /* We have to make sure the file is `closed on exec'. */
- int result, flags;
-
- result = flags = fcntl (fileno (stream), F_GETFD, 0);
- if (result >= 0)
+#if !defined O_CLOEXEC || !defined __ASSUME_O_CLOEXEC
+# ifdef O_CLOEXEC
+ if (__have_o_cloexec <= 0)
+# endif
{
- flags |= FD_CLOEXEC;
- result = fcntl (fileno (stream), F_SETFD, flags);
+ /* We have to make sure the file is `closed on exec'. */
+ int result;
+ int flags;
+
+ result = flags = fcntl (fileno (stream), F_GETFD, 0);
+ if (result >= 0)
+ {
+# ifdef O_CLOEXEC
+ if (__have_o_cloexec == 0)
+ __have_o_cloexec = (flags & FD_CLOEXEC) == 0 ? -1 : 1;
+ if (__have_o_cloexec < 0)
+# endif
+ {
+ flags |= FD_CLOEXEC;
+ result = fcntl (fileno (stream), F_SETFD, flags);
+ }
+ }
+ if (result < 0)
+ {
+ /* Something went wrong. Close the stream and return a
+ failure. */
+ fclose (stream);
+ stream = NULL;
+ status = NSS_STATUS_UNAVAIL;
+ }
}
- if (result < 0)
- {
- /* Something went wrong. Close the stream and return a
- failure. */
- fclose (stream);
- stream = NULL;
- status = NSS_STATUS_UNAVAIL;
- }
+#endif
}
}
else
Added: fsf/trunk/libc/nss/nss_files/files-have_o_cloexec.c
==============================================================================
--- fsf/trunk/libc/nss/nss_files/files-have_o_cloexec.c (added)
+++ fsf/trunk/libc/nss/nss_files/files-have_o_cloexec.c Sat Aug 11 00:02:39 2007
@@ -1,0 +1,24 @@
+/* Copyright (C) 2007 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <fcntl.h>
+#include <kernel-features.h>
+
+#if defined O_CLOEXEC && !defined __ASSUME_O_CLOEXEC
+int __have_o_cloexec;
+#endif
Modified: fsf/trunk/libc/shadow/lckpwdf.c
==============================================================================
--- fsf/trunk/libc/shadow/lckpwdf.c (original)
+++ fsf/trunk/libc/shadow/lckpwdf.c Sat Aug 11 00:02:39 2007
@@ -1,5 +1,5 @@
/* Handle locking of password file.
- Copyright (C) 1996,98,2000,02 Free Software Foundation, Inc.
+ Copyright (C) 1996, 1998, 2000, 2002, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 1996.
@@ -25,6 +25,8 @@
#include <string.h>
#include <unistd.h>
#include <sys/file.h>
+
+#include <kernel-features.h>
/* Name of the lock file. */
@@ -96,20 +98,38 @@
/* Prevent problems caused by multiple threads. */
__libc_lock_lock (lock);
- lock_fd = __open (PWD_LOCKFILE, O_WRONLY | O_CREAT, 0600);
+ int oflags = O_WRONLY | O_CREAT;
+#ifdef O_CLOEXEC
+ oflags |= O_CLOEXEC;
+#endif
+ lock_fd = __open (PWD_LOCKFILE, oflags, 0600);
if (lock_fd == -1)
/* Cannot create lock file. */
RETURN_CLOSE_FD (-1);
- /* Make sure file gets correctly closed when process finished. */
- flags = __fcntl (lock_fd, F_GETFD, 0);
- if (flags == -1)
- /* Cannot get file flags. */
- RETURN_CLOSE_FD (-1);
- flags |= FD_CLOEXEC; /* Close on exit. */
- if (__fcntl (lock_fd, F_SETFD, flags) < 0)
- /* Cannot set new flags. */
- RETURN_CLOSE_FD (-1);
+#ifndef __ASSUME_O_CLOEXEC
+# ifdef O_CLOEXEC
+ if (__have_o_cloexec <= 0)
+# endif
+ {
+ /* Make sure file gets correctly closed when process finished. */
+ flags = __fcntl (lock_fd, F_GETFD, 0);
+ if (flags == -1)
+ /* Cannot get file flags. */
+ RETURN_CLOSE_FD (-1);
+# ifdef O_CLOEXEC
+ if (__have_o_cloexec == 0)
+ __have_o_cloexec = (flags & FD_CLOEXEC) == 0 ? -1 : 1;
+ if (__have_o_cloexec < 0)
+# endif
+ {
+ flags |= FD_CLOEXEC; /* Close on exit. */
+ if (__fcntl (lock_fd, F_SETFD, flags) < 0)
+ /* Cannot set new flags. */
+ RETURN_CLOSE_FD (-1);
+ }
+ }
+#endif
/* Now we have to get exclusive write access. Since multiple
process could try this we won't stop when it first fails.
Modified: fsf/trunk/libc/stdio-common/tempnam.c
==============================================================================
--- fsf/trunk/libc/stdio-common/tempnam.c (original)
+++ fsf/trunk/libc/stdio-common/tempnam.c Sat Aug 11 00:02:39 2007
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,1993,1996-1999,2000 Free Software Foundation, Inc.
+/* Copyright (C) 1991,1993,1996-2000,2007 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
@@ -34,7 +34,7 @@
if (__path_search (buf, FILENAME_MAX, dir, pfx, 1))
return NULL;
- if (__gen_tempname (buf, __GT_NOCREATE))
+ if (__gen_tempname (buf, 0, __GT_NOCREATE))
return NULL;
return __strdup (buf);
Modified: fsf/trunk/libc/stdio-common/tempname.c
==============================================================================
--- fsf/trunk/libc/stdio-common/tempname.c (original)
+++ fsf/trunk/libc/stdio-common/tempname.c Sat Aug 11 00:02:39 2007
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 93, 95-98, 99 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 93, 95-98, 99, 2007 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
@@ -47,8 +47,9 @@
*/
int
-__gen_tempname (tmpl, kind)
+__gen_tempname (tmpl, flags, kind)
char *tmpl;
+ int flags;
int kind;
{
__set_errno (ENOSYS);
Modified: fsf/trunk/libc/stdio-common/tmpfile.c
==============================================================================
--- fsf/trunk/libc/stdio-common/tmpfile.c (original)
+++ fsf/trunk/libc/stdio-common/tmpfile.c Sat Aug 11 00:02:39 2007
@@ -1,5 +1,6 @@
/* Open a stdio stream on an anonymous temporary file. Generic/POSIX version.
- Copyright (C) 1991,93,1996-2000,2002,2003 Free Software Foundation, Inc.
+ Copyright (C) 1991,1993,1996-2000,2002,2003,2007
+ 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
@@ -17,6 +18,7 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
+#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
@@ -28,9 +30,6 @@
# endif
#endif
-#ifndef GEN_THIS
-# define GEN_THIS __GT_FILE
-#endif
/* This returns a new stream opened on a temporary file (generated
by tmpnam). The file is opened with mode "w+b" (binary read/write).
@@ -45,7 +44,11 @@
if (__path_search (buf, FILENAME_MAX, NULL, "tmpf", 0))
return NULL;
- fd = __gen_tempname (buf, GEN_THIS);
+ int flags = 0;
+#ifdef FLAGS
+ flags = FLAGS;
+#endif
+ fd = __gen_tempname (buf, flags, __GT_FILE);
if (fd < 0)
return NULL;
@@ -59,7 +62,7 @@
return f;
}
-#if defined USE_IN_LIBIO && GEN_THIS == __GT_FILE /* Not for tmpfile64. */
+#if defined USE_IN_LIBIO && !defined FLAGS /* Not for tmpfile64. */
# undef tmpfile
# include <shlib-compat.h>
versioned_symbol (libc, __new_tmpfile, tmpfile, GLIBC_2_1);
Modified: fsf/trunk/libc/stdio-common/tmpfile64.c
==============================================================================
--- fsf/trunk/libc/stdio-common/tmpfile64.c (original)
+++ fsf/trunk/libc/stdio-common/tmpfile64.c Sat Aug 11 00:02:39 2007
@@ -1,3 +1,3 @@
-#define GEN_THIS __GT_BIGFILE
-#define tmpfile tmpfile64
+#define FLAGS O_LARGEFILE
+#define tmpfile tmpfile64
#include <tmpfile.c>
Modified: fsf/trunk/libc/stdio-common/tmpnam.c
==============================================================================
--- fsf/trunk/libc/stdio-common/tmpnam.c (original)
+++ fsf/trunk/libc/stdio-common/tmpnam.c Sat Aug 11 00:02:39 2007
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,1993,1996-1999,2000 Free Software Foundation, Inc.
+/* Copyright (C) 1991,1993,1996-1999,2000,2007 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
@@ -39,7 +39,7 @@
0))
return NULL;
- if (__builtin_expect (__gen_tempname (tmpbuf, __GT_NOCREATE), 0))
+ if (__builtin_expect (__gen_tempname (tmpbuf, 0, __GT_NOCREATE), 0))
return NULL;
if (s == NULL)
Modified: fsf/trunk/libc/stdio-common/tmpnam_r.c
==============================================================================
--- fsf/trunk/libc/stdio-common/tmpnam_r.c (original)
+++ fsf/trunk/libc/stdio-common/tmpnam_r.c Sat Aug 11 00:02:39 2007
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,1993,1996-1999,2000 Free Software Foundation, Inc.
+/* Copyright (C) 1991,1993,1996-1999,2000,2007 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
@@ -28,7 +28,7 @@
if (__path_search (s, L_tmpnam, NULL, NULL, 0))
return NULL;
- if (__gen_tempname (s, __GT_NOCREATE))
+ if (__gen_tempname (s, 0, __GT_NOCREATE))
return NULL;
return s;
Modified: fsf/trunk/libc/stdlib/stdlib.h
==============================================================================
--- fsf/trunk/libc/stdlib/stdlib.h (original)
+++ fsf/trunk/libc/stdlib/stdlib.h Sat Aug 11 00:02:39 2007
@@ -614,6 +614,28 @@
extern char *mkdtemp (char *__template) __THROW __nonnull ((1)) __wur;
#endif
+#ifdef __USE_GNU
+/* Generate a unique temporary file name from TEMPLATE similar to
+ mkstemp. But allow the caller to pass additional flags which are
+ used in the open call to create the file..
+
+ This function is a possible cancellation points and therefore not
+ marked with __THROW. */
+# ifndef __USE_FILE_OFFSET64
+extern int mkostemp (char *__template, int __flags) __nonnull ((1)) __wur;
+# else
+# ifdef __REDIRECT
+extern int __REDIRECT (mkostemp, (char *__template, int __flags), mkostemp64)
+ __nonnull ((1)) __wur;
+# else
+# define mkostemp mkostemp64
+# endif
+# endif
+# ifdef __USE_LARGEFILE64
+extern int mkostemp64 (char *__template, int __flags) __nonnull ((1)) __wur;
+# endif
+#endif
+
__BEGIN_NAMESPACE_STD
/* Execute the given line as a shell command.
Modified: fsf/trunk/libc/sysdeps/ieee754/ldbl-128ibm/strtold_l.c
==============================================================================
--- fsf/trunk/libc/sysdeps/ieee754/ldbl-128ibm/strtold_l.c (original)
+++ fsf/trunk/libc/sysdeps/ieee754/ldbl-128ibm/strtold_l.c Sat Aug 11 00:02:39 2007
@@ -57,10 +57,12 @@
#ifdef __LONG_DOUBLE_MATH_OPTIONAL
# include <math_ldbl_opt.h>
# ifdef USE_WIDE_CHAR
-long_double_symbol (libc, __new_wcstold_l, wcstold_l);
+weak_alias (____new_wcstold_l, ___new_wcstold_l);
+long_double_symbol (libc, ___new_wcstold_l, wcstold_l);
long_double_symbol (libc, ____new_wcstold_l, __wcstold_l);
# else
-long_double_symbol (libc, __new_strtold_l, strtold_l);
+weak_alias (____new_strtold_l, ___new_strtold_l);
+long_double_symbol (libc, ___new_strtold_l, strtold_l);
long_double_symbol (libc, ____new_strtold_l, __strtold_l);
# endif
#endif
Modified: fsf/trunk/libc/sysdeps/mach/hurd/bits/ioctls.h
==============================================================================
--- fsf/trunk/libc/sysdeps/mach/hurd/bits/ioctls.h (original)
+++ fsf/trunk/libc/sysdeps/mach/hurd/bits/ioctls.h Sat Aug 11 00:02:39 2007
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992,93,96,97,98,99,2001 Free Software Foundation, Inc.
+/* Copyright (C) 1992,93,96,97,98,99,2001,2007 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
@@ -284,25 +284,30 @@
#define ODDP 0x00000040 /* get/send odd parity */
#define EVENP 0x00000080 /* get/send even parity */
#define ANYP 0x000000c0 /* get any parity/send none */
-#define NLDELAY 0x00000300 /* \n delay */
+#define NLDLY 0x00000300 /* \n delay */
+#define NLDELAY NLDLY /* traditional BSD name */
#define NL0 0x00000000
#define NL1 0x00000100 /* tty 37 */
#define NL2 0x00000200 /* vt05 */
#define NL3 0x00000300
-#define TBDELAY 0x00000c00 /* horizontal tab delay */
+#define TABDLY 0x00000c00 /* horizontal tab delay */
+#define TBDELAY TABDLY /* traditional BSD name */
#define TAB0 0x00000000
#define TAB1 0x00000400 /* tty 37 */
#define TAB2 0x00000800
#define XTABS 0x00000c00 /* expand tabs on output */
-#define CRDELAY 0x00003000 /* \r delay */
+#define CRDLY 0x00003000 /* \r delay */
+#define CRDELAY CRDLY /* traditional BSD name */
#define CR0 0x00000000
#define CR1 0x00001000 /* tn 300 */
#define CR2 0x00002000 /* tty 37 */
#define CR3 0x00003000 /* concept 100 */
-#define VTDELAY 0x00004000 /* vertical tab delay */
+#define VTDLY 0x00004000 /* vertical tab delay */
+#define VTDELAY VTDLY /* traditional BSD name */
#define FF0 0x00000000
#define FF1 0x00004000 /* tty 37 */
-#define BSDELAY 0x00008000 /* \b delay */
+#define BSDLY 0x00008000 /* \b delay */
+#define BSDELAY BSDLY /* traditional BSD name */
#define BS0 0x00000000
#define BS1 0x00008000
#define ALLDELAY (NLDELAY|TBDELAY|CRDELAY|VTDELAY|BSDELAY)
Modified: fsf/trunk/libc/sysdeps/posix/tempname.c
==============================================================================
--- fsf/trunk/libc/sysdeps/posix/tempname.c (original)
+++ fsf/trunk/libc/sysdeps/posix/tempname.c Sat Aug 11 00:02:39 2007
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-1999, 2000, 2001, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2001, 2006, 2007 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
@@ -37,9 +37,8 @@
#endif
#ifndef __GT_FILE
# define __GT_FILE 0
-# define __GT_BIGFILE 1
-# define __GT_DIR 2
-# define __GT_NOCREATE 3
+# define __GT_DIR 1
+# define __GT_NOCREATE 2
#endif
#if STDC_HEADERS || _LIBC
@@ -220,12 +219,11 @@
at the time of the call.
__GT_FILE: create the file using open(O_CREAT|O_EXCL)
and return a read-write fd. The file is mode 0600.
- __GT_BIGFILE: same as __GT_FILE but use open64().
__GT_DIR: create a directory, which will be mode 0700.
We use a clever algorithm to get hard-to-predict names. */
int
-__gen_tempname (char *tmpl, int kind)
+__gen_tempname (char *tmpl, int flags, int kind)
{
int len;
char *XXXXXX;
@@ -298,11 +296,9 @@
switch (kind)
{
case __GT_FILE:
- fd = __open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
- break;
-
- case __GT_BIGFILE:
- fd = __open64 (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
+ fd = __open (tmpl,
+ (flags & ~ACCESSPERMS)
+ | O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
break;
case __GT_DIR:
Modified: fsf/trunk/libc/sysdeps/unix/sysv/linux/shm_open.c
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/shm_open.c (original)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/shm_open.c Sat Aug 11 00:02:39 2007
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000,2001,2002,2003,2004,2006 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2004,2006,2007 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
@@ -46,6 +46,11 @@
__libc_once_define (static, once);
+#if defined O_CLOEXEC && !defined __ASSUME_O_CLOEXEC
+static bool have_o_cloexec;
+#endif
+
+
/* Determine where the shmfs is mounted (if at all). */
static void
where_is_shmfs (void)
@@ -160,6 +165,10 @@
__mempcpy (__mempcpy (fname, mountpoint.dir, mountpoint.dirlen),
name, namelen + 1);
+#ifdef O_CLOEXEC
+ oflag |= O_CLOEXEC;
+#endif
+
/* And get the file descriptor.
XXX Maybe we should test each descriptor whether it really is for a
file on the shmfs. If this is what should be done the whole function
@@ -168,23 +177,37 @@
fd = open (fname, oflag | O_NOFOLLOW, mode);
if (fd != -1)
{
- /* We got a descriptor. Now set the FD_CLOEXEC bit. */
- int flags = fcntl (fd, F_GETFD, 0);
-
- if (__builtin_expect (flags, 0) >= 0)
+#if !defined O_CLOEXEC || !defined __ASSUME_O_CLOEXEC
+# ifdef O_CLOEXEC
+ if (have_o_cloexec <= 0)
+# endif
{
- flags |= FD_CLOEXEC;
- flags = fcntl (fd, F_SETFD, flags);
+ /* We got a descriptor. Now set the FD_CLOEXEC bit. */
+ int flags = fcntl (fd, F_GETFD, 0);
+
+ if (__builtin_expect (flags, 0) >= 0)
+ {
+# ifdef O_CLOEXEC
+ if (have_o_cloexec == 0)
+ have_o_cloexec = (flags & FD_CLOEXEC) == 0 ? -1 : 1;
+ if (have_o_cloexec < 0)
+# endif
+ {
+ flags |= FD_CLOEXEC;
+ flags = fcntl (fd, F_SETFD, flags);
+ }
+ }
+
+ if (flags == -1)
+ {
+ /* Something went wrong. We cannot return the descriptor. */
+ int save_errno = errno;
+ close (fd);
+ fd = -1;
+ __set_errno (save_errno);
+ }
}
-
- if (flags == -1)
- {
- /* Something went wrong. We cannot return the descriptor. */
- int save_errno = errno;
- close (fd);
- fd = -1;
- __set_errno (save_errno);
- }
+#endif
}
else if (__builtin_expect (errno == EISDIR, 0))
/* It might be better to fold this error with EINVAL since