File tree Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -277,7 +277,7 @@ int git_futils_mkdir(
277
277
mode_t mode ,
278
278
uint32_t flags )
279
279
{
280
- int error = -1 , tmp_errno ;
280
+ int error = -1 , tmp ;
281
281
git_buf make_path = GIT_BUF_INIT ;
282
282
ssize_t root = 0 ;
283
283
char lastch , * tail ;
@@ -315,6 +315,11 @@ int git_futils_mkdir(
315
315
if (root < 0 )
316
316
root = 0 ;
317
317
318
+ /* make sure mkdir root is at least after filesystem root */
319
+ tmp = git_path_root (make_path .ptr );
320
+ if (root < tmp )
321
+ root = tmp ;
322
+
318
323
tail = & make_path .ptr [root ];
319
324
320
325
while (* tail ) {
@@ -345,26 +350,22 @@ int git_futils_mkdir(
345
350
346
351
already_exists = 1 ;
347
352
break ;
348
- #ifdef GIT_WIN32
349
- case EACCES :
350
- #endif
351
353
case ENOSYS :
352
- /* The following errors can be generated if:
353
- * EACCES - Win32 can generate this error if you try to mkdir
354
- * a path which is the root of a volume.
355
- * ENOSYS - Solaris can generate a ENOSYS error if you try to mkdir
356
- * a path which is already a mount point.
357
- * In these cases, the path does already exist; but it's not implied by
358
- * the definition of the error, so let's recheck */
359
- tmp_errno = errno ;
354
+ case EACCES :
355
+ /* Possible recoverable errors. These errors could occur
356
+ * on some OS if we try to mkdir at a network mount point
357
+ * or at the root of a volume. If the path is a dir, just
358
+ * treat as EEXIST.
359
+ */
360
+ tmp = errno ;
360
361
361
362
if (git_path_isdir (make_path .ptr )) {
362
363
already_exists = 1 ;
363
364
break ;
364
365
}
365
366
366
367
/* Fall through */
367
- errno = tmp_errno ;
368
+ errno = tmp ;
368
369
default :
369
370
giterr_set (GITERR_OS , "Failed to make directory '%s'" ,
370
371
make_path .ptr );
You can’t perform that action at this time.
0 commit comments