Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
987ab765
Commit
987ab765
authored
Jun 05, 2013
by
Vicent Martí
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1634 from arrbee/alternative-mkdir-fix
Ensure git_futils_mkdir won't mkdir root
parents
e236b37f
b832ecf7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
13 deletions
+14
-13
src/fileops.c
+14
-13
No files found.
src/fileops.c
View file @
987ab765
...
...
@@ -277,7 +277,7 @@ int git_futils_mkdir(
mode_t
mode
,
uint32_t
flags
)
{
int
error
=
-
1
,
tmp
_errno
;
int
error
=
-
1
,
tmp
;
git_buf
make_path
=
GIT_BUF_INIT
;
ssize_t
root
=
0
;
char
lastch
,
*
tail
;
...
...
@@ -315,6 +315,11 @@ int git_futils_mkdir(
if
(
root
<
0
)
root
=
0
;
/* make sure mkdir root is at least after filesystem root */
tmp
=
git_path_root
(
make_path
.
ptr
);
if
(
root
<
tmp
)
root
=
tmp
;
tail
=
&
make_path
.
ptr
[
root
];
while
(
*
tail
)
{
...
...
@@ -345,18 +350,14 @@ int git_futils_mkdir(
already_exists
=
1
;
break
;
#ifdef GIT_WIN32
case
EACCES
:
#endif
case
ENOSYS
:
/* The following errors can be generated if:
* EACCES - Win32 can generate this error if you try to mkdir
* a path which is the root of a volume.
* ENOSYS - Solaris can generate a ENOSYS error if you try to mkdir
* a path which is already a mount point.
* In these cases, the path does already exist; but it's not implied by
* the definition of the error, so let's recheck */
tmp_errno
=
errno
;
case
EACCES
:
/* Possible recoverable errors. These errors could occur
* on some OS if we try to mkdir at a network mount point
* or at the root of a volume. If the path is a dir, just
* treat as EEXIST.
*/
tmp
=
errno
;
if
(
git_path_isdir
(
make_path
.
ptr
))
{
already_exists
=
1
;
...
...
@@ -364,7 +365,7 @@ int git_futils_mkdir(
}
/* Fall through */
errno
=
tmp
_errno
;
errno
=
tmp
;
default:
giterr_set
(
GITERR_OS
,
"Failed to make directory '%s'"
,
make_path
.
ptr
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment