diff options
| author | Martin Ridgers <[email protected]> | 2022-02-21 13:28:40 +0100 |
|---|---|---|
| committer | Martin Ridgers <[email protected]> | 2022-02-21 13:28:40 +0100 |
| commit | 9910aa2db475c47ff97f4239e2393a940663685f (patch) | |
| tree | defc14379d3f7b1aefd0c893f0dcb0fcfd34f156 | |
| parent | Linux compile fix (diff) | |
| download | zen-9910aa2db475c47ff97f4239e2393a940663685f.tar.xz zen-9910aa2db475c47ff97f4239e2393a940663685f.zip | |
If open(O_CREAT) is used then a file mode must be given
| -rw-r--r-- | zen/internalfile.cpp | 2 | ||||
| -rw-r--r-- | zencore/filesystem.cpp | 8 | ||||
| -rw-r--r-- | zencore/thread.cpp | 4 | ||||
| -rw-r--r-- | zenstore/basicfile.cpp | 4 | ||||
| -rw-r--r-- | zenstore/filecas.cpp | 2 |
5 files changed, 10 insertions, 10 deletions
diff --git a/zen/internalfile.cpp b/zen/internalfile.cpp index 354ec2221..b3b587a41 100644 --- a/zen/internalfile.cpp +++ b/zen/internalfile.cpp @@ -182,7 +182,7 @@ InternalFile::OpenWrite(std::filesystem::path FileName, bool IsCreate) int OpenFlags = O_RDWR | O_CLOEXEC; OpenFlags |= IsCreate ? O_CREAT | O_TRUNC : 0; - int Fd = open(FileName.c_str(), OpenFlags); + int Fd = open(FileName.c_str(), OpenFlags, 0666); if (Fd >= 0) { if (IsCreate) diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp index 7cd71e4b4..79563190c 100644 --- a/zencore/filesystem.cpp +++ b/zencore/filesystem.cpp @@ -436,7 +436,7 @@ CloneFile(std::filesystem::path FromPath, std::filesystem::path ToPath) ScopedFd $From = { FromFd }; // The 'to' file - int ToFd = open(ToPath.c_str(), O_WRONLY|O_CREAT|O_EXCL|O_CLOEXEC); + int ToFd = open(ToPath.c_str(), O_WRONLY|O_CREAT|O_EXCL|O_CLOEXEC, 0666); if (ToFd < 0) { return false; @@ -503,7 +503,7 @@ CopyFile(std::filesystem::path FromPath, std::filesystem::path ToPath, const Cop ScopedFd $From = {FromFd}; // To file - int ToFd = open(ToPath.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC); + int ToFd = open(ToPath.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC, 0666); if (ToFd < 0) { ThrowLastError(fmt::format("failed to create file {}", ToPath)); @@ -560,11 +560,11 @@ WriteFile(std::filesystem::path Path, const IoBuffer* const* Data, size_t Buffer #else int OpenFlags = O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC; - int Fd = open(Path.c_str(), OpenFlags); + int Fd = open(Path.c_str(), OpenFlags, 0666); if (Fd < 0) { zen::CreateDirectories(Path.parent_path()); - Fd = open(Path.c_str(), OpenFlags); + Fd = open(Path.c_str(), OpenFlags, 0666); } if (Fd < 0) diff --git a/zencore/thread.cpp b/zencore/thread.cpp index df8cb7a34..527938cf3 100644 --- a/zencore/thread.cpp +++ b/zencore/thread.cpp @@ -271,7 +271,7 @@ NamedEvent::NamedEvent(std::string_view EventName) ExtendableStringBuilder<64> EventPath; EventPath << "/tmp/" << EventName; - int Fd = open(EventPath.c_str(), O_RDWR | O_CREAT | O_CLOEXEC); + int Fd = open(EventPath.c_str(), O_RDWR | O_CREAT | O_CLOEXEC, 0666); if (Fd < 0) { ThrowLastError(fmt::format("Failed to create '{}' for named event", EventPath)); @@ -448,7 +448,7 @@ NamedMutex::Create(std::string_view MutexName) ExtendableStringBuilder<64> Name; Name << "/tmp/" << MutexName; - int Inner = open(Name.c_str(), O_RDWR | O_CREAT | O_CLOEXEC); + int Inner = open(Name.c_str(), O_RDWR | O_CREAT | O_CLOEXEC, 0666); if (Inner < 0) { return false; diff --git a/zenstore/basicfile.cpp b/zenstore/basicfile.cpp index 1b6080379..895db6cee 100644 --- a/zenstore/basicfile.cpp +++ b/zenstore/basicfile.cpp @@ -75,7 +75,7 @@ BasicFile::Open(std::filesystem::path FileName, bool IsCreate, std::error_code& int OpenFlags = O_RDWR | O_CLOEXEC; OpenFlags |= IsCreate ? O_CREAT | O_TRUNC : 0; - int Fd = open(FileName.c_str(), OpenFlags); + int Fd = open(FileName.c_str(), OpenFlags, 0666); if (Fd < 0) { Ec = zen::MakeErrorCodeFromLastError(); @@ -370,7 +370,7 @@ LockFile::Create(std::filesystem::path FileName, CbObject Payload, std::error_co return; } #elif ZEN_PLATFORM_LINUX || ZEN_PLATFORM_MAC - int Fd = open(FileName.c_str(), O_RDWR | O_CREAT | O_CLOEXEC); + int Fd = open(FileName.c_str(), O_RDWR | O_CREAT | O_CLOEXEC, 0666); if (Fd < 0) { Ec = zen::MakeErrorCodeFromLastError(); diff --git a/zenstore/filecas.cpp b/zenstore/filecas.cpp index 5c7edef29..758c0665b 100644 --- a/zenstore/filecas.cpp +++ b/zenstore/filecas.cpp @@ -389,7 +389,7 @@ FileCasStrategy::InsertChunk(const void* const ChunkData, const size_t ChunkSize #else // Attempt to exclusively create the file. auto InternalCreateFile = [&] { - int Fd = open(Name.ShardedPath.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC); + int Fd = open(Name.ShardedPath.c_str(), O_WRONLY | O_CREAT | O_EXCL | O_CLOEXEC, 0666); if (Fd >= 0) { fchmod(Fd, 0666); |