Skip to content

Commit ca5bb5d

Browse files
committed
Define compat version of mkdtemp for systems lacking it
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>
1 parent cfa5b2b commit ca5bb5d

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ all::
3838
#
3939
# Define NO_SETENV if you don't have setenv in the C library.
4040
#
41+
# Define NO_MKDTEMP if you don't have mkdtemp in the C library.
42+
#
4143
# Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.
4244
# Enable it on Windows. By default, symrefs are still used.
4345
#
@@ -414,12 +416,14 @@ ifeq ($(uname_S),SunOS)
414416
NEEDS_LIBICONV = YesPlease
415417
NO_UNSETENV = YesPlease
416418
NO_SETENV = YesPlease
419+
NO_MKDTEMP = YesPlease
417420
NO_C99_FORMAT = YesPlease
418421
NO_STRTOUMAX = YesPlease
419422
endif
420423
ifeq ($(uname_R),5.9)
421424
NO_UNSETENV = YesPlease
422425
NO_SETENV = YesPlease
426+
NO_MKDTEMP = YesPlease
423427
NO_C99_FORMAT = YesPlease
424428
NO_STRTOUMAX = YesPlease
425429
endif
@@ -610,6 +614,10 @@ ifdef NO_SETENV
610614
COMPAT_CFLAGS += -DNO_SETENV
611615
COMPAT_OBJS += compat/setenv.o
612616
endif
617+
ifdef NO_MKDTEMP
618+
COMPAT_CFLAGS += -DNO_MKDTEMP
619+
COMPAT_OBJS += compat/mkdtemp.o
620+
endif
613621
ifdef NO_UNSETENV
614622
COMPAT_CFLAGS += -DNO_UNSETENV
615623
COMPAT_OBJS += compat/unsetenv.o

compat/mkdtemp.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include "../git-compat-util.h"
2+
3+
char *gitmkdtemp(char *template)
4+
{
5+
if (!mktemp(template) || mkdir(template, 0700))
6+
return NULL;
7+
return template;
8+
}

git-compat-util.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ extern ssize_t git_pread(int fd, void *buf, size_t count, off_t offset);
147147
extern int gitsetenv(const char *, const char *, int);
148148
#endif
149149

150+
#ifdef NO_MKDTEMP
151+
#define mkdtemp gitmkdtemp
152+
extern char *gitmkdtemp(char *);
153+
#endif
154+
150155
#ifdef NO_UNSETENV
151156
#define unsetenv gitunsetenv
152157
extern void gitunsetenv(const char *);

0 commit comments

Comments
 (0)