From 6a5ce475b80d697b130c912365cfc4c9d8e6fb7f Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Sun, 19 Nov 2017 16:44:06 +0300 Subject: [PATCH] Implement fs::unshare (linux) --- Utilities/File.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Utilities/File.cpp b/Utilities/File.cpp index 0511e9159d..da54fb7fd4 100644 --- a/Utilities/File.cpp +++ b/Utilities/File.cpp @@ -108,6 +108,7 @@ static fs::error to_error(DWORD e) #include #include #include +#include #include #include #include @@ -939,6 +940,13 @@ fs::file::file(const std::string& path, bs_t mode) return; } + if (test(mode & fs::unshare) && ::flock(fd, LOCK_EX | LOCK_NB) != 0) + { + g_tls_error = errno == EWOULDBLOCK ? fs::error::acces : to_error(errno); + ::close(fd); + return; + } + class unix_file final : public file_base, public get_native_handle { const int m_fd;