diff options
author | Ron Yorston <rmy@pobox.com> | 2014-10-09 14:35:36 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2014-10-09 14:35:36 +0100 |
commit | 0e0b5e9ff840b6a26a0ad798ad68c07209c527b4 (patch) | |
tree | 3422725d1212fbe20dc6ec971bd2832ae5972914 | |
parent | 0161b80c268c9c3e36c7e639029f98a5d316f573 (diff) | |
download | busybox-w32-0e0b5e9ff840b6a26a0ad798ad68c07209c527b4.tar.gz busybox-w32-0e0b5e9ff840b6a26a0ad798ad68c07209c527b4.tar.bz2 busybox-w32-0e0b5e9ff840b6a26a0ad798ad68c07209c527b4.zip |
mingw.c: ignore EACCES from mkdir if directory exists
Microsoft Windows has a strange issue with access permissions such that
mkdir will sometimes return EACESS for an existing directory. This is
mentioned here:
http://www.apijunkie.com/APIJunkie/blog/post/2009/12/22/_mkdir-C-runtime-library-function-might-return-unexpected-error-values.aspx
This was causing mkdir -p to fail on a particular machine. Ignoring the
EACCES error if the directory exists fixes the problem.
-rw-r--r-- | win32/mingw.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/win32/mingw.c b/win32/mingw.c index 8045fb996..dfdbecc85 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -762,7 +762,20 @@ const char *get_busybox_exec_path(void) | |||
762 | #undef mkdir | 762 | #undef mkdir |
763 | int mingw_mkdir(const char *path, int mode UNUSED_PARAM) | 763 | int mingw_mkdir(const char *path, int mode UNUSED_PARAM) |
764 | { | 764 | { |
765 | return mkdir(path); | 765 | int ret; |
766 | struct stat st; | ||
767 | int lerrno = 0; | ||
768 | |||
769 | if ( (ret=mkdir(path)) < 0 ) { | ||
770 | lerrno = errno; | ||
771 | if ( lerrno == EACCES && stat(path, &st) == 0 ) { | ||
772 | ret = 0; | ||
773 | lerrno = 0; | ||
774 | } | ||
775 | } | ||
776 | |||
777 | errno = lerrno; | ||
778 | return ret; | ||
766 | } | 779 | } |
767 | 780 | ||
768 | int fcntl(int fd, int cmd, ...) | 781 | int fcntl(int fd, int cmd, ...) |