mirror of
https://git.proxmox.com/git/libgit2
synced 2025-10-14 21:06:01 +00:00
fileops: save errno and report file existence
We need to save the errno, lest we clobber it in the giterr_set() call. Also add code for reporting that a path component is missing, which is a distinct failure mode.
This commit is contained in:
parent
2d9aec99fb
commit
f94825c10c
@ -72,8 +72,16 @@ int git_futils_creat_locked(const char *path, const mode_t mode)
|
||||
O_EXCL | O_BINARY | O_CLOEXEC, mode);
|
||||
|
||||
if (fd < 0) {
|
||||
int error = errno;
|
||||
giterr_set(GITERR_OS, "Failed to create locked file '%s'", path);
|
||||
return errno == EEXIST ? GIT_ELOCKED : -1;
|
||||
switch (error) {
|
||||
case EEXIST:
|
||||
return GIT_ELOCKED;
|
||||
case ENOENT:
|
||||
return GIT_ENOTFOUND;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return fd;
|
||||
|
Loading…
Reference in New Issue
Block a user