summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-08-03 16:47:01 +0000
committerUlrich Drepper <drepper@redhat.com>1998-08-03 16:47:01 +0000
commit7cabd57c0d64a2ee5ca0c5218c877ff700727880 (patch)
tree4db8d28a07bfb0ee5705e9199fcf1f59d5b27403
parent2698e32c2c2fae23c5c5f39f73b09553158b482d (diff)
Update.
1998-08-03 16:36 Ulrich Drepper <drepper@cygnus.com> * catgets/catgets.c: Use mmap/munmap only is _POSIX_MAPPED_FILES is defined. * catgets/open_catalog.c: Likewise. * iconv/iconv_prog.c: Likewise. * intl/loadmsgcat.c: Likewise. * locale/findlocale.c: Likewise. * locale/loadlocale.c: Likewise. * locale/programs/localedef.c: Likewise. * malloc/malloc.c: Likewise. * elf/elf.h: Fix typo. * math/Makefile: Use $(LN_S) instead of ln. * sysdeps/generic/getpgid.c: Fix return type. 1998-08-01 02:49 -0400 Zack Weinberg <zack@rabi.phys.columbia.edu> * sysdeps/posix/tempname.c (__stdio_gen_tempname): Rename to __gen_tempname and simplify the interface. Strip out the code to do path search and create FILE objects. This function now takes a mktemp() style template and returns either a name or a file descriptor. (__path_search): New function; searches for directories for temp files. * sysdeps/generic/tempname.c: Stub out __gen_tempname and __path_search, not __stdio_gen_tempname. * libio/stdio.h: Prototype __gen_tempname and __path_search, not __stdio_gen_tempname. * stdio/stdio.h: Likewise. * stdio-common/tempnam.c: Use __path_search and __gen_tempname. * stdio-common/tmpfile.c: Likewise. * stdio-common/tmpfile64.c: Likewise. * stdio-common/tmpnam.c: Likewise. * stdio-common/tmpnam_r.c: Likewise. * misc/mkstemp.c: New file. Use __gen_tempname. * misc/mktemp.c: Likewise. * sysdeps/posix/mkstemp.c: Removed. * sysdeps/posix/mktemp.c: Removed. * sysdeps/generic/mkstemp.c: Removed. * sysdeps/generic/mktemp.c: Removed. 1998-08-02 Thorsten Kukuk <kukuk@vt.uni-paderborn.de> * configure.in: Check, if door add-on is installed. * config.make.in: Add have_doors. * sunrpc/Makefile: Add HAVE_DOOR define. * sunrpc/key_call.c: Add keyserv/door interface. * sunrpc/svc_unix.c: Call setsockopt only if SO_PASSCRED is defined. * sunrpc/clnt_unix.c: Likewise. 1998-08-02 Andreas Jaeger <aj@arthur.rhein-neckar.de> * inet/netinet/in.h (IN_CLASSC): Correct mask. Reported by Ian Staniforth <I.Staniforth@sheffield.ac.uk> [fixes PR libc/727]. 1998-08-03 10:23 Ulrich Drepper <drepper@cygnus.com> * misc/Makefile: Fix installation problem with --disable-shared. * posix/Makefile: Likewise. 1998-08-02 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * posix/regex.c (re_search_2): Optimize searching for anchored pattern if '^' cannot match at embedded newlines. (regerror): Renamed from __regerror, which it should only be called if _LIBC. 1998-07-31 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sunrpc/svc_unix.c (__msgread): Check setsockopt return value. 1998-07-31 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * sysdeps/generic/glob.c: Remove obsolete cast. 1998-07-31 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de> * Rules (tests): Fix last change.
-rw-r--r--ChangeLog88
-rw-r--r--Rules10
-rw-r--r--catgets/catgets.c19
-rw-r--r--catgets/open_catalog.c28
-rw-r--r--config.make.in1
-rwxr-xr-xconfigure7
-rw-r--r--configure.in6
-rw-r--r--elf/elf.h2
-rw-r--r--iconv/iconv_prog.c6
-rw-r--r--include/bits/cmathcalls.h1
-rw-r--r--include/complex.h1
-rw-r--r--include/execinfo.h1
-rw-r--r--include/fenv.h1
-rw-r--r--inet/netinet/in.h2
-rw-r--r--intl/loadmsgcat.c23
-rw-r--r--libio/stdio.h13
-rw-r--r--linuxthreads/ChangeLog5
-rw-r--r--linuxthreads/Makefile3
-rw-r--r--locale/findlocale.c6
-rw-r--r--locale/loadlocale.c46
-rw-r--r--locale/programs/localedef.c6
-rw-r--r--malloc/malloc.c12
-rw-r--r--math/Makefile2
-rw-r--r--misc/Makefile3
-rw-r--r--misc/mkstemp.c (renamed from sysdeps/generic/mkstemp.c)20
-rw-r--r--misc/mktemp.c (renamed from sysdeps/generic/mktemp.c)20
-rw-r--r--posix/Makefile2
-rw-r--r--posix/regex.c8
-rw-r--r--stdio-common/tempnam.c17
-rw-r--r--stdio-common/tmpfile.c18
-rw-r--r--stdio-common/tmpfile64.c23
-rw-r--r--stdio-common/tmpnam.c22
-rw-r--r--stdio-common/tmpnam_r.c16
-rw-r--r--stdio/stdio.h15
-rw-r--r--sunrpc/Makefile4
-rw-r--r--sunrpc/clnt_unix.c5
-rw-r--r--sunrpc/key_call.c87
-rw-r--r--sunrpc/svc_unix.c5
-rw-r--r--sysdeps/generic/getpgid.c4
-rw-r--r--sysdeps/generic/glob.c2
-rw-r--r--sysdeps/generic/tempname.c46
-rw-r--r--sysdeps/posix/mkstemp.c90
-rw-r--r--sysdeps/posix/mktemp.c89
-rw-r--r--sysdeps/posix/tempname.c287
44 files changed, 520 insertions, 552 deletions
diff --git a/ChangeLog b/ChangeLog
index e918d29cac..095145f991 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,91 @@
+1998-08-03 16:36 Ulrich Drepper <drepper@cygnus.com>
+
+ * catgets/catgets.c: Use mmap/munmap only is _POSIX_MAPPED_FILES
+ is defined.
+ * catgets/open_catalog.c: Likewise.
+ * iconv/iconv_prog.c: Likewise.
+ * intl/loadmsgcat.c: Likewise.
+ * locale/findlocale.c: Likewise.
+ * locale/loadlocale.c: Likewise.
+ * locale/programs/localedef.c: Likewise.
+ * malloc/malloc.c: Likewise.
+
+ * elf/elf.h: Fix typo.
+
+ * math/Makefile: Use $(LN_S) instead of ln.
+
+ * sysdeps/generic/getpgid.c: Fix return type.
+
+1998-08-01 02:49 -0400 Zack Weinberg <zack@rabi.phys.columbia.edu>
+
+ * sysdeps/posix/tempname.c (__stdio_gen_tempname): Rename to
+ __gen_tempname and simplify the interface. Strip out the
+ code to do path search and create FILE objects. This function
+ now takes a mktemp() style template and returns either a name
+ or a file descriptor.
+ (__path_search): New function; searches for directories for
+ temp files.
+ * sysdeps/generic/tempname.c: Stub out __gen_tempname and
+ __path_search, not __stdio_gen_tempname.
+
+ * libio/stdio.h: Prototype __gen_tempname and __path_search,
+ not __stdio_gen_tempname.
+ * stdio/stdio.h: Likewise.
+
+ * stdio-common/tempnam.c: Use __path_search and __gen_tempname.
+ * stdio-common/tmpfile.c: Likewise.
+ * stdio-common/tmpfile64.c: Likewise.
+ * stdio-common/tmpnam.c: Likewise.
+ * stdio-common/tmpnam_r.c: Likewise.
+
+ * misc/mkstemp.c: New file. Use __gen_tempname.
+ * misc/mktemp.c: Likewise.
+
+ * sysdeps/posix/mkstemp.c: Removed.
+ * sysdeps/posix/mktemp.c: Removed.
+ * sysdeps/generic/mkstemp.c: Removed.
+ * sysdeps/generic/mktemp.c: Removed.
+
+1998-08-02 Thorsten Kukuk <kukuk@vt.uni-paderborn.de>
+
+ * configure.in: Check, if door add-on is installed.
+ * config.make.in: Add have_doors.
+ * sunrpc/Makefile: Add HAVE_DOOR define.
+ * sunrpc/key_call.c: Add keyserv/door interface.
+
+ * sunrpc/svc_unix.c: Call setsockopt only if SO_PASSCRED is defined.
+ * sunrpc/clnt_unix.c: Likewise.
+
+1998-08-02 Andreas Jaeger <aj@arthur.rhein-neckar.de>
+
+ * inet/netinet/in.h (IN_CLASSC): Correct mask.
+ Reported by Ian Staniforth <I.Staniforth@sheffield.ac.uk> [fixes
+ PR libc/727].
+
+1998-08-03 10:23 Ulrich Drepper <drepper@cygnus.com>
+
+ * misc/Makefile: Fix installation problem with --disable-shared.
+ * posix/Makefile: Likewise.
+
+1998-08-02 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * posix/regex.c (re_search_2): Optimize searching for anchored
+ pattern if '^' cannot match at embedded newlines.
+ (regerror): Renamed from __regerror, which it should only be
+ called if _LIBC.
+
+1998-07-31 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * sunrpc/svc_unix.c (__msgread): Check setsockopt return value.
+
+1998-07-31 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * sysdeps/generic/glob.c: Remove obsolete cast.
+
+1998-07-31 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * Rules (tests): Fix last change.
+
1998-07-31 17:59 Ulrich Drepper <drepper@cygnus.com>
* sysdeps/unix/sysv/linux/Makefile [subdir==misc] (sysdep_routines):
diff --git a/Rules b/Rules
index 2353cc34a0..a3005a069e 100644
--- a/Rules
+++ b/Rules
@@ -89,12 +89,14 @@ else
others: $(addprefix $(objpfx),$(extra-objs))
endif
ifeq ($(cross-compiling),yes)
-tests: $(addprefix $(objpfx),$(tests) $(tests-static) $(test-srcs))
+tests: $(addprefix $(objpfx),$(tests) $(test-srcs))
+ifeq ($(build-static),yes)
+tests: $(addprefix $(objpfx),$(tests-static))
+endif
else
-ifneq (($build-static),yes)
tests: $(tests:%=$(objpfx)%.out)
-else
-tests: $(tests:%=$(objpfx)%.out) $(tests-static:%=$(objpfx)%.sout)
+ifeq ($(build-static),yes)
+tests: $(tests-static:%=$(objpfx)%.sout)
endif
endif
diff --git a/catgets/catgets.c b/catgets/catgets.c
index ebfb2c54cc..b5de2fbb50 100644
--- a/catgets/catgets.c
+++ b/catgets/catgets.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>.
@@ -166,15 +166,18 @@ catclose (nl_catd catalog_desc)
catalog = (__nl_catd) catalog_desc;
+#ifdef _POSIX_MAPPED_FILES
if (catalog->status == mmapped)
__munmap ((void *) catalog->file_ptr, catalog->file_size);
- else if (catalog->status == malloced)
- free ((void *) catalog->file_ptr);
- else if (catalog->status != closed && catalog->status != nonexisting)
- {
- __set_errno (EBADF);
- return -1;
- }
+ else
+#endif /* _POSIX_MAPPED_FILES */
+ if (catalog->status == malloced)
+ free ((void *) catalog->file_ptr);
+ else if (catalog->status != closed && catalog->status != nonexisting)
+ {
+ __set_errno (EBADF);
+ return -1;
+ }
if (catalog->nlspath)
free ((void *) catalog->nlspath);
diff --git a/catgets/open_catalog.c b/catgets/open_catalog.c
index deaa8718dd..e4b61d779a 100644
--- a/catgets/open_catalog.c
+++ b/catgets/open_catalog.c
@@ -24,7 +24,9 @@
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
-#include <sys/mman.h>
+#ifdef _POSIX_MAPPED_FILES
+# include <sys/mman.h>
+#endif
#include <sys/stat.h>
#include "catgetsinfo.h"
@@ -194,19 +196,20 @@ __open_catalog (__nl_catd catalog)
goto unlock_return;
}
-#ifndef MAP_COPY
+ catalog->file_size = st.st_size;
+#ifdef _POSIX_MAPPED_FILES
+# ifndef MAP_COPY
/* Linux seems to lack read-only copy-on-write. */
-# define MAP_COPY MAP_PRIVATE
-#endif
-#ifndef MAP_FILE
+# define MAP_COPY MAP_PRIVATE
+# endif
+# ifndef MAP_FILE
/* Some systems do not have this flag; it is superfluous. */
-# define MAP_FILE 0
-#endif
-#ifndef MAP_INHERIT
+# define MAP_FILE 0
+# endif
+# ifndef MAP_INHERIT
/* Some systems might lack this; they lose. */
-# define MAP_INHERIT 0
-#endif
- catalog->file_size = st.st_size;
+# define MAP_INHERIT 0
+# endif
catalog->file_ptr =
(struct catalog_obj *) __mmap (NULL, st.st_size, PROT_READ,
MAP_FILE|MAP_COPY|MAP_INHERIT, fd, 0);
@@ -214,6 +217,7 @@ __open_catalog (__nl_catd catalog)
/* Tell the world we managed to mmap the file. */
catalog->status = mmapped;
else
+#endif /* _POSIX_MAPPED_FILES */
{
/* mmap failed perhaps because the system call is not
implemented. Try to load the file. */
@@ -258,9 +262,11 @@ __open_catalog (__nl_catd catalog)
invalid_file:
/* Invalid file. Free the resources and mark catalog as not
usable. */
+#ifdef _POSIX_MAPPED_FILES
if (catalog->status == mmapped)
__munmap ((void *) catalog->file_ptr, catalog->file_size);
else
+#endif /* _POSIX_MAPPED_FILES */
free (catalog->file_ptr);
catalog->status = nonexisting;
goto unlock_return;
diff --git a/config.make.in b/config.make.in
index 9f8ea0a909..6b4dc7ae9b 100644
--- a/config.make.in
+++ b/config.make.in
@@ -40,6 +40,7 @@ old-glibc-headers = @old_glibc_headers@
versioning = @VERSIONING@
no-whole-archive = @no_whole_archive@
exceptions = @exceptions@
+have_doors = @linux_doors@
have-bash2 = @libc_cv_have_bash2@
have-ksh = @libc_cv_have_ksh@
diff --git a/configure b/configure
index 1b50582d81..fc1f09aea6 100755
--- a/configure
+++ b/configure
@@ -2879,6 +2879,12 @@ echo "$ac_t""$pic_default" 1>&6
+case "$add_ons" in
+ *door*) linux_doors=yes ;;
+ *) linux_doors=no ;;
+esac
+
+
if test "`(cd $srcdir; pwd)`" = "`pwd`"; then
config_makefile=
else
@@ -3083,6 +3089,7 @@ s%@bounded@%$bounded%g
s%@static_nss@%$static_nss%g
s%@nopic_initfini@%$nopic_initfini%g
s%@DEFINES@%$DEFINES%g
+s%@linux_doors@%$linux_doors%g
s%@VERSION@%$VERSION%g
s%@RELEASE@%$RELEASE%g
diff --git a/configure.in b/configure.in
index 2f7f925516..036491805a 100644
--- a/configure.in
+++ b/configure.in
@@ -1168,6 +1168,12 @@ AC_SUBST(nopic_initfini)
AC_SUBST(DEFINES)
+case "$add_ons" in
+ *door*) linux_doors=yes ;;
+ *) linux_doors=no ;;
+esac
+AC_SUBST(linux_doors)
+
if test "`(cd $srcdir; pwd)`" = "`pwd`"; then
config_makefile=
else
diff --git a/elf/elf.h b/elf/elf.h
index 4974c08edd..6418927160 100644
--- a/elf/elf.h
+++ b/elf/elf.h
@@ -1170,7 +1170,7 @@ typedef struct
#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */
#define DT_MIPS_NUM 0x32
-/* Legal values for DT_MIPS_FLAG Elf32_Dyn entry. */
+/* Legal values for DT_MIPS_FLAGS Elf32_Dyn entry. */
#define RHF_NONE 0 /* No flags */
#define RHF_QUICKSTART (1 << 0) /* Use quickstart */
diff --git a/iconv/iconv_prog.c b/iconv/iconv_prog.c
index 82ff5cf802..f12a69020e 100644
--- a/iconv/iconv_prog.c
+++ b/iconv/iconv_prog.c
@@ -30,7 +30,9 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <sys/mman.h>
+#ifdef _POSIX_MAPPED_FILES
+# include <sys/mman.h>
+#endif
#include <gconv_int.h>
/* Get libc version number. */
@@ -176,6 +178,7 @@ main (int argc, char *argv[])
continue;
}
+#ifdef _POSIX_MAPPED_FILES
/* We have possibilities for reading the input file. First try
to mmap() it since this will provide the fastest solution. */
if (fstat (fd, &st) == 0
@@ -206,6 +209,7 @@ main (int argc, char *argv[])
munmap ((void *) addr, st.st_size);
}
else
+#endif /* _POSIX_MAPPED_FILES */
{
/* Read the file in pieces. */
if (process_fd (cd, fd, output) != 0)
diff --git a/include/bits/cmathcalls.h b/include/bits/cmathcalls.h
new file mode 100644
index 0000000000..dd029602f9
--- /dev/null
+++ b/include/bits/cmathcalls.h
@@ -0,0 +1 @@
+#include <math/bits/cmathcalls.h>
diff --git a/include/complex.h b/include/complex.h
new file mode 100644
index 0000000000..acf8cf14ba
--- /dev/null
+++ b/include/complex.h
@@ -0,0 +1 @@
+#include <math/complex.h>
diff --git a/include/execinfo.h b/include/execinfo.h
new file mode 100644
index 0000000000..d5c52164d2
--- /dev/null
+++ b/include/execinfo.h
@@ -0,0 +1 @@
+#include <debug/execinfo.h>
diff --git a/include/fenv.h b/include/fenv.h
new file mode 100644
index 0000000000..b2da08406c
--- /dev/null
+++ b/include/fenv.h
@@ -0,0 +1 @@
+#include <math/fenv.h>
diff --git a/inet/netinet/in.h b/inet/netinet/in.h
index ddc09753e2..418c6f96f7 100644
--- a/inet/netinet/in.h
+++ b/inet/netinet/in.h
@@ -118,7 +118,7 @@ struct in_addr
#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET)
#define IN_CLASSB_MAX 65536
-#define IN_CLASSC(a) ((((uint32_t) (a)) & 0xc0000000) == 0xc0000000)
+#define IN_CLASSC(a) ((((uint32_t) (a)) & 0xe0000000) == 0xc0000000)
#define IN_CLASSC_NET 0xffffff00
#define IN_CLASSC_NSHIFT 8
#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET)
diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c
index f6214e1428..480e6bc384 100644
--- a/intl/loadmsgcat.c
+++ b/intl/loadmsgcat.c
@@ -35,8 +35,13 @@
# include <unistd.h>
#endif
-#if (defined HAVE_MMAP && defined HAVE_MUNMAP) || defined _LIBC
+#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \
+ || (defined _LIBC && defined _POSIX_MAPPED_FILES)
# include <sys/mman.h>
+# undef HAVE_MMAP
+# define HAVE_MMAP 1
+#else
+# undef HAVE_MMAP
#endif
#include "gettext.h"
@@ -72,10 +77,7 @@ _nl_load_domain (domain_file)
size_t size;
struct stat st;
struct mo_file_header *data = (struct mo_file_header *) -1;
-#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \
- || defined _LIBC
int use_mmap = 0;
-#endif
struct loaded_domain *domain;
domain_file->decided = 1;
@@ -103,8 +105,7 @@ _nl_load_domain (domain_file)
return;
}
-#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \
- || defined _LIBC
+#ifdef HAVE_MMAP
/* Now we are ready to load the file. If mmap() is available we try
this first. If not available or it failed we try to load it. */
data = (struct mo_file_header *) mmap (NULL, size, PROT_READ,
@@ -153,8 +154,7 @@ _nl_load_domain (domain_file)
if (data->magic != _MAGIC && data->magic != _MAGIC_SWAPPED)
{
/* The magic number is wrong: not a message catalog file. */
-#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \
- || defined _LIBC
+#ifdef HAVE_MMAP
if (use_mmap)
munmap ((caddr_t) data, size);
else
@@ -188,9 +188,8 @@ _nl_load_domain (domain_file)
((char *) data + W (domain->must_swap, data->hash_tab_offset));
break;
default:
- /* This is an illegal revision. */
-#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \
- || defined _LIBC
+ /* This is an invalid revision. */
+#ifdef HAVE_MMAP
if (use_mmap)
munmap ((caddr_t) data, size);
else
@@ -213,9 +212,11 @@ internal_function
_nl_unload_domain (domain)
struct loaded_domain *domain;
{
+#ifdef _POSIX_MAPPED_FILES
if (domain->use_mmap)
munmap ((caddr_t) domain->data, domain->mmap_size);
else
+#endif /* _POSIX_MAPPED_FILES */
free ((void *) domain->data);
free (domain);
diff --git a/libio/stdio.h b/libio/stdio.h
index a3ae40b536..7b5e4f857f 100644
--- a/libio/stdio.h
+++ b/libio/stdio.h
@@ -72,15 +72,12 @@ typedef _G_fpos64_t fpos_t;
typedef _G_fpos64_t fpos64_t;
#endif
-/* Generate a unique file name (and possibly open it with mode "w+b"). */
-extern char *__stdio_gen_tempname __P ((char *__buf, size_t __bufsize,
- __const char *__dir,
- __const char *__pfx,
- int __dir_search,
- size_t *__lenptr,
- FILE **__streamptr,
- int __large_file));
+/* Generate a unique file name (and possibly open it). */
+extern int __path_search __P ((char *__tmpl, size_t __tmpl_len,
+ __const char *__dir,
+ __const char *__pfx));
+extern int __gen_tempname __P ((char *__tmpl, int __openit, int __large_file));
/* Print out MESSAGE on the error output and abort. */
extern void __libc_fatal __P ((__const char *__message))
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog
index c3f7dc3dc8..47d8417a18 100644
--- a/linuxthreads/ChangeLog
+++ b/linuxthreads/ChangeLog
@@ -1,3 +1,8 @@
+1998-08-02 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
+
+ * Makefile (linuxthreads-version): Extract correct number from
+ Banner.
+
1998-07-29 Xavier Leroy <Xavier.Leroy@inria.fr>
* Banner: Bump version number to 0.8
diff --git a/linuxthreads/Makefile b/linuxthreads/Makefile
index b7444e7e4e..742be86445 100644
--- a/linuxthreads/Makefile
+++ b/linuxthreads/Makefile
@@ -21,7 +21,8 @@
#
subdir := linuxthreads
-linuxthreads-version=0.7
+linuxthreads-version := $(shell sed -n 's/^.*$(subdir)-\([0-9.]*\).*$$/\1/p' \
+ Banner)
headers := pthread.h semaphore.h bits/semaphore.h
distribute := internals.h queue.h restart.h spinlock.h
diff --git a/locale/findlocale.c b/locale/findlocale.c
index e2fdd06f6d..af2b36439e 100644
--- a/locale/findlocale.c
+++ b/locale/findlocale.c
@@ -21,7 +21,9 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <sys/mman.h>
+#ifdef _POSIX_MAPPED_FILES
+# include <sys/mman.h>
+#endif
#include "localeinfo.h"
@@ -211,6 +213,7 @@ _nl_remove_locale (int locale, struct locale_data *data)
/* Free the name. */
free ((char *) data->name);
+#ifdef _POSIX_MAPPED_FILES
/* Really delete the data. First delete the real data. */
if (data->mmaped)
{
@@ -223,6 +226,7 @@ _nl_remove_locale (int locale, struct locale_data *data)
}
}
else
+#endif /* _POSIX_MAPPED_FILES */
/* The memory was malloced. */
free ((void *) data->filedata);
diff --git a/locale/loadlocale.c b/locale/loadlocale.c
index d856063d52..8649abb241 100644
--- a/locale/loadlocale.c
+++ b/locale/loadlocale.c
@@ -23,7 +23,9 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <sys/mman.h>
+#ifdef _POSIX_MAPPED_FILES
+# include <sys/mman.h>
+#endif
#include <sys/stat.h>
#include "localeinfo.h"
@@ -113,24 +115,32 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
/* Map in the file's data. */
save_err = errno;
-#ifndef MAP_COPY
+#ifdef _POSIX_MAPPED_FILES
+# ifndef MAP_COPY
/* Linux seems to lack read-only copy-on-write. */
-#define MAP_COPY MAP_PRIVATE
-#endif
-#ifndef MAP_FILE
+# define MAP_COPY MAP_PRIVATE
+# endif
+# ifndef MAP_FILE
/* Some systems do not have this flag; it is superfluous. */
-#define MAP_FILE 0
-#endif
-#ifndef MAP_INHERIT
+# define MAP_FILE 0
+# endif
+# ifndef MAP_INHERIT
/* Some systems might lack this; they lose. */
-#define MAP_INHERIT 0
-#endif
+# define MAP_INHERIT 0
+# endif
filedata = (void *) __mmap ((caddr_t) 0, st.st_size, PROT_READ,
MAP_FILE|MAP_COPY|MAP_INHERIT, fd, 0);
- if ((void *) filedata == MAP_FAILED)
+ if ((void *) filedata != MAP_FAILED)
+ {
+ if (st.st_size < sizeof (*filedata))
+ /* This cannot be a locale data file since it's too small. */
+ goto puntfd;
+ }
+ else
{
if (errno == ENOSYS)
{
+#endif /* _POSIX_MAPPED_FILES */
/* No mmap; allocate a buffer and read from the file. */
mmaped = 0;
filedata = malloc (st.st_size);
@@ -156,13 +166,12 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
else
goto puntfd;
__set_errno (save_err);
+#ifdef _POSIX_MAPPED_FILES
}
else
goto puntfd;
}
- else if (st.st_size < sizeof (*filedata))
- /* This cannot be a locale data file since it's too small. */
- goto puntfd;
+#endif /* _POSIX_MAPPED_FILES */
if (filedata->magic == LIMAGIC (category))
/* Good data file in our byte order. */
@@ -175,7 +184,12 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
/* Bad data file in either byte order. */
{
puntmap:
- __munmap ((caddr_t) filedata, st.st_size);
+#ifdef _POSIX_MAPPED_FILES
+ if (mmaped)
+ __munmap ((caddr_t) filedata, st.st_size);
+ else
+#endif /* _POSIX_MAPPED_FILES */
+ free (filedata);
puntfd:
__close (fd);
return;
@@ -228,9 +242,11 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
void
_nl_unload_locale (struct locale_data *locale)
{
+#ifdef _POSIX_MAPPED_FILES
if (locale->mmaped)
__munmap ((caddr_t) locale->filedata, locale->filesize);
else
+#endif
free ((void *) locale->filedata);
free (locale);
diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c
index 6d32a3fbfa..94d6255378 100644
--- a/locale/programs/localedef.c
+++ b/locale/programs/localedef.c
@@ -30,7 +30,9 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <sys/mman.h>
+#ifdef _POSIX2_LOCALEDEF
+# include <sys/mman.h>
+#endif
#include <sys/stat.h>
#include "error.h"
@@ -276,10 +278,12 @@ cannot `stat' locale file `%s'"),
fname);
localedef->len[cat] = st.st_size;
+#ifdef _POSIX_MAPPED_FILES
localedef->categories[cat].generic
= mmap (NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if (localedef->categories[cat].generic == MAP_FAILED)
+#endif /* _POSIX_MAPPED_FILES */
{
size_t left = st.st_size;
void *read_ptr;
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 9c99c67d67..3d932db5e3 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -493,6 +493,10 @@ do { \
#endif
+#ifndef LACKS_UNISTD_H
+# include <unistd.h>
+#endif
+
/*
Define HAVE_MMAP to optionally make malloc() use mmap() to
allocate very large blocks. These will be returned to the
@@ -500,7 +504,9 @@ do { \
*/
#ifndef HAVE_MMAP
-#define HAVE_MMAP 1
+# ifdef _POSIX_MAPPED_FILES
+# define HAVE_MMAP 1
+# endif
#endif
/*
@@ -541,10 +547,6 @@ do { \
bsd/gnu getpagesize.h
*/
-#ifndef LACKS_UNISTD_H
-# include <unistd.h>
-#endif
-
#ifndef malloc_getpagesize
# ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */
# ifndef _SC_PAGE_SIZE
diff --git a/math/Makefile b/math/Makefile
index 4bd9580084..6930b206a7 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -140,7 +140,7 @@ override CFLAGS += -Wno-uninitialized -Wno-write-strings
# It's not a library to make sure it is linked in instead of s_lib_version.o.
$(objpfx)libieee.a: $(objpfx)ieee-math.o
rm -f $@
- ln $< $@
+ $(LN_S) $< $@
ifeq ($(build-shared),yes)
$(addprefix $(objpfx),$(tests)): $(objpfx)libm.so$(libm.so-version)
diff --git a/misc/Makefile b/misc/Makefile
index 7a233f5486..d7982d2b79 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -57,6 +57,9 @@ routines := brk sbrk sstk ioctl \
hsearch hsearch_r tsearch lsearch \
err error ustat \
getsysstats dirname regexp
+
+include ../Makeconfig
+
aux := init-misc
ifeq ($(build-static),yes)
install-lib := libbsd-compat.a libg.a
diff --git a/sysdeps/generic/mkstemp.c b/misc/mkstemp.c
index c84e8eb4c2..3fa033bd6b 100644
--- a/sysdeps/generic/mkstemp.c
+++ b/misc/mkstemp.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1995, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1998 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,27 +16,17 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <stdlib.h>
-#include <string.h>
#include <errno.h>
+#include <stdio.h>
+#include <unistd.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.
- Returns a file descriptor open on the file for reading and writing. */
+ Then open the file and return a fd. */
int
mkstemp (template)
char *template;
{
- if (strcmp (&template[strlen (template) - 6], "XXXXXX"))
- {
- __set_errno (EINVAL);
- return -1;
- }
-
- __set_errno (ENOSYS);
- return -1;
+ return __gen_tempname (template, 1, 0);
}
-
-stub_warning (mkstemp)
-#include <stub-tag.h>
diff --git a/sysdeps/generic/mktemp.c b/misc/mktemp.c
index 7d53f01c04..b2abc5d5e0 100644
--- a/sysdeps/generic/mktemp.c
+++ b/misc/mktemp.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1995, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1998 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,9 +16,9 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <stdlib.h>
-#include <string.h>
#include <errno.h>
+#include <stdio.h>
+#include <unistd.h>
/* Generate a unique temporary file name from TEMPLATE.
The last six characters of TEMPLATE must be "XXXXXX";
@@ -27,15 +27,9 @@ char *
mktemp (template)
char *template;
{
- if (strcmp (&template[strlen (template) - 6], "XXXXXX"))
- {
- __set_errno (EINVAL);
- return template;
- }
+ if (__gen_tempname (template, 0, 0) < 0)
+ /* We return the null string if we can't find a unique file name. */
+ template[0] = '\0';
- __set_errno (ENOSYS);
- return NULL;
+ return template;
}
-
-stub_warning (mktemp)
-#include <stub-tag.h>
diff --git a/posix/Makefile b/posix/Makefile
index daf4960d86..201cb781b7 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -52,6 +52,8 @@ routines := \
getaddrinfo gai_strerror wordexp \
pread pwrite pread64 pwrite64
+include ../Makeconfig
+
aux := init-posix environ
tests := tstgetopt testfnm runtests wordexp-test runptests
test-srcs := globtest
diff --git a/posix/regex.c b/posix/regex.c
index 62c41c11bb..484e13d799 100644
--- a/posix/regex.c
+++ b/posix/regex.c
@@ -3525,7 +3525,11 @@ re_search_2 (bufp, string1, size1, string2, size2, startpos, range, regs, stop)
/* If the search isn't to be a backwards one, don't waste time in a
search for a pattern that must be anchored. */
- if (bufp->used > 0 && (re_opcode_t) bufp->buffer[0] == begbuf && range > 0)
+ if (bufp->used > 0 && range > 0
+ && ((re_opcode_t) bufp->buffer[0] == begbuf
+ /* `begline' is like `begbuf' if it cannot match at newlines. */
+ || ((re_opcode_t) bufp->buffer[0] == begline
+ && !bufp->newline_anchor)))
{
if (startpos > 0)
return -1;
@@ -5737,7 +5741,7 @@ weak_alias (__regexec, regexec)
from either regcomp or regexec. We don't use PREG here. */
size_t
-__regerror (errcode, preg, errbuf, errbuf_size)
+regerror (errcode, preg, errbuf, errbuf_size)
int errcode;
const regex_t *preg;
char *errbuf;
diff --git a/stdio-common/tempnam.c b/stdio-common/tempnam.c
index 987fbbbabe..8683643c76 100644
--- a/stdio-common/tempnam.c
+++ b/stdio-common/tempnam.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1993, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1993, 1996, 1997, 1998 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,13 +16,9 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <errno.h>
-#include <stddef.h>
#include <stdio.h>
-#include <stdlib.h>
#include <string.h>
-
/* Generate a unique temporary filename using up to five characters of PFX
if it is not NULL. The directory to put this file in is searched for
as follows: First the environment variable "TMPDIR" is checked.
@@ -34,17 +30,12 @@ char *
tempnam (const char *dir, const char *pfx)
{
char buf[FILENAME_MAX];
- size_t len;
- char *s;
- char *t = __stdio_gen_tempname (buf, sizeof (buf), dir, pfx, 1,
- &len, (FILE **) NULL, 0);
- if (t == NULL)
+ if (__path_search (buf, FILENAME_MAX, dir, pfx))
return NULL;
- s = (char *) malloc (len);
- if (s == NULL)
+ if (__gen_tempname (buf, 0, 0))
return NULL;
- return (char *) memcpy (s, t, len);
+ return strdup (buf);
}
diff --git a/stdio-common/tmpfile.c b/stdio-common/tmpfile.c
index c3afd3f78b..488b43b1f7 100644
--- a/stdio-common/tmpfile.c
+++ b/stdio-common/tmpfile.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1993, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1993, 1996, 1997, 1998 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
@@ -18,6 +18,9 @@
#include <stdio.h>
+#ifdef _USE_IN_LIBIO
+# define fdopen _IO_new_fdopen
+#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).
@@ -27,17 +30,20 @@ FILE *
tmpfile ()
{
char buf[FILENAME_MAX];
- char *filename;
+ int fd;
FILE *f;
- filename = __stdio_gen_tempname (buf, sizeof (buf), (char *) NULL, "tmpf", 0,
- (size_t *) NULL, &f, 0);
- if (filename == NULL)
+ if (__path_search (buf, FILENAME_MAX, NULL, "tmpf"))
+ return NULL;
+ if ((fd = __gen_tempname (buf, 1, 0)) < 0)
return NULL;
/* Note that this relies on the Unix semantics that
a file is not really removed until it is closed. */
- (void) remove (filename);
+ (void) remove (buf);
+
+ if ((f = fdopen (fd, "w+b")) == NULL)
+ close (fd);
return f;
}
diff --git a/stdio-common/tmpfile64.c b/stdio-common/tmpfile64.c
index 5a6e3238fc..5854f1451d 100644
--- a/stdio-common/tmpfile64.c
+++ b/stdio-common/tmpfile64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1993, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1993, 1996, 1997, 1998 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
@@ -19,6 +19,9 @@
#include <errno.h>
#include <stdio.h>
+#ifdef _USE_IN_LIBIO
+# define fdopen _IO_new_fdopen
+#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).
@@ -27,23 +30,21 @@
FILE *
tmpfile64 ()
{
-#ifdef _G_OPEN64
char buf[FILENAME_MAX];
- char *filename;
+ int fd;
FILE *f;
- filename = __stdio_gen_tempname (buf, sizeof (buf), (char *) NULL, "tmpf", 0,
- (size_t *) NULL, &f, 1);
- if (filename == NULL)
+ if (__path_search (buf, FILENAME_MAX, NULL, "tmpf"))
+ return NULL;
+ if ((fd = __gen_tempname (buf, 1, 1)) < 0)
return NULL;
/* Note that this relies on the Unix semantics that
a file is not really removed until it is closed. */
- (void) remove (filename);
+ (void) remove (buf);
+
+ if ((f = fdopen (fd, "w+b")) == NULL)
+ close (fd);
return f;
-#else
- __set_errno (ENOSYS);
- return NULL;
-#endif
}
diff --git a/stdio-common/tmpnam.c b/stdio-common/tmpnam.c
index 3389ff57b4..e5c6bf166d 100644
--- a/stdio-common/tmpnam.c
+++ b/stdio-common/tmpnam.c
@@ -19,7 +19,6 @@
#include <stdio.h>
#include <string.h>
-
/* Generate a unique filename in P_tmpdir.
This function is *not* thread safe! */
@@ -30,20 +29,21 @@ tmpnam (char *s)
where S != NULL. */
static char buf[L_tmpnam];
char tmpbuf[L_tmpnam];
- char *result;
/* In the following call we use the buffer pointed to by S if
non-NULL although we don't know the size. But we limit the size
- to FILENAME_MAX characters in any case. */
- result = __stdio_gen_tempname (s ?: tmpbuf, L_tmpnam, (const char *) NULL,
- (const char *) NULL, 0,
- (size_t *) NULL, (FILE **) NULL, 0);
+ to L_tmpnam characters in any case. */
+ if (__path_search (s ? : tmpbuf, L_tmpnam, NULL, NULL))
+ return NULL;
+
+ if (__gen_tempname (s ? : tmpbuf, 0, 0))
+ return NULL;
- if (result != NULL && s == NULL)
+ if (s == NULL)
{
- memcpy (buf, result, L_tmpnam);
- result = buf;
+ memcpy (buf, tmpbuf, L_tmpnam);
+ return buf;
}
-
- return result;
+ else
+ return s;
}
diff --git a/stdio-common/tmpnam_r.c b/stdio-common/tmpnam_r.c
index 5e67cc6845..07c4650cc0 100644
--- a/stdio-common/tmpnam_r.c
+++ b/stdio-common/tmpnam_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1993, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1993, 1996, 1997, 1998 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,8 +17,6 @@
Boston, MA 02111-1307, USA. */
#include <stdio.h>
-#include <string.h>
-
/* Generate a unique filename in P_tmpdir. If S is NULL return NULL.
This makes this function thread safe. */
@@ -28,10 +26,10 @@ tmpnam_r (char *s)
if (s == NULL)
return NULL;
- /* In the following call we use the buffer pointed to by S if
- non-NULL although we don't know the size. But we limit the size
- to L_tmpnam characters in any case. */
- return __stdio_gen_tempname (s, L_tmpnam, (const char *) NULL,
- (const char *) NULL, 0,
- (size_t *) NULL, (FILE **) NULL, 0);
+ if (__path_search (s, L_tmpnam, NULL, NULL))
+ return NULL;
+ if (__gen_tempname (s, 0, 0))
+ return NULL;
+
+ return s;
}
diff --git a/stdio/stdio.h b/stdio/stdio.h
index 7594f13840..2214302b68 100644
--- a/stdio/stdio.h
+++ b/stdio/stdio.h
@@ -155,14 +155,13 @@ extern int __stdio_open __P ((__const char *__file, __io_mode __m,
__ptr_t *__cookieptr));
/* Put out an error message for when stdio needs to die. */
extern void __stdio_errmsg __P ((__const char *__msg, size_t __len));
-/* Generate a unique file name (and possibly open it with mode "w+b"). */
-extern char *__stdio_gen_tempname __P ((char *__buf, size_t __bufsize,
- __const char *__dir,
- __const char *__pfx,
- int __dir_search,
- size_t *__lenptr,
- FILE **__streamptr,
- int __large_file));
+
+/* Generate a unique file name (and possibly open it). */
+extern int __path_search __P ((char *__tmpl, size_t __tmpl_len,
+ __const char *__dir,
+ __const char *__pfx));
+
+extern int __gen_tempname __P ((char *__tmpl, int __openit, int __large_file));
/* Print out MESSAGE on the error output and abort. */
diff --git a/sunrpc/Makefile b/sunrpc/Makefile
index 2dac9937f3..c96fe4fa64 100644
--- a/sunrpc/Makefile
+++ b/sunrpc/Makefile
@@ -109,6 +109,10 @@ CFLAGS-xnfs_prot.c = -Wno-unused
CFLAGS-xrquota.c = -Wno-unused
CFLAGS-xkey_prot.c = -Wno-unused
+ifeq (yes,$(have_doors))
+CPPFLAGS-key_call.c += -DHAVE_DOORS=1
+endif
+
include ../Rules
$(objpfx)rpcgen: $(addprefix $(objpfx),$(rpcgen-objs)) \
diff --git a/sunrpc/clnt_unix.c b/sunrpc/clnt_unix.c
index 64b9ca9731..ad12d5fa89 100644
--- a/sunrpc/clnt_unix.c
+++ b/sunrpc/clnt_unix.c
@@ -458,7 +458,10 @@ __msgread (int sock, void *buf, size_t cnt)
msg.msg_controllen = sizeof(struct cmessage);
msg.msg_flags = 0;
- setsockopt (sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof (on));
+#ifdef SO_PASSCRED
+ if (setsockopt (sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof (on)))
+ return -1;
+#endif
return recvmsg (sock, &msg, 0);
}
diff --git a/sunrpc/key_call.c b/sunrpc/key_call.c
index 0219eaf5ad..0aa49cc78a 100644
--- a/sunrpc/key_call.c
+++ b/sunrpc/key_call.c
@@ -32,8 +32,8 @@
/*
* The original source is from the RPCSRC 4.0 package from Sun Microsystems.
- * The Interface to keyserver protocoll 2 was added by
- * Thorsten Kukuk <kukuk@vt.uni-paderborn.de>
+ * The Interface to keyserver protocoll 2, RPC over AF_UNIX und Linux/doors
+ * was added by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>
*/
#include <stdio.h>
@@ -50,6 +50,10 @@
#include <rpc/key_prot.h>
#include <bits/libc-lock.h>
+#ifdef HAVE_DOORS
+# include "door/door.h"
+#endif
+
#define KEY_TIMEOUT 5 /* per-try timeout in seconds */
#define KEY_NRETRY 12 /* number of retries */
@@ -479,13 +483,82 @@ key_call_socket (u_long proc, xdrproc_t xdr_arg, char *arg,
return result;
}
-/* returns 0 on failure, 1 on success */
+#ifdef HAVE_DOORS
+/* returns 0 on failure, 1 on success */
+static int
+internal_function
+key_call_door (u_long proc, xdrproc_t xdr_arg, char *arg,
+ xdrproc_t xdr_rslt, char *rslt)
+{
+ XDR xdrs;
+ int fd;
+ door_arg_t args;
+ char *data_ptr;
+ u_long data_len = 0;
+ char res[255];
+
+ if ((fd = open("/var/run/keyservdoor", O_RDONLY)) < 0)
+ return 0;
+ res[0] = 0;
+
+ data_len = xdr_sizeof (xdr_arg, arg);
+ data_ptr = calloc (1, data_len + 2 * sizeof (u_long));
+ if (data_ptr == NULL)
+ return 0;
+
+ xdrmem_create (&xdrs, &data_ptr[2 * sizeof (u_long)], data_len, XDR_ENCODE);
+ if (!xdr_arg (&xdrs, arg))
+ {
+ xdr_destroy (&xdrs);
+ free (data_ptr);
+ return 0;
+ }
+ xdr_destroy (&xdrs);
+
+ memcpy (data_ptr, &proc, sizeof (u_long));
+ memcpy (&data_ptr[sizeof (proc)], &data_len, sizeof (u_long));
+
+ args.data_ptr = data_ptr;
+ args.data_size = data_len + 2 * sizeof (u_long);
+ args.desc_ptr = NULL;
+ args.desc_num = 0;
+ args.rbuf = res;
+ args.rsize = sizeof (res);
+
+ if (__door_call (fd, &args) < 0)
+ return 0;
+
+ free (data_ptr);
+ close (fd);
+
+ memcpy (&data_len, args.data_ptr, sizeof (u_long));
+ if (data_len != 0)
+ return 0;
+
+ memcpy (&data_len, &args.data_ptr[sizeof (u_long)], sizeof (u_long));
+ xdrmem_create (&xdrs, &args.data_ptr[2 * sizeof (u_long)],
+ data_len, XDR_DECODE);
+ if (!xdr_rslt (&xdrs, rslt))
+ {
+ xdr_destroy (&xdrs);
+ return 0;
+ }
+ xdr_destroy (&xdrs);
+
+ return 1;
+}
+#endif
+
+/* returns 0 on failure, 1 on success */
static int
internal_function
key_call (u_long proc, xdrproc_t xdr_arg, char *arg,
xdrproc_t xdr_rslt, char *rslt)
{
static int use_keyenvoy = 0;
+#ifdef HAVE_DOORS
+ static int use_doors = 1;
+#endif
if (proc == KEY_ENCRYPT_PK && __key_encryptsession_pk_LOCAL)
{
@@ -509,6 +582,14 @@ key_call (u_long proc, xdrproc_t xdr_arg, char *arg,
return 1;
}
+#ifdef HAVE_DOORS
+ if (use_doors)
+ {
+ if (key_call_door (proc, xdr_arg, arg, xdr_rslt, rslt))
+ return 1;
+ use_doors = 0;
+ }
+#endif
if (!use_keyenvoy)
{
if (key_call_socket (proc, xdr_arg, arg, xdr_rslt, rslt))
diff --git a/sunrpc/svc_unix.c b/sunrpc/svc_unix.c
index a8ed53463e..c42d30ed83 100644
--- a/sunrpc/svc_unix.c
+++ b/sunrpc/svc_unix.c
@@ -307,7 +307,10 @@ __msgread (int sock, void *buf, size_t cnt)
msg.msg_controllen = sizeof (struct cmessage);
msg.msg_flags = 0;
- setsockopt (sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof (on));
+#ifdef SO_PASSCRED
+ if (setsockopt (sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof (on)))
+ return -1;
+#endif
return recvmsg (sock, &msg, 0);
}
diff --git a/sysdeps/generic/getpgid.c b/sysdeps/generic/getpgid.c
index 7423e118f0..7ae21515b9 100644
--- a/sysdeps/generic/getpgid.c
+++ b/sysdeps/generic/getpgid.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1995, 1996, 1997, 1998 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
@@ -20,7 +20,7 @@
#include <sys/types.h>
/* Get the process group ID of process PID. */
-int
+pid_t
__getpgid (pid)
pid_t pid;
{
diff --git a/sysdeps/generic/glob.c b/sysdeps/generic/glob.c
index bd92d68324..5fc094ebe7 100644
--- a/sysdeps/generic/glob.c
+++ b/sysdeps/generic/glob.c
@@ -511,7 +511,7 @@ glob (pattern, flags, errfunc, pglob)
case is nothing but a notation for a directory. */
if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && pattern[0] == '~')
{
- dirname = (char *) pattern;
+ dirname = pattern;
dirlen = strlen (pattern);
/* Set FILENAME to NULL as a special flag. This is ugly but
diff --git a/sysdeps/generic/tempname.c b/sysdeps/generic/tempname.c
index f5d1ed0345..c17d86967d 100644
--- a/sysdeps/generic/tempname.c
+++ b/sysdeps/generic/tempname.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 93, 95, 96, 97 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 93, 95, 96, 97, 98 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,31 +16,39 @@
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-#include <errno.h>
+#define __need_size_t
+#include <stddef.h>
#include <stdio.h>
+#include <errno.h>
-/* Generate a (hopefully) unique temporary filename
- in DIR (if applicable), using prefix PFX.
- If DIR_SEARCH is nonzero, perform directory searching
- malarkey as per the SVID for tempnam.
- Return the generated filename or NULL if one could not
- be generated, putting the length of the string in *LENPTR. */
-char *
-__stdio_gen_tempname (buf, bufsize, dir, pfx, dir_search, lenptr, streamptr,
- large_file)
- char *buf;
- size_t bufsize;
+/* Perform the "SVID path search malarkey" on DIR and PFX. Write a
+ template suitable for use in __gen_tempname into TMPL, bounded
+ by TMPL_LEN. */
+int
+__path_search (tmpl, tmpl_len, dir, pfx)
+ char *tmpl;
+ size_t tmpl_len;
const char *dir;
const char *pfx;
- int dir_search;
- size_t *lenptr;
- FILE **streamptr;
+{
+ __set_errno (ENOSYS);
+ return -1;
+}
+stub_warning (__path_search)
+
+/* Generate a (hopefully) unique temporary filename
+ in DIR (if applicable), using template TMPL.
+ If OPENIT is 1, open the file and return a fd. If LARGEFILE is 1,
+ use open64() to do that. */
+ int
+ __gen_tempname (tmpl, openit, largefile)
+ char *tmpl;
+ int openit;
int large_file;
{
- *lenptr = 0;
__set_errno (ENOSYS);
- return NULL;
+ return -1;
}
-stub_warning (__stdio_gen_tempname)
+stub_warning (__gen_tempname)
#include <stub-tag.h>
diff --git a/sysdeps/posix/mkstemp.c b/sysdeps/posix/mkstemp.c
deleted file mode 100644
index d380935c42..0000000000
--- a/sysdeps/posix/mkstemp.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/* Copyright (C) 1991, 1992, 1996, 1998 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 Library General Public License as
- published by the Free Software Foundation; either version 2 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <sys/time.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.
- Returns a file descriptor open on the file for reading and writing. */
-int
-mkstemp (template)
- char *template;
-{
- static const char letters[62]
- = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
- static uint64_t value;
- struct timeval tv;
- char *XXXXXX;
- size_t len;
- int count;
-
- len = strlen (template);
- if (len < 6 || strcmp (&template[len - 6], "XXXXXX"))
- {
- __set_errno (EINVAL);
- return -1;
- }
-
- /* This is where the Xs start. */
- XXXXXX = &template[len - 6];
-
- /* Get some more or less random data. */
- __gettimeofday (&tv, NULL);
- value += ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ __getpid ();
-
- for (count = 0; count < TMP_MAX; ++count)
- {
- uint64_t v = value;
- int fd;
-
- /* Fill in the random bits. */
- XXXXXX[0] = letters[v % 62];
- v /= 62;
- XXXXXX[1] = letters[v % 62];
- v /= 62;
- XXXXXX[2] = letters[v % 62];
- v /= 62;
- XXXXXX[3] = letters[v % 62];
- v /= 62;
- XXXXXX[4] = letters[v % 62];
- v /= 62;
- XXXXXX[5] = letters[v % 62];
-
- fd = __open (template, O_RDWR|O_CREAT|O_EXCL, 0600);
- if (fd >= 0)
- /* The file does not exist. */
- return fd;
-
- /* This is a random value. It is only necessary that the next
- TMP_MAX values generated by adding 7777 to VALUE are different
- with (module 2^32). */
- value += 7777;
- }
-
- /* We return the null string if we can't find a unique file name. */
- template[0] = '\0';
- return -1;
-}
diff --git a/sysdeps/posix/mktemp.c b/sysdeps/posix/mktemp.c
deleted file mode 100644
index e9a576c16f..0000000000
--- a/sysdeps/posix/mktemp.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/* Copyright (C) 1991, 1992, 1993, 1996, 1998 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 Library General Public License as
- published by the Free Software Foundation; either version 2 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the GNU C Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-#include <errno.h>
-#include <stdint.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/types.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. */
-char *
-mktemp (template)
- char *template;
-{
- static const char letters[]
- = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
- static uint64_t value;
- struct timeval tv;
- char *XXXXXX;
- size_t len;
- int count;
-
- len = strlen (template);
- if (len < 6 || strcmp (&template[len - 6], "XXXXXX"))
- {
- __set_errno (EINVAL);
- return NULL;
- }
-
- /* This is where the Xs start. */
- XXXXXX = &template[len - 6];
-
- /* Get some more or less random data. */
- __gettimeofday (&tv, NULL);
- value += ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ __getpid ();
-
- for (count = 0; count < TMP_MAX; ++count)
- {
- struct stat ignored;
- uint64_t v = value;
-
- /* Fill in the random bits. */
- XXXXXX[0] = letters[v % 62];
- v /= 62;
- XXXXXX[1] = letters[v % 62];
- v /= 62;
- XXXXXX[2] = letters[v % 62];
- v /= 62;
- XXXXXX[3] = letters[v % 62];
- v /= 62;
- XXXXXX[4] = letters[v % 62];
- v /= 62;
- XXXXXX[5] = letters[v % 62];
-
- if (stat (template, &ignored) < 0 && errno == ENOENT)
- /* The file does not exist. So return this name. */
- return template;
-
- /* This is a random value. It is only necessary that the next
- TMP_MAX values generated by adding 7777 to VALUE are different
- with (module 2^32). */
- value += 7777;
- }
-
- /* We return the null string if we can't find a unique file name. */
- template[0] = '\0';
- return template;
-}
diff --git a/sysdeps/posix/tempname.c b/sysdeps/posix/tempname.c
index 82e0243132..6dd893e613 100644
--- a/sysdeps/posix/tempname.c
+++ b/sysdeps/posix/tempname.c
@@ -28,119 +28,99 @@
#include <unistd.h>
#include <sys/time.h>
-#ifdef USE_IN_LIBIO
-# include "libioP.h"
-# include <libio.h>
-#endif
-
/* Return nonzero if DIR is an existent directory. */
static int
-diraccess (const char *dir)
+direxists (const char *dir)
{
struct stat buf;
return __stat (dir, &buf) == 0 && S_ISDIR (buf.st_mode);
}
-/* Return nonzero if FILE exists. */
-static int
-exists (const char *file)
+/* Path search algorithm, for tmpnam, tmpfile, etc. If DIR is
+ non-null and exists, uses it; otherwise uses the first of $TMPDIR,
+ P_tmpdir, /tmp that exists. Copies into TMPL a template suitable
+ for use with mk[s]temp. Will fail (-1) if DIR is non-null and
+ doesn't exist, none of the searched dirs exists, or there's not
+ enough space in TMPL. */
+int
+__path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx)
{
- /* We can stat the file even if we can't read its data. */
- struct stat st;
- int save = errno;
- if (__stat (file, &st) == 0)
- return 1;
+ const char *d;
+ size_t dlen, plen;
+
+ if (!pfx || !pfx[0])
+ {
+ pfx = "file";
+ plen = 4;
+ }
else
{
- /* We report that the file exists if stat failed for a reason other
- than nonexistence. In this case, it may or may not exist, and we
- don't know; but reporting that it does exist will never cause any
- trouble, while reporting that it doesn't exist when it does would
- violate the interface of __stdio_gen_tempname. */
- int exists = errno != ENOENT;
- __set_errno (save);
- return exists;
+ plen = strlen (pfx);
+ if (plen > 5)
+ plen = 5;
}
-}
-
-/* These are the characters used in temporary filenames. */
-static const char letters[] =
- "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
-
-/* Generate a temporary filename and return it (in a static buffer). If
- STREAMPTR is not NULL, open a stream "w+b" on the file and set
- *STREAMPTR to it. If DIR_SEARCH is nonzero, DIR and PFX are used as
- described for tempnam. If not, a temporary filename in P_tmpdir with no
- special prefix is generated. If LENPTR is not NULL, *LENPTR is set the
- to length (including the terminating '\0') of the resultant filename,
- which is returned. This goes through a cyclic pattern of all possible
- filenames consisting of five decimal digits of the current pid and three
- of the characters in `letters'. Data for tempnam and tmpnam is kept
- separate, but when tempnam is using P_tmpdir and no prefix (i.e, it is
- identical to tmpnam), the same data is used. Each potential filename is
- tested for an already-existing file of the same name, and no name of an
- existing file will be returned. When the cycle reaches its end
- (12345ZZZ), NULL is returned. */
-char *
-__stdio_gen_tempname (char *buf, size_t bufsize, const char *dir,
- const char *pfx, int dir_search, size_t *lenptr,
- FILE **streamptr, int large_file)
-{
- int saverrno = errno;
- static const char tmpdir[] = P_tmpdir;
- size_t plen, dlen, len;
- char *XXXXXX;
- static uint64_t value;
- struct timeval tv;
- int count;
-
- if (dir_search)
+ d = __secure_getenv ("TMPDIR");
+ if (d != NULL && direxists (d))
+ dir = d;
+ else if (dir != NULL && direxists (dir))
+ /* nothing */ ;
+ else if (direxists (P_tmpdir))
+ dir = P_tmpdir;
+ else if (direxists ("/tmp"))
+ dir = "/tmp";
+ else
{
- register const char *d = __secure_getenv ("TMPDIR");
- if (d != NULL && !diraccess (d))
- d = NULL;
- if (d == NULL && dir != NULL && diraccess (dir))
- d = dir;
- if (d == NULL && diraccess (tmpdir))
- d = tmpdir;
- if (d == NULL && diraccess ("/tmp"))
- d = "/tmp";
- if (d == NULL)
- {
- __set_errno (ENOENT);
- return NULL;
- }
- dir = d;
+ __set_errno (ENOENT);
+ return -1;
}
- else
- dir = tmpdir;
dlen = strlen (dir);
-
- /* Remove trailing slashes from the directory name. */
while (dlen > 1 && dir[dlen - 1] == '/')
- --dlen;
+ dlen--; /* remove trailing slashes */
- if (pfx != NULL && *pfx != '\0')
+ /* check we have room for "${dir}/${pfx}XXXXXX\0" */
+ if (tmpl_len < dlen + 1 + plen + 6 + 1)
{
- plen = strlen (pfx);
- if (plen > 5)
- plen = 5;
+ __set_errno (EINVAL);
+ return -1;
}
- else
- plen = 0;
- len = __snprintf (buf, bufsize, "%.*s/%.*sXXXXXX",
- (int) dlen, dir, (int) plen, pfx);
+ sprintf (tmpl, "%*s/%*sXXXXXX", dlen, dir, plen, pfx);
+ return 0;
+}
+
+/* These are the characters used in temporary filenames. */
+static const char letters[] =
+"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+
+/* Generate a temporary file name based on TMPL. TMPL must match the
+ rules for mk[s]temp (i.e. end in "XXXXXX"). The name constructed
+ does not exist at the time of the call to __gen_tempname. TMPL is
+ overwritten with the result. If OPENIT is nonzero, creates the
+ file and returns a read-write fd; the file is mode 0600 modulo
+ umask. If LARGEFILE is nonzero, uses open64() instead of open().
+
+ We use a clever algorithm to get hard-to-predict names. */
+int
+__gen_tempname (char *tmpl, int openit, int largefile)
+{
+ int len;
+ char *XXXXXX;
+ static uint64_t value;
+ struct timeval tv;
+ int count, fd;
+ int save_errno = errno;
- if (len < dlen + plen + 7)
- {
+ len = strlen (tmpl);
+ if (len < 6 || strcmp (&tmpl[len - 6], "XXXXXX"))
+ {
__set_errno (EINVAL);
- return NULL;
- }
+ return -1;
+ }
- XXXXXX = &buf[dlen + plen + 1];
+ /* This is where the Xs start. */
+ XXXXXX = &tmpl[len - 6];
/* Get some more or less random data. */
__gettimeofday (&tv, NULL);
@@ -163,116 +143,45 @@ __stdio_gen_tempname (char *buf, size_t bufsize, const char *dir,
v /= 62;
XXXXXX[5] = letters[v % 62];
- if (streamptr != NULL)
+ if (openit)
{
- /* Try to create the file atomically. */
-#ifdef _G_OPEN64
- int fd = (large_file
- ? __open (buf, O_RDWR|O_CREAT|O_EXCL, 0666)
- : _G_OPEN64 (buf, O_RDWR|O_CREAT|O_EXCL, 0666));
+ /* XXX Do we want to fail on largefile if 64 bit fileops
+ are not implemented, or just fall back to the old stuff? */
+#ifndef __stub_open64
+ fd = (largefile
+ ? __open (tmpl, O_RDWR | O_CREAT | O_EXCL, 0666)
+ : __open64 (tmpl, O_RDWR | O_CREAT | O_EXCL, 0666));
#else
- int fd = __open (buf, O_RDWR|O_CREAT|O_EXCL, 0666);
+ fd = __open (tmpl, O_RDWR | O_CREAT | O_EXCL, 0666);
#endif
if (fd >= 0)
{
- /* We got a new file that did not previously exist.
- Create a stream for it. */
-#ifdef USE_IN_LIBIO
- int save;
- struct locked_FILE
- {
- struct _IO_FILE_plus fp;
-#ifdef _IO_MTSAFE_IO
- _IO_lock_t lock;
-#endif
- } *new_f;
- struct _IO_FILE_plus *fp;
-
- new_f = (struct locked_FILE *)
- malloc (sizeof (struct locked_FILE));
- if (new_f == NULL)
- {
- /* We lost trying to create a stream (out of memory?).
- Nothing to do but remove the file, close the descriptor,
- and return failure. */
- save = errno;
- lose:
- (void) remove (buf);
- (void) __close (fd);
- __set_errno (save);
- return NULL;
- }
- fp = &new_f->fp;
-#ifdef _IO_MTSAFE_IO
- fp->file._lock = &new_f->lock;
-#endif
- _IO_init (&fp->file, 0);
- _IO_JUMPS (&fp->file) = &_IO_file_jumps;
- _IO_file_init (&fp->file);
-# if !_IO_UNIFIED_JUMPTABLES
- fp->vtable = NULL;
-# endif
- if (_IO_file_attach (&fp->file, fd) == NULL)
- {
- save = errno;
- free (fp);
- goto lose;
- }
- fp->file._flags &= ~_IO_DELETE_DONT_CLOSE;
-
- *streamptr = (FILE *) fp;
-#else
- *streamptr = __newstream ();
- if (*streamptr == NULL)
+ __set_errno (save_errno);
+ return fd;
+ }
+ else if (errno != EEXIST)
+ /* Any other error will apply also to other names we might
+ try, and there are 2^32 or so of them, so give up now. */
+ return -1;
+ }
+ else
+ {
+ struct stat st;
+ if (__stat (tmpl, &st) < 0)
+ {
+ if (errno == ENOENT)
{
- /* We lost trying to create a stream (out of memory?).
- Nothing to do but remove the file, close the descriptor,
- and return failure. */
- const int save = errno;
- (void) remove (buf);
- (void) __close (fd);
- __set_errno (save);
- return NULL;
+ __set_errno (save_errno);
+ return 0;
}
- (*streamptr)->__cookie = (__ptr_t) (long int) fd;
- (*streamptr)->__mode.__write = 1;
- (*streamptr)->__mode.__read = 1;
- (*streamptr)->__mode.__binary = 1;
-#endif
+ else
+ /* Give up now. */
+ return -1;
}
-#if defined EMFILE || defined ENFILE || defined EINTR
- else if (0
-# ifdef EMFILE
- || errno == EMFILE
-# endif
-# ifdef ENFILE
- || errno == ENFILE
-# endif
-# ifdef EINTR
- || errno == EINTR
-# endif
- )
- /* We cannot open anymore files since all descriptors are
- used or because we got a signal. */
- return NULL;
-#endif
- else
- continue;
}
- else if (exists (buf))
- continue;
-
- /* If the file already existed we have continued the loop above,
- so we only get here when we have a winning name to return. */
-
- __set_errno (saverrno);
-
- if (lenptr != NULL)
- *lenptr = len + 1;
- return buf;
}
/* We got out of the loop because we ran out of combinations to try. */
- __set_errno (EEXIST); /* ? */
- return NULL;
+ __set_errno (EEXIST);
+ return -1;
}