summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2017-03-22 19:48:50 +0000
committerEdward Thomson <ethomson@edwardthomson.com>2017-03-22 19:48:50 +0000
commit4a26915d34414709bfb93a688ac9ae93dbe5828e (patch)
tree523fa5976acb530d442677d6ab69a4cbcbb595db
parent33ea4aae378f390aa4e2163389cd2cc183420ebe (diff)
downloadlibgit2-ethomson/dont_trunc_and_excl.tar.gz
git_futils: don't O_EXCL and O_TRUNCethomson/dont_trunc_and_excl
`O_EXCL` and `O_TRUNC` are mutually exclusive flags to open(2); you can't truncate a file if you're asserting that it can't exist in the first place. Drop `O_TRUNC`.
-rw-r--r--src/fileops.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/fileops.c b/src/fileops.c
index acb3b87e3..cc638ea5b 100644
--- a/src/fileops.c
+++ b/src/fileops.c
@@ -66,8 +66,8 @@ int git_futils_creat_withpath(const char *path, const mode_t dirmode, const mode
int git_futils_creat_locked(const char *path, const mode_t mode)
{
- int fd = p_open(path, O_WRONLY | O_CREAT | O_TRUNC |
- O_EXCL | O_BINARY | O_CLOEXEC, mode);
+ int fd = p_open(path, O_WRONLY | O_CREAT | O_EXCL | O_BINARY | O_CLOEXEC,
+ mode);
if (fd < 0) {
int error = errno;