Skip to content

Commit

Permalink
Define compat version of mkdtemp for systems lacking it
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Shawn O. Pearce committed Oct 21, 2007
1 parent cfa5b2b commit ca5bb5d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
#
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions compat/mkdtemp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "../git-compat-util.h"

char *gitmkdtemp(char *template)
{
if (!mktemp(template) || mkdir(template, 0700))
return NULL;
return template;
}
5 changes: 5 additions & 0 deletions git-compat-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);
Expand Down

0 comments on commit ca5bb5d

Please sign in to comment.