Implement fs::unshare (linux)

This commit is contained in:
Nekotekina 2017-11-19 16:44:06 +03:00
parent 3628a8593f
commit 6a5ce475b8

View file

@ -108,6 +108,7 @@ static fs::error to_error(DWORD e)
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/statvfs.h>
#include <sys/file.h>
#include <dirent.h>
#include <fcntl.h>
#include <libgen.h>
@ -939,6 +940,13 @@ fs::file::file(const std::string& path, bs_t<open_mode> 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;