summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1b66834)
raw | patch | inline | side by side (parent: 1b66834)
author | Linus Torvalds <torvalds@g5.osdl.org> | |
Thu, 14 Jul 2005 00:27:48 +0000 (17:27 -0700) | ||
committer | Linus Torvalds <torvalds@g5.osdl.org> | |
Thu, 14 Jul 2005 00:27:48 +0000 (17:27 -0700) |
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.
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.
entry.c | patch | blob | history |
index ded83103a9d8f16333d941e1e5410e0a12822ae7..792ea733e851a3d288cad1e34ea89478503e71be 100644 (file)
--- a/entry.c
+++ b/entry.c
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;