This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
Re: [RFA:] add _mkdir_r, fixing fallout from "add mkstemps, mkdtemp"
- From: Jeff Johnston <jjohnstn at redhat dot com>
- To: Eric Blake <ebb9 at byu dot net>
- Cc: Hans-Peter Nilsson <hans-peter dot nilsson at axis dot com>, newlib at sources dot redhat dot com
- Date: Wed, 12 Aug 2009 12:26:14 -0400
- Subject: Re: [RFA:] add _mkdir_r, fixing fallout from "add mkstemps, mkdtemp"
- References: <200908112340.n7BNe4Lv016915@ignucius.se.axis.com> <4A822EE7.2080106@byu.net>
Eric Blake wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
According to Hans-Peter Nilsson on 8/11/2009 5:40 PM:
+#if !defined _ELIX_LEVEL || _ELIX_LEVEL >= 2
+ if (domkdir)
+ {
+ if (_mkdir_r (ptr, path, 0700) == 0)
+ return 1;
+ if (ptr->_errno != EEXIST)
+ return 0;
+ }
+ else
+#endif /* _ELIX_LEVEL */
So, where did you find that _mkdir_r you're calling? Were there
missing parts to the above patches? Would those parts look like
the patches below, adding necessary framework and stub for the
mkdir syscall?
I just assumed that it worked like any other syscall, but you are correct
that newlib has not yet wrapped mkdir. It worked for me on cygwin because
cygwin overrides mk*temp* in order to use a more secure random string
generation function, so this particular block wasn't getting compiled
under cygwin.
With this patch, I can use today's newlib with test-suite
results fixed (the same as before the above patch) for cris-elf.
Nope, didn't test it anywhere else. Not trying to raise the bar.
Ok to commit?
I can't approve it, but it looks obvious to me.
Actually, I don't agree with this. The better way to handle this is to
protect the code with HAVE_MKDIR and put in the libnosys logic directly
if it is not provided. Otherwise, this forces platforms to either
implement _mkdir or link with libnosys which is unreasonable. There are
other optional syscalls already being checked for in newlib. I have
put together a patch which I attached to this note. Let me know what
you think.
Index: mktemp.c
===================================================================
RCS file: /cvs/src/src/newlib/libc/stdio/mktemp.c,v
retrieving revision 1.11
diff -u -p -r1.11 mktemp.c
--- mktemp.c 3 Jul 2009 12:03:25 -0000 1.11
+++ mktemp.c 12 Aug 2009 16:23:48 -0000
@@ -201,10 +201,15 @@ _DEFUN(_gettemp, (ptr, path, doopen, dom
#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 */