mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-29 11:41:21 +03:00
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.
This commit is contained in:
88
ChangeLog
88
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>
|
1998-07-31 17:59 Ulrich Drepper <drepper@cygnus.com>
|
||||||
|
|
||||||
* sysdeps/unix/sysv/linux/Makefile [subdir==misc] (sysdep_routines):
|
* sysdeps/unix/sysv/linux/Makefile [subdir==misc] (sysdep_routines):
|
||||||
|
10
Rules
10
Rules
@ -89,12 +89,14 @@ else
|
|||||||
others: $(addprefix $(objpfx),$(extra-objs))
|
others: $(addprefix $(objpfx),$(extra-objs))
|
||||||
endif
|
endif
|
||||||
ifeq ($(cross-compiling),yes)
|
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
|
else
|
||||||
ifneq (($build-static),yes)
|
|
||||||
tests: $(tests:%=$(objpfx)%.out)
|
tests: $(tests:%=$(objpfx)%.out)
|
||||||
else
|
ifeq ($(build-static),yes)
|
||||||
tests: $(tests:%=$(objpfx)%.out) $(tests-static:%=$(objpfx)%.sout)
|
tests: $(tests-static:%=$(objpfx)%.sout)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -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.
|
This file is part of the GNU C Library.
|
||||||
Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>.
|
Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>.
|
||||||
|
|
||||||
@ -166,15 +166,18 @@ catclose (nl_catd catalog_desc)
|
|||||||
|
|
||||||
catalog = (__nl_catd) catalog_desc;
|
catalog = (__nl_catd) catalog_desc;
|
||||||
|
|
||||||
|
#ifdef _POSIX_MAPPED_FILES
|
||||||
if (catalog->status == mmapped)
|
if (catalog->status == mmapped)
|
||||||
__munmap ((void *) catalog->file_ptr, catalog->file_size);
|
__munmap ((void *) catalog->file_ptr, catalog->file_size);
|
||||||
else if (catalog->status == malloced)
|
else
|
||||||
free ((void *) catalog->file_ptr);
|
#endif /* _POSIX_MAPPED_FILES */
|
||||||
else if (catalog->status != closed && catalog->status != nonexisting)
|
if (catalog->status == malloced)
|
||||||
{
|
free ((void *) catalog->file_ptr);
|
||||||
__set_errno (EBADF);
|
else if (catalog->status != closed && catalog->status != nonexisting)
|
||||||
return -1;
|
{
|
||||||
}
|
__set_errno (EBADF);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if (catalog->nlspath)
|
if (catalog->nlspath)
|
||||||
free ((void *) catalog->nlspath);
|
free ((void *) catalog->nlspath);
|
||||||
|
@ -24,7 +24,9 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/mman.h>
|
#ifdef _POSIX_MAPPED_FILES
|
||||||
|
# include <sys/mman.h>
|
||||||
|
#endif
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "catgetsinfo.h"
|
#include "catgetsinfo.h"
|
||||||
@ -194,19 +196,20 @@ __open_catalog (__nl_catd catalog)
|
|||||||
goto unlock_return;
|
goto unlock_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef MAP_COPY
|
|
||||||
/* Linux seems to lack read-only copy-on-write. */
|
|
||||||
# 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
|
|
||||||
/* Some systems might lack this; they lose. */
|
|
||||||
# define MAP_INHERIT 0
|
|
||||||
#endif
|
|
||||||
catalog->file_size = st.st_size;
|
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
|
||||||
|
/* Some systems do not have this flag; it is superfluous. */
|
||||||
|
# define MAP_FILE 0
|
||||||
|
# endif
|
||||||
|
# ifndef MAP_INHERIT
|
||||||
|
/* Some systems might lack this; they lose. */
|
||||||
|
# define MAP_INHERIT 0
|
||||||
|
# endif
|
||||||
catalog->file_ptr =
|
catalog->file_ptr =
|
||||||
(struct catalog_obj *) __mmap (NULL, st.st_size, PROT_READ,
|
(struct catalog_obj *) __mmap (NULL, st.st_size, PROT_READ,
|
||||||
MAP_FILE|MAP_COPY|MAP_INHERIT, fd, 0);
|
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. */
|
/* Tell the world we managed to mmap the file. */
|
||||||
catalog->status = mmapped;
|
catalog->status = mmapped;
|
||||||
else
|
else
|
||||||
|
#endif /* _POSIX_MAPPED_FILES */
|
||||||
{
|
{
|
||||||
/* mmap failed perhaps because the system call is not
|
/* mmap failed perhaps because the system call is not
|
||||||
implemented. Try to load the file. */
|
implemented. Try to load the file. */
|
||||||
@ -258,9 +262,11 @@ __open_catalog (__nl_catd catalog)
|
|||||||
invalid_file:
|
invalid_file:
|
||||||
/* Invalid file. Free the resources and mark catalog as not
|
/* Invalid file. Free the resources and mark catalog as not
|
||||||
usable. */
|
usable. */
|
||||||
|
#ifdef _POSIX_MAPPED_FILES
|
||||||
if (catalog->status == mmapped)
|
if (catalog->status == mmapped)
|
||||||
__munmap ((void *) catalog->file_ptr, catalog->file_size);
|
__munmap ((void *) catalog->file_ptr, catalog->file_size);
|
||||||
else
|
else
|
||||||
|
#endif /* _POSIX_MAPPED_FILES */
|
||||||
free (catalog->file_ptr);
|
free (catalog->file_ptr);
|
||||||
catalog->status = nonexisting;
|
catalog->status = nonexisting;
|
||||||
goto unlock_return;
|
goto unlock_return;
|
||||||
|
@ -40,6 +40,7 @@ old-glibc-headers = @old_glibc_headers@
|
|||||||
versioning = @VERSIONING@
|
versioning = @VERSIONING@
|
||||||
no-whole-archive = @no_whole_archive@
|
no-whole-archive = @no_whole_archive@
|
||||||
exceptions = @exceptions@
|
exceptions = @exceptions@
|
||||||
|
have_doors = @linux_doors@
|
||||||
|
|
||||||
have-bash2 = @libc_cv_have_bash2@
|
have-bash2 = @libc_cv_have_bash2@
|
||||||
have-ksh = @libc_cv_have_ksh@
|
have-ksh = @libc_cv_have_ksh@
|
||||||
|
7
configure
vendored
7
configure
vendored
@ -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
|
if test "`(cd $srcdir; pwd)`" = "`pwd`"; then
|
||||||
config_makefile=
|
config_makefile=
|
||||||
else
|
else
|
||||||
@ -3083,6 +3089,7 @@ s%@bounded@%$bounded%g
|
|||||||
s%@static_nss@%$static_nss%g
|
s%@static_nss@%$static_nss%g
|
||||||
s%@nopic_initfini@%$nopic_initfini%g
|
s%@nopic_initfini@%$nopic_initfini%g
|
||||||
s%@DEFINES@%$DEFINES%g
|
s%@DEFINES@%$DEFINES%g
|
||||||
|
s%@linux_doors@%$linux_doors%g
|
||||||
s%@VERSION@%$VERSION%g
|
s%@VERSION@%$VERSION%g
|
||||||
s%@RELEASE@%$RELEASE%g
|
s%@RELEASE@%$RELEASE%g
|
||||||
|
|
||||||
|
@ -1168,6 +1168,12 @@ AC_SUBST(nopic_initfini)
|
|||||||
|
|
||||||
AC_SUBST(DEFINES)
|
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
|
if test "`(cd $srcdir; pwd)`" = "`pwd`"; then
|
||||||
config_makefile=
|
config_makefile=
|
||||||
else
|
else
|
||||||
|
@ -1170,7 +1170,7 @@ typedef struct
|
|||||||
#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */
|
#define DT_MIPS_AUX_DYNAMIC 0x70000031 /* Address of aux .dynamic. */
|
||||||
#define DT_MIPS_NUM 0x32
|
#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_NONE 0 /* No flags */
|
||||||
#define RHF_QUICKSTART (1 << 0) /* Use quickstart */
|
#define RHF_QUICKSTART (1 << 0) /* Use quickstart */
|
||||||
|
@ -30,7 +30,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/mman.h>
|
#ifdef _POSIX_MAPPED_FILES
|
||||||
|
# include <sys/mman.h>
|
||||||
|
#endif
|
||||||
#include <gconv_int.h>
|
#include <gconv_int.h>
|
||||||
|
|
||||||
/* Get libc version number. */
|
/* Get libc version number. */
|
||||||
@ -176,6 +178,7 @@ main (int argc, char *argv[])
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _POSIX_MAPPED_FILES
|
||||||
/* We have possibilities for reading the input file. First try
|
/* We have possibilities for reading the input file. First try
|
||||||
to mmap() it since this will provide the fastest solution. */
|
to mmap() it since this will provide the fastest solution. */
|
||||||
if (fstat (fd, &st) == 0
|
if (fstat (fd, &st) == 0
|
||||||
@ -206,6 +209,7 @@ main (int argc, char *argv[])
|
|||||||
munmap ((void *) addr, st.st_size);
|
munmap ((void *) addr, st.st_size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif /* _POSIX_MAPPED_FILES */
|
||||||
{
|
{
|
||||||
/* Read the file in pieces. */
|
/* Read the file in pieces. */
|
||||||
if (process_fd (cd, fd, output) != 0)
|
if (process_fd (cd, fd, output) != 0)
|
||||||
|
1
include/bits/cmathcalls.h
Normal file
1
include/bits/cmathcalls.h
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include <math/bits/cmathcalls.h>
|
1
include/complex.h
Normal file
1
include/complex.h
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include <math/complex.h>
|
1
include/execinfo.h
Normal file
1
include/execinfo.h
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include <debug/execinfo.h>
|
1
include/fenv.h
Normal file
1
include/fenv.h
Normal file
@ -0,0 +1 @@
|
|||||||
|
#include <math/fenv.h>
|
@ -118,7 +118,7 @@ struct in_addr
|
|||||||
#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET)
|
#define IN_CLASSB_HOST (0xffffffff & ~IN_CLASSB_NET)
|
||||||
#define IN_CLASSB_MAX 65536
|
#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_NET 0xffffff00
|
||||||
#define IN_CLASSC_NSHIFT 8
|
#define IN_CLASSC_NSHIFT 8
|
||||||
#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET)
|
#define IN_CLASSC_HOST (0xffffffff & ~IN_CLASSC_NET)
|
||||||
|
@ -35,8 +35,13 @@
|
|||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#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>
|
# include <sys/mman.h>
|
||||||
|
# undef HAVE_MMAP
|
||||||
|
# define HAVE_MMAP 1
|
||||||
|
#else
|
||||||
|
# undef HAVE_MMAP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
@ -72,10 +77,7 @@ _nl_load_domain (domain_file)
|
|||||||
size_t size;
|
size_t size;
|
||||||
struct stat st;
|
struct stat st;
|
||||||
struct mo_file_header *data = (struct mo_file_header *) -1;
|
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;
|
int use_mmap = 0;
|
||||||
#endif
|
|
||||||
struct loaded_domain *domain;
|
struct loaded_domain *domain;
|
||||||
|
|
||||||
domain_file->decided = 1;
|
domain_file->decided = 1;
|
||||||
@ -103,8 +105,7 @@ _nl_load_domain (domain_file)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \
|
#ifdef HAVE_MMAP
|
||||||
|| defined _LIBC
|
|
||||||
/* Now we are ready to load the file. If mmap() is available we try
|
/* 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. */
|
this first. If not available or it failed we try to load it. */
|
||||||
data = (struct mo_file_header *) mmap (NULL, size, PROT_READ,
|
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)
|
if (data->magic != _MAGIC && data->magic != _MAGIC_SWAPPED)
|
||||||
{
|
{
|
||||||
/* The magic number is wrong: not a message catalog file. */
|
/* The magic number is wrong: not a message catalog file. */
|
||||||
#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \
|
#ifdef HAVE_MMAP
|
||||||
|| defined _LIBC
|
|
||||||
if (use_mmap)
|
if (use_mmap)
|
||||||
munmap ((caddr_t) data, size);
|
munmap ((caddr_t) data, size);
|
||||||
else
|
else
|
||||||
@ -188,9 +188,8 @@ _nl_load_domain (domain_file)
|
|||||||
((char *) data + W (domain->must_swap, data->hash_tab_offset));
|
((char *) data + W (domain->must_swap, data->hash_tab_offset));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* This is an illegal revision. */
|
/* This is an invalid revision. */
|
||||||
#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \
|
#ifdef HAVE_MMAP
|
||||||
|| defined _LIBC
|
|
||||||
if (use_mmap)
|
if (use_mmap)
|
||||||
munmap ((caddr_t) data, size);
|
munmap ((caddr_t) data, size);
|
||||||
else
|
else
|
||||||
@ -213,9 +212,11 @@ internal_function
|
|||||||
_nl_unload_domain (domain)
|
_nl_unload_domain (domain)
|
||||||
struct loaded_domain *domain;
|
struct loaded_domain *domain;
|
||||||
{
|
{
|
||||||
|
#ifdef _POSIX_MAPPED_FILES
|
||||||
if (domain->use_mmap)
|
if (domain->use_mmap)
|
||||||
munmap ((caddr_t) domain->data, domain->mmap_size);
|
munmap ((caddr_t) domain->data, domain->mmap_size);
|
||||||
else
|
else
|
||||||
|
#endif /* _POSIX_MAPPED_FILES */
|
||||||
free ((void *) domain->data);
|
free ((void *) domain->data);
|
||||||
|
|
||||||
free (domain);
|
free (domain);
|
||||||
|
@ -72,15 +72,12 @@ typedef _G_fpos64_t fpos_t;
|
|||||||
typedef _G_fpos64_t fpos64_t;
|
typedef _G_fpos64_t fpos64_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Generate a unique file name (and possibly open it with mode "w+b"). */
|
/* Generate a unique file name (and possibly open it). */
|
||||||
extern char *__stdio_gen_tempname __P ((char *__buf, size_t __bufsize,
|
extern int __path_search __P ((char *__tmpl, size_t __tmpl_len,
|
||||||
__const char *__dir,
|
__const char *__dir,
|
||||||
__const char *__pfx,
|
__const char *__pfx));
|
||||||
int __dir_search,
|
|
||||||
size_t *__lenptr,
|
|
||||||
FILE **__streamptr,
|
|
||||||
int __large_file));
|
|
||||||
|
|
||||||
|
extern int __gen_tempname __P ((char *__tmpl, int __openit, int __large_file));
|
||||||
|
|
||||||
/* Print out MESSAGE on the error output and abort. */
|
/* Print out MESSAGE on the error output and abort. */
|
||||||
extern void __libc_fatal __P ((__const char *__message))
|
extern void __libc_fatal __P ((__const char *__message))
|
||||||
|
@ -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>
|
1998-07-29 Xavier Leroy <Xavier.Leroy@inria.fr>
|
||||||
|
|
||||||
* Banner: Bump version number to 0.8
|
* Banner: Bump version number to 0.8
|
||||||
|
@ -21,7 +21,8 @@
|
|||||||
#
|
#
|
||||||
subdir := linuxthreads
|
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
|
headers := pthread.h semaphore.h bits/semaphore.h
|
||||||
distribute := internals.h queue.h restart.h spinlock.h
|
distribute := internals.h queue.h restart.h spinlock.h
|
||||||
|
@ -21,7 +21,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/mman.h>
|
#ifdef _POSIX_MAPPED_FILES
|
||||||
|
# include <sys/mman.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "localeinfo.h"
|
#include "localeinfo.h"
|
||||||
|
|
||||||
@ -211,6 +213,7 @@ _nl_remove_locale (int locale, struct locale_data *data)
|
|||||||
/* Free the name. */
|
/* Free the name. */
|
||||||
free ((char *) data->name);
|
free ((char *) data->name);
|
||||||
|
|
||||||
|
#ifdef _POSIX_MAPPED_FILES
|
||||||
/* Really delete the data. First delete the real data. */
|
/* Really delete the data. First delete the real data. */
|
||||||
if (data->mmaped)
|
if (data->mmaped)
|
||||||
{
|
{
|
||||||
@ -223,6 +226,7 @@ _nl_remove_locale (int locale, struct locale_data *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
#endif /* _POSIX_MAPPED_FILES */
|
||||||
/* The memory was malloced. */
|
/* The memory was malloced. */
|
||||||
free ((void *) data->filedata);
|
free ((void *) data->filedata);
|
||||||
|
|
||||||
|
@ -23,7 +23,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/mman.h>
|
#ifdef _POSIX_MAPPED_FILES
|
||||||
|
# include <sys/mman.h>
|
||||||
|
#endif
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "localeinfo.h"
|
#include "localeinfo.h"
|
||||||
@ -113,24 +115,32 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
|
|||||||
|
|
||||||
/* Map in the file's data. */
|
/* Map in the file's data. */
|
||||||
save_err = errno;
|
save_err = errno;
|
||||||
#ifndef MAP_COPY
|
#ifdef _POSIX_MAPPED_FILES
|
||||||
|
# ifndef MAP_COPY
|
||||||
/* Linux seems to lack read-only copy-on-write. */
|
/* Linux seems to lack read-only copy-on-write. */
|
||||||
#define MAP_COPY MAP_PRIVATE
|
# define MAP_COPY MAP_PRIVATE
|
||||||
#endif
|
# endif
|
||||||
#ifndef MAP_FILE
|
# ifndef MAP_FILE
|
||||||
/* Some systems do not have this flag; it is superfluous. */
|
/* Some systems do not have this flag; it is superfluous. */
|
||||||
#define MAP_FILE 0
|
# define MAP_FILE 0
|
||||||
#endif
|
# endif
|
||||||
#ifndef MAP_INHERIT
|
# ifndef MAP_INHERIT
|
||||||
/* Some systems might lack this; they lose. */
|
/* Some systems might lack this; they lose. */
|
||||||
#define MAP_INHERIT 0
|
# define MAP_INHERIT 0
|
||||||
#endif
|
# endif
|
||||||
filedata = (void *) __mmap ((caddr_t) 0, st.st_size, PROT_READ,
|
filedata = (void *) __mmap ((caddr_t) 0, st.st_size, PROT_READ,
|
||||||
MAP_FILE|MAP_COPY|MAP_INHERIT, fd, 0);
|
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)
|
if (errno == ENOSYS)
|
||||||
{
|
{
|
||||||
|
#endif /* _POSIX_MAPPED_FILES */
|
||||||
/* No mmap; allocate a buffer and read from the file. */
|
/* No mmap; allocate a buffer and read from the file. */
|
||||||
mmaped = 0;
|
mmaped = 0;
|
||||||
filedata = malloc (st.st_size);
|
filedata = malloc (st.st_size);
|
||||||
@ -156,13 +166,12 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
|
|||||||
else
|
else
|
||||||
goto puntfd;
|
goto puntfd;
|
||||||
__set_errno (save_err);
|
__set_errno (save_err);
|
||||||
|
#ifdef _POSIX_MAPPED_FILES
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
goto puntfd;
|
goto puntfd;
|
||||||
}
|
}
|
||||||
else if (st.st_size < sizeof (*filedata))
|
#endif /* _POSIX_MAPPED_FILES */
|
||||||
/* This cannot be a locale data file since it's too small. */
|
|
||||||
goto puntfd;
|
|
||||||
|
|
||||||
if (filedata->magic == LIMAGIC (category))
|
if (filedata->magic == LIMAGIC (category))
|
||||||
/* Good data file in our byte order. */
|
/* 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. */
|
/* Bad data file in either byte order. */
|
||||||
{
|
{
|
||||||
puntmap:
|
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:
|
puntfd:
|
||||||
__close (fd);
|
__close (fd);
|
||||||
return;
|
return;
|
||||||
@ -228,9 +242,11 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
|
|||||||
void
|
void
|
||||||
_nl_unload_locale (struct locale_data *locale)
|
_nl_unload_locale (struct locale_data *locale)
|
||||||
{
|
{
|
||||||
|
#ifdef _POSIX_MAPPED_FILES
|
||||||
if (locale->mmaped)
|
if (locale->mmaped)
|
||||||
__munmap ((caddr_t) locale->filedata, locale->filesize);
|
__munmap ((caddr_t) locale->filedata, locale->filesize);
|
||||||
else
|
else
|
||||||
|
#endif
|
||||||
free ((void *) locale->filedata);
|
free ((void *) locale->filedata);
|
||||||
|
|
||||||
free (locale);
|
free (locale);
|
||||||
|
@ -30,7 +30,9 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/mman.h>
|
#ifdef _POSIX2_LOCALEDEF
|
||||||
|
# include <sys/mman.h>
|
||||||
|
#endif
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
@ -276,10 +278,12 @@ cannot `stat' locale file `%s'"),
|
|||||||
fname);
|
fname);
|
||||||
|
|
||||||
localedef->len[cat] = st.st_size;
|
localedef->len[cat] = st.st_size;
|
||||||
|
#ifdef _POSIX_MAPPED_FILES
|
||||||
localedef->categories[cat].generic
|
localedef->categories[cat].generic
|
||||||
= mmap (NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
= mmap (NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||||
|
|
||||||
if (localedef->categories[cat].generic == MAP_FAILED)
|
if (localedef->categories[cat].generic == MAP_FAILED)
|
||||||
|
#endif /* _POSIX_MAPPED_FILES */
|
||||||
{
|
{
|
||||||
size_t left = st.st_size;
|
size_t left = st.st_size;
|
||||||
void *read_ptr;
|
void *read_ptr;
|
||||||
|
@ -493,6 +493,10 @@ do { \
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef LACKS_UNISTD_H
|
||||||
|
# include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Define HAVE_MMAP to optionally make malloc() use mmap() to
|
Define HAVE_MMAP to optionally make malloc() use mmap() to
|
||||||
allocate very large blocks. These will be returned to the
|
allocate very large blocks. These will be returned to the
|
||||||
@ -500,7 +504,9 @@ do { \
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef HAVE_MMAP
|
#ifndef HAVE_MMAP
|
||||||
#define HAVE_MMAP 1
|
# ifdef _POSIX_MAPPED_FILES
|
||||||
|
# define HAVE_MMAP 1
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -541,10 +547,6 @@ do { \
|
|||||||
bsd/gnu getpagesize.h
|
bsd/gnu getpagesize.h
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef LACKS_UNISTD_H
|
|
||||||
# include <unistd.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef malloc_getpagesize
|
#ifndef malloc_getpagesize
|
||||||
# ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */
|
# ifdef _SC_PAGESIZE /* some SVR4 systems omit an underscore */
|
||||||
# ifndef _SC_PAGE_SIZE
|
# ifndef _SC_PAGE_SIZE
|
||||||
|
@ -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.
|
# 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
|
$(objpfx)libieee.a: $(objpfx)ieee-math.o
|
||||||
rm -f $@
|
rm -f $@
|
||||||
ln $< $@
|
$(LN_S) $< $@
|
||||||
|
|
||||||
ifeq ($(build-shared),yes)
|
ifeq ($(build-shared),yes)
|
||||||
$(addprefix $(objpfx),$(tests)): $(objpfx)libm.so$(libm.so-version)
|
$(addprefix $(objpfx),$(tests)): $(objpfx)libm.so$(libm.so-version)
|
||||||
|
@ -57,6 +57,9 @@ routines := brk sbrk sstk ioctl \
|
|||||||
hsearch hsearch_r tsearch lsearch \
|
hsearch hsearch_r tsearch lsearch \
|
||||||
err error ustat \
|
err error ustat \
|
||||||
getsysstats dirname regexp
|
getsysstats dirname regexp
|
||||||
|
|
||||||
|
include ../Makeconfig
|
||||||
|
|
||||||
aux := init-misc
|
aux := init-misc
|
||||||
ifeq ($(build-static),yes)
|
ifeq ($(build-static),yes)
|
||||||
install-lib := libbsd-compat.a libg.a
|
install-lib := libbsd-compat.a libg.a
|
||||||
|
@ -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.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
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,
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Boston, MA 02111-1307, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
/* Generate a unique temporary file name from TEMPLATE.
|
/* Generate a unique temporary file name from TEMPLATE.
|
||||||
The last six characters of TEMPLATE must be "XXXXXX";
|
The last six characters of TEMPLATE must be "XXXXXX";
|
||||||
they are replaced with a string that makes the filename unique.
|
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
|
int
|
||||||
mkstemp (template)
|
mkstemp (template)
|
||||||
char *template;
|
char *template;
|
||||||
{
|
{
|
||||||
if (strcmp (&template[strlen (template) - 6], "XXXXXX"))
|
return __gen_tempname (template, 1, 0);
|
||||||
{
|
|
||||||
__set_errno (EINVAL);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
__set_errno (ENOSYS);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stub_warning (mkstemp)
|
|
||||||
#include <stub-tag.h>
|
|
@ -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.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
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,
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Boston, MA 02111-1307, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
/* Generate a unique temporary file name from TEMPLATE.
|
/* Generate a unique temporary file name from TEMPLATE.
|
||||||
The last six characters of TEMPLATE must be "XXXXXX";
|
The last six characters of TEMPLATE must be "XXXXXX";
|
||||||
@ -27,15 +27,9 @@ char *
|
|||||||
mktemp (template)
|
mktemp (template)
|
||||||
char *template;
|
char *template;
|
||||||
{
|
{
|
||||||
if (strcmp (&template[strlen (template) - 6], "XXXXXX"))
|
if (__gen_tempname (template, 0, 0) < 0)
|
||||||
{
|
/* We return the null string if we can't find a unique file name. */
|
||||||
__set_errno (EINVAL);
|
template[0] = '\0';
|
||||||
return template;
|
|
||||||
}
|
|
||||||
|
|
||||||
__set_errno (ENOSYS);
|
return template;
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stub_warning (mktemp)
|
|
||||||
#include <stub-tag.h>
|
|
@ -52,6 +52,8 @@ routines := \
|
|||||||
getaddrinfo gai_strerror wordexp \
|
getaddrinfo gai_strerror wordexp \
|
||||||
pread pwrite pread64 pwrite64
|
pread pwrite pread64 pwrite64
|
||||||
|
|
||||||
|
include ../Makeconfig
|
||||||
|
|
||||||
aux := init-posix environ
|
aux := init-posix environ
|
||||||
tests := tstgetopt testfnm runtests wordexp-test runptests
|
tests := tstgetopt testfnm runtests wordexp-test runptests
|
||||||
test-srcs := globtest
|
test-srcs := globtest
|
||||||
|
@ -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
|
/* If the search isn't to be a backwards one, don't waste time in a
|
||||||
search for a pattern that must be anchored. */
|
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)
|
if (startpos > 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -5737,7 +5741,7 @@ weak_alias (__regexec, regexec)
|
|||||||
from either regcomp or regexec. We don't use PREG here. */
|
from either regcomp or regexec. We don't use PREG here. */
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
__regerror (errcode, preg, errbuf, errbuf_size)
|
regerror (errcode, preg, errbuf, errbuf_size)
|
||||||
int errcode;
|
int errcode;
|
||||||
const regex_t *preg;
|
const regex_t *preg;
|
||||||
char *errbuf;
|
char *errbuf;
|
||||||
|
@ -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.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
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,
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Boston, MA 02111-1307, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
/* Generate a unique temporary filename using up to five characters of PFX
|
/* 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
|
if it is not NULL. The directory to put this file in is searched for
|
||||||
as follows: First the environment variable "TMPDIR" is checked.
|
as follows: First the environment variable "TMPDIR" is checked.
|
||||||
@ -34,17 +30,12 @@ char *
|
|||||||
tempnam (const char *dir, const char *pfx)
|
tempnam (const char *dir, const char *pfx)
|
||||||
{
|
{
|
||||||
char buf[FILENAME_MAX];
|
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;
|
return NULL;
|
||||||
|
|
||||||
s = (char *) malloc (len);
|
if (__gen_tempname (buf, 0, 0))
|
||||||
if (s == NULL)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return (char *) memcpy (s, t, len);
|
return strdup (buf);
|
||||||
}
|
}
|
||||||
|
@ -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.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -18,6 +18,9 @@
|
|||||||
|
|
||||||
#include <stdio.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
|
/* This returns a new stream opened on a temporary file (generated
|
||||||
by tmpnam) The file is opened with mode "w+b" (binary read/write).
|
by tmpnam) The file is opened with mode "w+b" (binary read/write).
|
||||||
@ -27,17 +30,20 @@ FILE *
|
|||||||
tmpfile ()
|
tmpfile ()
|
||||||
{
|
{
|
||||||
char buf[FILENAME_MAX];
|
char buf[FILENAME_MAX];
|
||||||
char *filename;
|
int fd;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
filename = __stdio_gen_tempname (buf, sizeof (buf), (char *) NULL, "tmpf", 0,
|
if (__path_search (buf, FILENAME_MAX, NULL, "tmpf"))
|
||||||
(size_t *) NULL, &f, 0);
|
return NULL;
|
||||||
if (filename == NULL)
|
if ((fd = __gen_tempname (buf, 1, 0)) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Note that this relies on the Unix semantics that
|
/* Note that this relies on the Unix semantics that
|
||||||
a file is not really removed until it is closed. */
|
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;
|
return f;
|
||||||
}
|
}
|
||||||
|
@ -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.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -19,6 +19,9 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.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
|
/* This returns a new stream opened on a temporary file (generated
|
||||||
by tmpnam) The file is opened with mode "w+b" (binary read/write).
|
by tmpnam) The file is opened with mode "w+b" (binary read/write).
|
||||||
@ -27,23 +30,21 @@
|
|||||||
FILE *
|
FILE *
|
||||||
tmpfile64 ()
|
tmpfile64 ()
|
||||||
{
|
{
|
||||||
#ifdef _G_OPEN64
|
|
||||||
char buf[FILENAME_MAX];
|
char buf[FILENAME_MAX];
|
||||||
char *filename;
|
int fd;
|
||||||
FILE *f;
|
FILE *f;
|
||||||
|
|
||||||
filename = __stdio_gen_tempname (buf, sizeof (buf), (char *) NULL, "tmpf", 0,
|
if (__path_search (buf, FILENAME_MAX, NULL, "tmpf"))
|
||||||
(size_t *) NULL, &f, 1);
|
return NULL;
|
||||||
if (filename == NULL)
|
if ((fd = __gen_tempname (buf, 1, 1)) < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* Note that this relies on the Unix semantics that
|
/* Note that this relies on the Unix semantics that
|
||||||
a file is not really removed until it is closed. */
|
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;
|
return f;
|
||||||
#else
|
|
||||||
__set_errno (ENOSYS);
|
|
||||||
return NULL;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
|
||||||
/* Generate a unique filename in P_tmpdir.
|
/* Generate a unique filename in P_tmpdir.
|
||||||
|
|
||||||
This function is *not* thread safe! */
|
This function is *not* thread safe! */
|
||||||
@ -30,20 +29,21 @@ tmpnam (char *s)
|
|||||||
where S != NULL. */
|
where S != NULL. */
|
||||||
static char buf[L_tmpnam];
|
static char buf[L_tmpnam];
|
||||||
char tmpbuf[L_tmpnam];
|
char tmpbuf[L_tmpnam];
|
||||||
char *result;
|
|
||||||
|
|
||||||
/* In the following call we use the buffer pointed to by S if
|
/* 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
|
non-NULL although we don't know the size. But we limit the size
|
||||||
to FILENAME_MAX characters in any case. */
|
to L_tmpnam characters in any case. */
|
||||||
result = __stdio_gen_tempname (s ?: tmpbuf, L_tmpnam, (const char *) NULL,
|
if (__path_search (s ? : tmpbuf, L_tmpnam, NULL, NULL))
|
||||||
(const char *) NULL, 0,
|
return NULL;
|
||||||
(size_t *) NULL, (FILE **) NULL, 0);
|
|
||||||
|
|
||||||
if (result != NULL && s == NULL)
|
if (__gen_tempname (s ? : tmpbuf, 0, 0))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (s == NULL)
|
||||||
{
|
{
|
||||||
memcpy (buf, result, L_tmpnam);
|
memcpy (buf, tmpbuf, L_tmpnam);
|
||||||
result = buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
return result;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -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.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -17,8 +17,6 @@
|
|||||||
Boston, MA 02111-1307, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* Generate a unique filename in P_tmpdir. If S is NULL return NULL.
|
/* Generate a unique filename in P_tmpdir. If S is NULL return NULL.
|
||||||
This makes this function thread safe. */
|
This makes this function thread safe. */
|
||||||
@ -28,10 +26,10 @@ tmpnam_r (char *s)
|
|||||||
if (s == NULL)
|
if (s == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
/* In the following call we use the buffer pointed to by S if
|
if (__path_search (s, L_tmpnam, NULL, NULL))
|
||||||
non-NULL although we don't know the size. But we limit the size
|
return NULL;
|
||||||
to L_tmpnam characters in any case. */
|
if (__gen_tempname (s, 0, 0))
|
||||||
return __stdio_gen_tempname (s, L_tmpnam, (const char *) NULL,
|
return NULL;
|
||||||
(const char *) NULL, 0,
|
|
||||||
(size_t *) NULL, (FILE **) NULL, 0);
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -155,14 +155,13 @@ extern int __stdio_open __P ((__const char *__file, __io_mode __m,
|
|||||||
__ptr_t *__cookieptr));
|
__ptr_t *__cookieptr));
|
||||||
/* Put out an error message for when stdio needs to die. */
|
/* Put out an error message for when stdio needs to die. */
|
||||||
extern void __stdio_errmsg __P ((__const char *__msg, size_t __len));
|
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,
|
/* Generate a unique file name (and possibly open it). */
|
||||||
__const char *__dir,
|
extern int __path_search __P ((char *__tmpl, size_t __tmpl_len,
|
||||||
__const char *__pfx,
|
__const char *__dir,
|
||||||
int __dir_search,
|
__const char *__pfx));
|
||||||
size_t *__lenptr,
|
|
||||||
FILE **__streamptr,
|
extern int __gen_tempname __P ((char *__tmpl, int __openit, int __large_file));
|
||||||
int __large_file));
|
|
||||||
|
|
||||||
|
|
||||||
/* Print out MESSAGE on the error output and abort. */
|
/* Print out MESSAGE on the error output and abort. */
|
||||||
|
@ -109,6 +109,10 @@ CFLAGS-xnfs_prot.c = -Wno-unused
|
|||||||
CFLAGS-xrquota.c = -Wno-unused
|
CFLAGS-xrquota.c = -Wno-unused
|
||||||
CFLAGS-xkey_prot.c = -Wno-unused
|
CFLAGS-xkey_prot.c = -Wno-unused
|
||||||
|
|
||||||
|
ifeq (yes,$(have_doors))
|
||||||
|
CPPFLAGS-key_call.c += -DHAVE_DOORS=1
|
||||||
|
endif
|
||||||
|
|
||||||
include ../Rules
|
include ../Rules
|
||||||
|
|
||||||
$(objpfx)rpcgen: $(addprefix $(objpfx),$(rpcgen-objs)) \
|
$(objpfx)rpcgen: $(addprefix $(objpfx),$(rpcgen-objs)) \
|
||||||
|
@ -458,7 +458,10 @@ __msgread (int sock, void *buf, size_t cnt)
|
|||||||
msg.msg_controllen = sizeof(struct cmessage);
|
msg.msg_controllen = sizeof(struct cmessage);
|
||||||
msg.msg_flags = 0;
|
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);
|
return recvmsg (sock, &msg, 0);
|
||||||
}
|
}
|
||||||
|
@ -32,8 +32,8 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* The original source is from the RPCSRC 4.0 package from Sun Microsystems.
|
* The original source is from the RPCSRC 4.0 package from Sun Microsystems.
|
||||||
* The Interface to keyserver protocoll 2 was added by
|
* The Interface to keyserver protocoll 2, RPC over AF_UNIX und Linux/doors
|
||||||
* Thorsten Kukuk <kukuk@vt.uni-paderborn.de>
|
* was added by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@ -50,6 +50,10 @@
|
|||||||
#include <rpc/key_prot.h>
|
#include <rpc/key_prot.h>
|
||||||
#include <bits/libc-lock.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_TIMEOUT 5 /* per-try timeout in seconds */
|
||||||
#define KEY_NRETRY 12 /* number of retries */
|
#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;
|
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
|
static int
|
||||||
internal_function
|
internal_function
|
||||||
key_call (u_long proc, xdrproc_t xdr_arg, char *arg,
|
key_call (u_long proc, xdrproc_t xdr_arg, char *arg,
|
||||||
xdrproc_t xdr_rslt, char *rslt)
|
xdrproc_t xdr_rslt, char *rslt)
|
||||||
{
|
{
|
||||||
static int use_keyenvoy = 0;
|
static int use_keyenvoy = 0;
|
||||||
|
#ifdef HAVE_DOORS
|
||||||
|
static int use_doors = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (proc == KEY_ENCRYPT_PK && __key_encryptsession_pk_LOCAL)
|
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;
|
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 (!use_keyenvoy)
|
||||||
{
|
{
|
||||||
if (key_call_socket (proc, xdr_arg, arg, xdr_rslt, rslt))
|
if (key_call_socket (proc, xdr_arg, arg, xdr_rslt, rslt))
|
||||||
|
@ -307,7 +307,10 @@ __msgread (int sock, void *buf, size_t cnt)
|
|||||||
msg.msg_controllen = sizeof (struct cmessage);
|
msg.msg_controllen = sizeof (struct cmessage);
|
||||||
msg.msg_flags = 0;
|
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);
|
return recvmsg (sock, &msg, 0);
|
||||||
}
|
}
|
||||||
|
@ -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.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -20,7 +20,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
/* Get the process group ID of process PID. */
|
/* Get the process group ID of process PID. */
|
||||||
int
|
pid_t
|
||||||
__getpgid (pid)
|
__getpgid (pid)
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
{
|
{
|
||||||
|
@ -511,7 +511,7 @@ glob (pattern, flags, errfunc, pglob)
|
|||||||
case is nothing but a notation for a directory. */
|
case is nothing but a notation for a directory. */
|
||||||
if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && pattern[0] == '~')
|
if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && pattern[0] == '~')
|
||||||
{
|
{
|
||||||
dirname = (char *) pattern;
|
dirname = pattern;
|
||||||
dirlen = strlen (pattern);
|
dirlen = strlen (pattern);
|
||||||
|
|
||||||
/* Set FILENAME to NULL as a special flag. This is ugly but
|
/* Set FILENAME to NULL as a special flag. This is ugly but
|
||||||
|
@ -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.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
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,
|
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
Boston, MA 02111-1307, USA. */
|
Boston, MA 02111-1307, USA. */
|
||||||
|
|
||||||
#include <errno.h>
|
#define __need_size_t
|
||||||
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
/* Generate a (hopefully) unique temporary filename
|
/* Perform the "SVID path search malarkey" on DIR and PFX. Write a
|
||||||
in DIR (if applicable), using prefix PFX.
|
template suitable for use in __gen_tempname into TMPL, bounded
|
||||||
If DIR_SEARCH is nonzero, perform directory searching
|
by TMPL_LEN. */
|
||||||
malarkey as per the SVID for tempnam.
|
int
|
||||||
Return the generated filename or NULL if one could not
|
__path_search (tmpl, tmpl_len, dir, pfx)
|
||||||
be generated, putting the length of the string in *LENPTR. */
|
char *tmpl;
|
||||||
char *
|
size_t tmpl_len;
|
||||||
__stdio_gen_tempname (buf, bufsize, dir, pfx, dir_search, lenptr, streamptr,
|
|
||||||
large_file)
|
|
||||||
char *buf;
|
|
||||||
size_t bufsize;
|
|
||||||
const char *dir;
|
const char *dir;
|
||||||
const char *pfx;
|
const char *pfx;
|
||||||
int dir_search;
|
{
|
||||||
size_t *lenptr;
|
__set_errno (ENOSYS);
|
||||||
FILE **streamptr;
|
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;
|
int large_file;
|
||||||
{
|
{
|
||||||
*lenptr = 0;
|
|
||||||
__set_errno (ENOSYS);
|
__set_errno (ENOSYS);
|
||||||
return NULL;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
stub_warning (__stdio_gen_tempname)
|
stub_warning (__gen_tempname)
|
||||||
#include <stub-tag.h>
|
#include <stub-tag.h>
|
||||||
|
@ -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;
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
@ -28,119 +28,99 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
#ifdef USE_IN_LIBIO
|
|
||||||
# include "libioP.h"
|
|
||||||
# include <libio.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Return nonzero if DIR is an existent directory. */
|
/* Return nonzero if DIR is an existent directory. */
|
||||||
static int
|
static int
|
||||||
diraccess (const char *dir)
|
direxists (const char *dir)
|
||||||
{
|
{
|
||||||
struct stat buf;
|
struct stat buf;
|
||||||
return __stat (dir, &buf) == 0 && S_ISDIR (buf.st_mode);
|
return __stat (dir, &buf) == 0 && S_ISDIR (buf.st_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return nonzero if FILE exists. */
|
/* Path search algorithm, for tmpnam, tmpfile, etc. If DIR is
|
||||||
static int
|
non-null and exists, uses it; otherwise uses the first of $TMPDIR,
|
||||||
exists (const char *file)
|
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. */
|
const char *d;
|
||||||
struct stat st;
|
size_t dlen, plen;
|
||||||
int save = errno;
|
|
||||||
if (__stat (file, &st) == 0)
|
if (!pfx || !pfx[0])
|
||||||
return 1;
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
/* We report that the file exists if stat failed for a reason other
|
pfx = "file";
|
||||||
than nonexistence. In this case, it may or may not exist, and we
|
plen = 4;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* 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)
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dir = tmpdir;
|
|
||||||
|
|
||||||
dlen = strlen (dir);
|
|
||||||
|
|
||||||
/* Remove trailing slashes from the directory name. */
|
|
||||||
while (dlen > 1 && dir[dlen - 1] == '/')
|
|
||||||
--dlen;
|
|
||||||
|
|
||||||
if (pfx != NULL && *pfx != '\0')
|
|
||||||
{
|
{
|
||||||
plen = strlen (pfx);
|
plen = strlen (pfx);
|
||||||
if (plen > 5)
|
if (plen > 5)
|
||||||
plen = 5;
|
plen = 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
else
|
||||||
plen = 0;
|
{
|
||||||
|
__set_errno (ENOENT);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
len = __snprintf (buf, bufsize, "%.*s/%.*sXXXXXX",
|
dlen = strlen (dir);
|
||||||
(int) dlen, dir, (int) plen, pfx);
|
while (dlen > 1 && dir[dlen - 1] == '/')
|
||||||
|
dlen--; /* remove trailing slashes */
|
||||||
|
|
||||||
if (len < dlen + plen + 7)
|
/* check we have room for "${dir}/${pfx}XXXXXX\0" */
|
||||||
{
|
if (tmpl_len < dlen + 1 + plen + 6 + 1)
|
||||||
|
{
|
||||||
__set_errno (EINVAL);
|
__set_errno (EINVAL);
|
||||||
return NULL;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
XXXXXX = &buf[dlen + plen + 1];
|
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;
|
||||||
|
|
||||||
|
len = strlen (tmpl);
|
||||||
|
if (len < 6 || strcmp (&tmpl[len - 6], "XXXXXX"))
|
||||||
|
{
|
||||||
|
__set_errno (EINVAL);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This is where the Xs start. */
|
||||||
|
XXXXXX = &tmpl[len - 6];
|
||||||
|
|
||||||
/* Get some more or less random data. */
|
/* Get some more or less random data. */
|
||||||
__gettimeofday (&tv, NULL);
|
__gettimeofday (&tv, NULL);
|
||||||
@ -163,116 +143,45 @@ __stdio_gen_tempname (char *buf, size_t bufsize, const char *dir,
|
|||||||
v /= 62;
|
v /= 62;
|
||||||
XXXXXX[5] = letters[v % 62];
|
XXXXXX[5] = letters[v % 62];
|
||||||
|
|
||||||
if (streamptr != NULL)
|
if (openit)
|
||||||
{
|
{
|
||||||
/* Try to create the file atomically. */
|
/* XXX Do we want to fail on largefile if 64 bit fileops
|
||||||
#ifdef _G_OPEN64
|
are not implemented, or just fall back to the old stuff? */
|
||||||
int fd = (large_file
|
#ifndef __stub_open64
|
||||||
? __open (buf, O_RDWR|O_CREAT|O_EXCL, 0666)
|
fd = (largefile
|
||||||
: _G_OPEN64 (buf, O_RDWR|O_CREAT|O_EXCL, 0666));
|
? __open (tmpl, O_RDWR | O_CREAT | O_EXCL, 0666)
|
||||||
|
: __open64 (tmpl, O_RDWR | O_CREAT | O_EXCL, 0666));
|
||||||
#else
|
#else
|
||||||
int fd = __open (buf, O_RDWR|O_CREAT|O_EXCL, 0666);
|
fd = __open (tmpl, O_RDWR | O_CREAT | O_EXCL, 0666);
|
||||||
#endif
|
#endif
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
{
|
{
|
||||||
/* We got a new file that did not previously exist.
|
__set_errno (save_errno);
|
||||||
Create a stream for it. */
|
return fd;
|
||||||
#ifdef USE_IN_LIBIO
|
}
|
||||||
int save;
|
else if (errno != EEXIST)
|
||||||
struct locked_FILE
|
/* 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. */
|
||||||
struct _IO_FILE_plus fp;
|
return -1;
|
||||||
#ifdef _IO_MTSAFE_IO
|
}
|
||||||
_IO_lock_t lock;
|
else
|
||||||
#endif
|
{
|
||||||
} *new_f;
|
struct stat st;
|
||||||
struct _IO_FILE_plus *fp;
|
if (__stat (tmpl, &st) < 0)
|
||||||
|
{
|
||||||
new_f = (struct locked_FILE *)
|
if (errno == ENOENT)
|
||||||
malloc (sizeof (struct locked_FILE));
|
{
|
||||||
if (new_f == NULL)
|
__set_errno (save_errno);
|
||||||
{
|
return 0;
|
||||||
/* We lost trying to create a stream (out of memory?).
|
}
|
||||||
Nothing to do but remove the file, close the descriptor,
|
else
|
||||||
and return failure. */
|
/* Give up now. */
|
||||||
save = errno;
|
return -1;
|
||||||
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)
|
|
||||||
{
|
|
||||||
/* 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;
|
|
||||||
}
|
|
||||||
(*streamptr)->__cookie = (__ptr_t) (long int) fd;
|
|
||||||
(*streamptr)->__mode.__write = 1;
|
|
||||||
(*streamptr)->__mode.__read = 1;
|
|
||||||
(*streamptr)->__mode.__binary = 1;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#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. */
|
/* We got out of the loop because we ran out of combinations to try. */
|
||||||
__set_errno (EEXIST); /* ? */
|
__set_errno (EEXIST);
|
||||||
return NULL;
|
return -1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user