2009=08-12 Jeff Johnston <jjohnstn@redhat.com>

* libc/stdio/mktemp.c (_gettemp): Do not call _mkdir_r unless
        HAVE_MKDIR is defined.

2009-08-12  Hans-Peter Nilsson  <hp@axis.com>

        * libc/include/reent.h: Add prototype and definition of _mkdir_r.
        * libc/reent/Makefile.am (GENERAL_SOURCES): Add mkdirr.c.
        (CHEWOUT_FILES): Add mkdirr.def.
        * libc/reent/Makefile.in: Regenerate.
        * libc/reent/mkdirr.c: New file.
This commit is contained in:
Jeff Johnston 2009-08-12 18:22:38 +00:00
parent a73a3f438b
commit 12387ab6f7
6 changed files with 102 additions and 7 deletions

View File

@ -1,3 +1,16 @@
2009=08-12 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdio/mktemp.c (_gettemp): Do not call _mkdir_r unless
HAVE_MKDIR is defined.
2009-08-12 Hans-Peter Nilsson <hp@axis.com>
* libc/include/reent.h: Add prototype and definition of _mkdir_r.
* libc/reent/Makefile.am (GENERAL_SOURCES): Add mkdirr.c.
(CHEWOUT_FILES): Add mkdirr.def.
* libc/reent/Makefile.in: Regenerate.
* libc/reent/mkdirr.c: New file.
2009-08-10 Jeff Johnston <jjohnstn@redhat.com> 2009-08-10 Jeff Johnston <jjohnstn@redhat.com>
* libc/stdlib/wcstombs.c: Change documentation to specify size_t * libc/stdlib/wcstombs.c: Change documentation to specify size_t

View File

@ -116,6 +116,7 @@ struct timezone;
#define _kill_r(__reent, __pid, __signal) kill(__pid, __signal) #define _kill_r(__reent, __pid, __signal) kill(__pid, __signal)
#define _link_r(__reent, __oldpath, __newpath) link(__oldpath, __newpath) #define _link_r(__reent, __oldpath, __newpath) link(__oldpath, __newpath)
#define _lseek_r(__reent, __fdes, __off, __w) lseek(__fdes, __off, __w) #define _lseek_r(__reent, __fdes, __off, __w) lseek(__fdes, __off, __w)
#define _mkdir_r(__reent, __path, __m) mkdir(__path, __m)
#define _open_r(__reent, __path, __flag, __m) open(__path, __flag, __m) #define _open_r(__reent, __path, __flag, __m) open(__path, __flag, __m)
#define _read_r(__reent, __fd, __buff, __cnt) read(__fd, __buff, __cnt) #define _read_r(__reent, __fd, __buff, __cnt) read(__fd, __buff, __cnt)
#define _rename_r(__reent, __old, __new) rename(__old, __new) #define _rename_r(__reent, __old, __new) rename(__old, __new)
@ -146,6 +147,7 @@ extern int _isatty_r _PARAMS ((struct _reent *, int));
extern int _kill_r _PARAMS ((struct _reent *, int, int)); extern int _kill_r _PARAMS ((struct _reent *, int, int));
extern int _link_r _PARAMS ((struct _reent *, const char *, const char *)); extern int _link_r _PARAMS ((struct _reent *, const char *, const char *));
extern _off_t _lseek_r _PARAMS ((struct _reent *, int, _off_t, int)); extern _off_t _lseek_r _PARAMS ((struct _reent *, int, _off_t, int));
extern int _mkdir_r _PARAMS ((struct _reent *, const char *, int));
extern int _open_r _PARAMS ((struct _reent *, const char *, int, int)); extern int _open_r _PARAMS ((struct _reent *, const char *, int, int));
extern _ssize_t _read_r _PARAMS ((struct _reent *, int, void *, size_t)); extern _ssize_t _read_r _PARAMS ((struct _reent *, int, void *, size_t));
extern int _rename_r _PARAMS ((struct _reent *, const char *, const char *)); extern int _rename_r _PARAMS ((struct _reent *, const char *, const char *));

View File

@ -42,6 +42,7 @@ GENERAL_SOURCES = \
isattyr.c \ isattyr.c \
linkr.c \ linkr.c \
lseekr.c \ lseekr.c \
mkdirr.c \
openr.c \ openr.c \
readr.c \ readr.c \
renamer.c \ renamer.c \
@ -77,6 +78,7 @@ CHEWOUT_FILES = \
gettimeofdayr.def \ gettimeofdayr.def \
linkr.def \ linkr.def \
lseekr.def \ lseekr.def \
mkdirr.def \
openr.def \ openr.def \
readr.def \ readr.def \
renamer.def \ renamer.def \

View File

@ -62,11 +62,12 @@ am__objects_1 = lib_a-closer.$(OBJEXT) lib_a-reent.$(OBJEXT) \
lib_a-fstatr.$(OBJEXT) lib_a-getreent.$(OBJEXT) \ lib_a-fstatr.$(OBJEXT) lib_a-getreent.$(OBJEXT) \
lib_a-gettimeofdayr.$(OBJEXT) lib_a-isattyr.$(OBJEXT) \ lib_a-gettimeofdayr.$(OBJEXT) lib_a-isattyr.$(OBJEXT) \
lib_a-linkr.$(OBJEXT) lib_a-lseekr.$(OBJEXT) \ lib_a-linkr.$(OBJEXT) lib_a-lseekr.$(OBJEXT) \
lib_a-openr.$(OBJEXT) lib_a-readr.$(OBJEXT) \ lib_a-mkdirr.$(OBJEXT) lib_a-openr.$(OBJEXT) \
lib_a-renamer.$(OBJEXT) lib_a-signalr.$(OBJEXT) \ lib_a-readr.$(OBJEXT) lib_a-renamer.$(OBJEXT) \
lib_a-signgam.$(OBJEXT) lib_a-sbrkr.$(OBJEXT) \ lib_a-signalr.$(OBJEXT) lib_a-signgam.$(OBJEXT) \
lib_a-statr.$(OBJEXT) lib_a-timesr.$(OBJEXT) \ lib_a-sbrkr.$(OBJEXT) lib_a-statr.$(OBJEXT) \
lib_a-unlinkr.$(OBJEXT) lib_a-writer.$(OBJEXT) lib_a-timesr.$(OBJEXT) lib_a-unlinkr.$(OBJEXT) \
lib_a-writer.$(OBJEXT)
@HAVE_STDIO64_DIR_TRUE@am__objects_2 = lib_a-fstat64r.$(OBJEXT) \ @HAVE_STDIO64_DIR_TRUE@am__objects_2 = lib_a-fstat64r.$(OBJEXT) \
@HAVE_STDIO64_DIR_TRUE@ lib_a-lseek64r.$(OBJEXT) \ @HAVE_STDIO64_DIR_TRUE@ lib_a-lseek64r.$(OBJEXT) \
@HAVE_STDIO64_DIR_TRUE@ lib_a-stat64r.$(OBJEXT) \ @HAVE_STDIO64_DIR_TRUE@ lib_a-stat64r.$(OBJEXT) \
@ -85,8 +86,8 @@ LTLIBRARIES = $(noinst_LTLIBRARIES)
libreent_la_LIBADD = libreent_la_LIBADD =
am__objects_6 = closer.lo reent.lo impure.lo fcntlr.lo fstatr.lo \ am__objects_6 = closer.lo reent.lo impure.lo fcntlr.lo fstatr.lo \
getreent.lo gettimeofdayr.lo isattyr.lo linkr.lo lseekr.lo \ getreent.lo gettimeofdayr.lo isattyr.lo linkr.lo lseekr.lo \
openr.lo readr.lo renamer.lo signalr.lo signgam.lo sbrkr.lo \ mkdirr.lo openr.lo readr.lo renamer.lo signalr.lo signgam.lo \
statr.lo timesr.lo unlinkr.lo writer.lo sbrkr.lo statr.lo timesr.lo unlinkr.lo writer.lo
@HAVE_STDIO64_DIR_TRUE@am__objects_7 = fstat64r.lo lseek64r.lo \ @HAVE_STDIO64_DIR_TRUE@am__objects_7 = fstat64r.lo lseek64r.lo \
@HAVE_STDIO64_DIR_TRUE@ stat64r.lo open64r.lo @HAVE_STDIO64_DIR_TRUE@ stat64r.lo open64r.lo
am__objects_8 = $(am__objects_7) am__objects_8 = $(am__objects_7)
@ -158,6 +159,8 @@ ENABLE_NEWLIB_ICONV_TRUE = @ENABLE_NEWLIB_ICONV_TRUE@
EXEEXT = @EXEEXT@ EXEEXT = @EXEEXT@
FGREP = @FGREP@ FGREP = @FGREP@
GREP = @GREP@ GREP = @GREP@
HAVE_LONG_DOUBLE_FALSE = @HAVE_LONG_DOUBLE_FALSE@
HAVE_LONG_DOUBLE_TRUE = @HAVE_LONG_DOUBLE_TRUE@
HAVE_POSIX_DIR_FALSE = @HAVE_POSIX_DIR_FALSE@ HAVE_POSIX_DIR_FALSE = @HAVE_POSIX_DIR_FALSE@
HAVE_POSIX_DIR_TRUE = @HAVE_POSIX_DIR_TRUE@ HAVE_POSIX_DIR_TRUE = @HAVE_POSIX_DIR_TRUE@
HAVE_SIGNAL_DIR_FALSE = @HAVE_SIGNAL_DIR_FALSE@ HAVE_SIGNAL_DIR_FALSE = @HAVE_SIGNAL_DIR_FALSE@
@ -313,6 +316,7 @@ GENERAL_SOURCES = \
isattyr.c \ isattyr.c \
linkr.c \ linkr.c \
lseekr.c \ lseekr.c \
mkdirr.c \
openr.c \ openr.c \
readr.c \ readr.c \
renamer.c \ renamer.c \
@ -341,6 +345,7 @@ CHEWOUT_FILES = \
gettimeofdayr.def \ gettimeofdayr.def \
linkr.def \ linkr.def \
lseekr.def \ lseekr.def \
mkdirr.def \
openr.def \ openr.def \
readr.def \ readr.def \
renamer.def \ renamer.def \
@ -483,6 +488,12 @@ lib_a-lseekr.o: lseekr.c
lib_a-lseekr.obj: lseekr.c lib_a-lseekr.obj: lseekr.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-lseekr.obj `if test -f 'lseekr.c'; then $(CYGPATH_W) 'lseekr.c'; else $(CYGPATH_W) '$(srcdir)/lseekr.c'; fi` $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-lseekr.obj `if test -f 'lseekr.c'; then $(CYGPATH_W) 'lseekr.c'; else $(CYGPATH_W) '$(srcdir)/lseekr.c'; fi`
lib_a-mkdirr.o: mkdirr.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mkdirr.o `test -f 'mkdirr.c' || echo '$(srcdir)/'`mkdirr.c
lib_a-mkdirr.obj: mkdirr.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-mkdirr.obj `if test -f 'mkdirr.c'; then $(CYGPATH_W) 'mkdirr.c'; else $(CYGPATH_W) '$(srcdir)/mkdirr.c'; fi`
lib_a-openr.o: openr.c lib_a-openr.o: openr.c
$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-openr.o `test -f 'openr.c' || echo '$(srcdir)/'`openr.c $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-openr.o `test -f 'openr.c' || echo '$(srcdir)/'`openr.c

View File

@ -0,0 +1,62 @@
/* Reentrant versions of mkdir system call. */
#include <reent.h>
#include <unistd.h>
#include <_syslist.h>
/* Some targets provides their own versions of this functions. Those
targets should define REENTRANT_SYSCALLS_PROVIDED in TARGET_CFLAGS. */
#ifdef _REENT_ONLY
#ifndef REENTRANT_SYSCALLS_PROVIDED
#define REENTRANT_SYSCALLS_PROVIDED
#endif
#endif
#ifndef REENTRANT_SYSCALLS_PROVIDED
/* We use the errno variable used by the system dependent layer. */
#undef errno
extern int errno;
/*
FUNCTION
<<_mkdir_r>>---Reentrant version of mkdir
INDEX
_mkdir_r
ANSI_SYNOPSIS
#include <reent.h>
int _mkdir_r(struct _reent *<[ptr]>,
const char *<[path]>, int <[mode]>);
TRAD_SYNOPSIS
#include <reent.h>
int _mkdir_r(<[ptr]>, <[path]>, <[mode]>)
struct _reent *<[ptr]>;
char *<[path]>;
int <[mode]>;
DESCRIPTION
This is a reentrant version of <<mkdir>>. It
takes a pointer to the global data block, which holds
<<errno>>.
*/
int
_DEFUN (_mkdir_r, (ptr, path, mode),
struct _reent *ptr _AND
_CONST char *path _AND
int mode)
{
int ret;
errno = 0;
if ((ret = _mkdir (path, mode)) == -1 && errno != 0)
ptr->_errno = errno;
return ret;
}
#endif /* ! defined (REENTRANT_SYSCALLS_PROVIDED) */

View File

@ -201,10 +201,15 @@ _DEFUN(_gettemp, (ptr, path, doopen, domkdir, suffixlen),
#if !defined _ELIX_LEVEL || _ELIX_LEVEL >= 4 #if !defined _ELIX_LEVEL || _ELIX_LEVEL >= 4
if (domkdir) if (domkdir)
{ {
#ifdef HAVE_MKDIR
if (_mkdir_r (ptr, path, 0700) == 0) if (_mkdir_r (ptr, path, 0700) == 0)
return 1; return 1;
if (ptr->_errno != EEXIST) if (ptr->_errno != EEXIST)
return 0; return 0;
#else /* !HAVE_MKDIR */
ptr->_errno = ENOSYS;
return 0;
#endif /* !HAVE_MKDIR */
} }
else else
#endif /* _ELIX_LEVEL */ #endif /* _ELIX_LEVEL */