git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Define compat version of mkdtemp for systems lacking it
@ 2007-10-21  5:30 Shawn O. Pearce
  2007-10-21 22:03 ` Johannes Schindelin
  0 siblings, 1 reply; 2+ messages in thread
From: Shawn O. Pearce @ 2007-10-21  5:30 UTC (permalink / raw)
  To: git

Solaris 9 doesn't have mkdtemp() so we need to emulate it for the
rsync transport implementation.  Since Solaris 9 is lacking this
function we can also reasonably assume it is not available on
Solaris 8 either.  The new Makfile definition NO_MKDTEMP can be
set to enable the git compat version.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---

 On top of 'next' so that the db/fetch-pack series will actually
 build on Solaris 9.

 Makefile          |    8 ++++++++
 compat/mkdtemp.c  |    8 ++++++++
 git-compat-util.h |    5 +++++
 3 files changed, 21 insertions(+), 0 deletions(-)
 create mode 100644 compat/mkdtemp.c

diff --git a/Makefile b/Makefile
index bb4873d..6287418 100644
--- a/Makefile
+++ b/Makefile
@@ -38,6 +38,8 @@ all::
 #
 # Define NO_SETENV if you don't have setenv in the C library.
 #
+# Define NO_MKDTEMP if you don't have mkdtemp in the C library.
+#
 # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
 # Enable it on Windows.  By default, symrefs are still used.
 #
@@ -414,12 +416,14 @@ ifeq ($(uname_S),SunOS)
 		NEEDS_LIBICONV = YesPlease
 		NO_UNSETENV = YesPlease
 		NO_SETENV = YesPlease
+		NO_MKDTEMP = YesPlease
 		NO_C99_FORMAT = YesPlease
 		NO_STRTOUMAX = YesPlease
 	endif
 	ifeq ($(uname_R),5.9)
 		NO_UNSETENV = YesPlease
 		NO_SETENV = YesPlease
+		NO_MKDTEMP = YesPlease
 		NO_C99_FORMAT = YesPlease
 		NO_STRTOUMAX = YesPlease
 	endif
@@ -610,6 +614,10 @@ ifdef NO_SETENV
 	COMPAT_CFLAGS += -DNO_SETENV
 	COMPAT_OBJS += compat/setenv.o
 endif
+ifdef NO_MKDTEMP
+	COMPAT_CFLAGS += -DNO_MKDTEMP
+	COMPAT_OBJS += compat/mkdtemp.o
+endif
 ifdef NO_UNSETENV
 	COMPAT_CFLAGS += -DNO_UNSETENV
 	COMPAT_OBJS += compat/unsetenv.o
diff --git a/compat/mkdtemp.c b/compat/mkdtemp.c
new file mode 100644
index 0000000..34d4b49
--- /dev/null
+++ b/compat/mkdtemp.c
@@ -0,0 +1,8 @@
+#include "../git-compat-util.h"
+
+char *gitmkdtemp(char *template)
+{
+	if (!mktemp(template) || mkdir(template, 0700))
+		return NULL;
+	return template;
+}
diff --git a/git-compat-util.h b/git-compat-util.h
index f23d934..474f1d1 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -147,6 +147,11 @@ extern ssize_t git_pread(int fd, void *buf, size_t count, off_t offset);
 extern int gitsetenv(const char *, const char *, int);
 #endif
 
+#ifdef NO_MKDTEMP
+#define mkdtemp gitmkdtemp
+extern char *gitmkdtemp(char *);
+#endif
+
 #ifdef NO_UNSETENV
 #define unsetenv gitunsetenv
 extern void gitunsetenv(const char *);
-- 
1.5.3.4.1270.g2fe543

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Define compat version of mkdtemp for systems lacking it
  2007-10-21  5:30 [PATCH] Define compat version of mkdtemp for systems lacking it Shawn O. Pearce
@ 2007-10-21 22:03 ` Johannes Schindelin
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Schindelin @ 2007-10-21 22:03 UTC (permalink / raw)
  To: Shawn O. Pearce; +Cc: git

Hi,

On Sun, 21 Oct 2007, Shawn O. Pearce wrote:

> Solaris 9 doesn't have mkdtemp() so we need to emulate it for the
> rsync transport implementation.

Thanks.  I've been meaning to do it for msysGit, but I never came around 
to do it...

Ciao,
Dscho

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-10-21 22:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-21  5:30 [PATCH] Define compat version of mkdtemp for systems lacking it Shawn O. Pearce
2007-10-21 22:03 ` Johannes Schindelin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).