diff options
author | Linus Torvalds <torvalds@g5.osdl.org> | 2005-07-13 17:27:48 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-07-13 17:27:48 -0700 |
commit | 2408cff9f738459019709c8c12d0bd8a5605566f (patch) | |
tree | 9baa5e67c470376b09cbcc4cb68ef80654753e1f /entry.c | |
parent | 1b668341db6576d8d851473c74388031b319798a (diff) | |
download | git-2408cff9f738459019709c8c12d0bd8a5605566f.tar.gz |
Make "git-checkout" create files with O_EXCL
We should always have unlinked any old ones before, but this just makes
sure that we never over-write any old file.
A quick "grep" now shows that all the core tools that open files for
writing use O_EXCL, ie we never overwrite an existing file in place.
Diffstat (limited to 'entry.c')
-rw-r--r-- | entry.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -62,11 +62,11 @@ static int create_file(const char *path, unsigned int mode, int force) int fd; mode = (mode & 0100) ? 0777 : 0666; - fd = open(path, O_WRONLY | O_TRUNC | O_CREAT, mode); + fd = open(path, O_WRONLY | O_TRUNC | O_CREAT | O_EXCL, mode); if (fd < 0) { if (errno == EISDIR && force) { remove_subtree(path); - fd = open(path, O_WRONLY | O_TRUNC | O_CREAT, mode); + fd = open(path, O_WRONLY | O_TRUNC | O_CREAT | O_EXCL, mode); } } return fd; |