diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2009-08-12 18:22:38 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2009-08-12 18:22:38 +0000 |
commit | 12387ab6f77d6ae4fa3d8fdc1756d416a27197dd (patch) | |
tree | 36dafe73c5a032c70c5a02b3be651175ffc268b3 | |
parent | a73a3f438bd75c84ab2f6eb2a27a9b5064b7af9c (diff) | |
download | newlib-12387ab6f77d6ae4fa3d8fdc1756d416a27197dd.zip newlib-12387ab6f77d6ae4fa3d8fdc1756d416a27197dd.tar.gz newlib-12387ab6f77d6ae4fa3d8fdc1756d416a27197dd.tar.bz2 |
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.
-rw-r--r-- | newlib/ChangeLog | 13 | ||||
-rw-r--r-- | newlib/libc/include/reent.h | 2 | ||||
-rw-r--r-- | newlib/libc/reent/Makefile.am | 2 | ||||
-rw-r--r-- | newlib/libc/reent/Makefile.in | 25 | ||||
-rw-r--r-- | newlib/libc/reent/mkdirr.c | 62 | ||||
-rw-r--r-- | newlib/libc/stdio/mktemp.c | 5 |
6 files changed, 102 insertions, 7 deletions
diff --git a/newlib/ChangeLog b/newlib/ChangeLog index a536c78..dd3c66c 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -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> * libc/stdlib/wcstombs.c: Change documentation to specify size_t diff --git a/newlib/libc/include/reent.h b/newlib/libc/include/reent.h index 50b0b57..4617c0d 100644 --- a/newlib/libc/include/reent.h +++ b/newlib/libc/include/reent.h @@ -116,6 +116,7 @@ struct timezone; #define _kill_r(__reent, __pid, __signal) kill(__pid, __signal) #define _link_r(__reent, __oldpath, __newpath) link(__oldpath, __newpath) #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 _read_r(__reent, __fd, __buff, __cnt) read(__fd, __buff, __cnt) #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 _link_r _PARAMS ((struct _reent *, const char *, const char *)); 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 _ssize_t _read_r _PARAMS ((struct _reent *, int, void *, size_t)); extern int _rename_r _PARAMS ((struct _reent *, const char *, const char *)); diff --git a/newlib/libc/reent/Makefile.am b/newlib/libc/reent/Makefile.am index e61153c..9e0602d 100644 --- a/newlib/libc/reent/Makefile.am +++ b/newlib/libc/reent/Makefile.am @@ -42,6 +42,7 @@ GENERAL_SOURCES = \ isattyr.c \ linkr.c \ lseekr.c \ + mkdirr.c \ openr.c \ readr.c \ renamer.c \ @@ -77,6 +78,7 @@ CHEWOUT_FILES = \ gettimeofdayr.def \ linkr.def \ lseekr.def \ + mkdirr.def \ openr.def \ readr.def \ renamer.def \ diff --git a/newlib/libc/reent/Makefile.in b/newlib/libc/reent/Makefile.in index 171c71a..dd189b3 100644 --- a/newlib/libc/reent/Makefile.in +++ b/newlib/libc/reent/Makefile.in @@ -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-gettimeofdayr.$(OBJEXT) lib_a-isattyr.$(OBJEXT) \ lib_a-linkr.$(OBJEXT) lib_a-lseekr.$(OBJEXT) \ - lib_a-openr.$(OBJEXT) lib_a-readr.$(OBJEXT) \ - lib_a-renamer.$(OBJEXT) lib_a-signalr.$(OBJEXT) \ - lib_a-signgam.$(OBJEXT) lib_a-sbrkr.$(OBJEXT) \ - lib_a-statr.$(OBJEXT) lib_a-timesr.$(OBJEXT) \ - lib_a-unlinkr.$(OBJEXT) lib_a-writer.$(OBJEXT) + lib_a-mkdirr.$(OBJEXT) lib_a-openr.$(OBJEXT) \ + lib_a-readr.$(OBJEXT) lib_a-renamer.$(OBJEXT) \ + lib_a-signalr.$(OBJEXT) lib_a-signgam.$(OBJEXT) \ + lib_a-sbrkr.$(OBJEXT) lib_a-statr.$(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@ lib_a-lseek64r.$(OBJEXT) \ @HAVE_STDIO64_DIR_TRUE@ lib_a-stat64r.$(OBJEXT) \ @@ -85,8 +86,8 @@ LTLIBRARIES = $(noinst_LTLIBRARIES) libreent_la_LIBADD = am__objects_6 = closer.lo reent.lo impure.lo fcntlr.lo fstatr.lo \ getreent.lo gettimeofdayr.lo isattyr.lo linkr.lo lseekr.lo \ - openr.lo readr.lo renamer.lo signalr.lo signgam.lo sbrkr.lo \ - statr.lo timesr.lo unlinkr.lo writer.lo + mkdirr.lo openr.lo readr.lo renamer.lo signalr.lo signgam.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@ stat64r.lo open64r.lo am__objects_8 = $(am__objects_7) @@ -158,6 +159,8 @@ ENABLE_NEWLIB_ICONV_TRUE = @ENABLE_NEWLIB_ICONV_TRUE@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ 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_TRUE = @HAVE_POSIX_DIR_TRUE@ HAVE_SIGNAL_DIR_FALSE = @HAVE_SIGNAL_DIR_FALSE@ @@ -313,6 +316,7 @@ GENERAL_SOURCES = \ isattyr.c \ linkr.c \ lseekr.c \ + mkdirr.c \ openr.c \ readr.c \ renamer.c \ @@ -341,6 +345,7 @@ CHEWOUT_FILES = \ gettimeofdayr.def \ linkr.def \ lseekr.def \ + mkdirr.def \ openr.def \ readr.def \ renamer.def \ @@ -483,6 +488,12 @@ lib_a-lseekr.o: 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` +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 $(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 diff --git a/newlib/libc/reent/mkdirr.c b/newlib/libc/reent/mkdirr.c new file mode 100644 index 0000000..29d808d --- /dev/null +++ b/newlib/libc/reent/mkdirr.c @@ -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) */ diff --git a/newlib/libc/stdio/mktemp.c b/newlib/libc/stdio/mktemp.c index 167ee9b..185d9df 100644 --- a/newlib/libc/stdio/mktemp.c +++ b/newlib/libc/stdio/mktemp.c @@ -201,10 +201,15 @@ _DEFUN(_gettemp, (ptr, path, doopen, domkdir, suffixlen), #if !defined _ELIX_LEVEL || _ELIX_LEVEL >= 4 if (domkdir) { +#ifdef HAVE_MKDIR if (_mkdir_r (ptr, path, 0700) == 0) return 1; if (ptr->_errno != EEXIST) return 0; +#else /* !HAVE_MKDIR */ + ptr->_errno = ENOSYS; + return 0; +#endif /* !HAVE_MKDIR */ } else #endif /* _ELIX_LEVEL */ |