remote fixes
This commit is contained in:
@ -33,25 +33,32 @@ protected:
|
||||
virtual ~remote_open_file_table() = default;
|
||||
|
||||
protected:
|
||||
struct compat_open_info {
|
||||
std::size_t count{0U};
|
||||
struct compat_open_info final {
|
||||
std::string client_id;
|
||||
std::vector<remote::file_handle> handles;
|
||||
std::string path;
|
||||
};
|
||||
|
||||
struct open_info {
|
||||
std::size_t count{0U};
|
||||
struct open_info final {
|
||||
std::string client_id;
|
||||
PVOID directory_buffer{nullptr};
|
||||
std::vector<native_handle> handles;
|
||||
std::string path;
|
||||
};
|
||||
|
||||
private:
|
||||
std::unordered_map<remote::file_handle, compat_open_info> compat_lookup_;
|
||||
std::recursive_mutex compat_mutex_;
|
||||
std::unordered_map<std::string, std::unique_ptr<compat_open_info>>
|
||||
compat_file_lookup_;
|
||||
std::unordered_map<remote::file_handle, std::string> compat_handle_lookup_;
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, std::vector<std::uint64_t>> directory_lookup_;
|
||||
std::recursive_mutex directory_mutex_;
|
||||
std::unordered_map<native_handle, open_info> file_lookup_;
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, std::unique_ptr<open_info>> file_lookup_;
|
||||
std::unordered_map<native_handle, std::string> handle_lookup_;
|
||||
|
||||
private:
|
||||
mutable std::recursive_mutex file_mutex_;
|
||||
|
||||
protected:
|
||||
@ -64,11 +71,11 @@ protected:
|
||||
PVOID *&buffer) -> bool;
|
||||
#endif // _WIN32
|
||||
|
||||
[[nodiscard]] auto
|
||||
get_open_file_path(const native_handle &handle) -> std::string;
|
||||
[[nodiscard]] auto get_open_file_path(const native_handle &handle)
|
||||
-> std::string;
|
||||
|
||||
[[nodiscard]] auto get_open_info(const native_handle &handle,
|
||||
open_info &oi) -> bool;
|
||||
[[nodiscard]] auto get_open_info(const native_handle &handle, open_info &oi)
|
||||
-> bool;
|
||||
|
||||
[[nodiscard]] auto has_open_directory(const std::string &client_id,
|
||||
std::uint64_t handle) -> bool;
|
||||
@ -77,20 +84,21 @@ protected:
|
||||
int error_return) -> int;
|
||||
|
||||
template <typename error_type>
|
||||
[[nodiscard]] auto
|
||||
has_open_info(const native_handle &handle,
|
||||
const error_type &error_return) -> error_type {
|
||||
[[nodiscard]] auto has_open_info(const native_handle &handle,
|
||||
const error_type &error_return)
|
||||
-> error_type {
|
||||
recur_mutex_lock file_lock(file_mutex_);
|
||||
return ((file_lookup_.find(handle) == file_lookup_.end()) ? error_return
|
||||
: 0);
|
||||
return handle_lookup_.contains(handle) ? 0 : error_return;
|
||||
}
|
||||
|
||||
void remove_all(const std::string &file_path);
|
||||
|
||||
void remove_and_close_all(const native_handle &handle);
|
||||
|
||||
void remove_compat_open_info(const remote::file_handle &handle);
|
||||
|
||||
auto remove_directory(const std::string &client_id,
|
||||
std::uint64_t handle) -> bool;
|
||||
auto remove_directory(const std::string &client_id, std::uint64_t handle)
|
||||
-> bool;
|
||||
|
||||
void remove_open_info(const native_handle &handle);
|
||||
|
||||
@ -102,11 +110,11 @@ protected:
|
||||
void set_compat_open_info(const remote::file_handle &handle,
|
||||
const std::string &file_path);
|
||||
|
||||
void set_open_info(const native_handle &handle, open_info oi);
|
||||
void set_open_info(const native_handle &handle, open_info op_info);
|
||||
|
||||
public:
|
||||
[[nodiscard]] auto
|
||||
get_open_file_count(const std::string &file_path) const -> std::size_t;
|
||||
[[nodiscard]] auto get_open_file_count(const std::string &file_path) const
|
||||
-> std::size_t;
|
||||
};
|
||||
} // namespace repertory
|
||||
|
||||
|
@ -137,12 +137,12 @@ public:
|
||||
if (ret == STATUS_SUCCESS) {
|
||||
#if defined(_WIN32)
|
||||
this->set_client_id(file_desc, client_id);
|
||||
#else
|
||||
#else // !defined(_WIN32)
|
||||
this->set_client_id(
|
||||
static_cast<native_handle>(
|
||||
reinterpret_cast<std::uintptr_t>(file_desc)),
|
||||
client_id);
|
||||
#endif
|
||||
#endif // defined(_WIN32)
|
||||
response.encode(file_desc);
|
||||
response.encode(file_info);
|
||||
response.encode(normalized_name);
|
||||
@ -277,12 +277,12 @@ public:
|
||||
if (ret == STATUS_SUCCESS) {
|
||||
#if defined(_WIN32)
|
||||
this->set_client_id(file_desc, client_id);
|
||||
#else
|
||||
#else // !defined(_WIN32)
|
||||
this->set_client_id(
|
||||
static_cast<native_handle>(
|
||||
reinterpret_cast<std::uintptr_t>(file_desc)),
|
||||
client_id);
|
||||
#endif
|
||||
#endif // defined(_WIN32)
|
||||
response.encode(file_desc);
|
||||
response.encode(file_info);
|
||||
response.encode(normalized_name);
|
||||
@ -585,9 +585,9 @@ public:
|
||||
0) {
|
||||
#if defined(_WIN32)
|
||||
this->set_compat_client_id(handle, client_id);
|
||||
#else
|
||||
#else // !defined(_WIN32)
|
||||
this->set_client_id(static_cast<native_handle>(handle), client_id);
|
||||
#endif
|
||||
#endif // defined(_WIN32)
|
||||
response.encode(handle);
|
||||
}
|
||||
return ret;
|
||||
@ -841,9 +841,9 @@ public:
|
||||
if ((ret = this->fuse_open(path.c_str(), flags, handle)) >= 0) {
|
||||
#if defined(_WIN32)
|
||||
this->set_compat_client_id(handle, client_id);
|
||||
#else
|
||||
#else // !defined(_WIN32)
|
||||
this->set_client_id(static_cast<native_handle>(handle), client_id);
|
||||
#endif
|
||||
#endif // defined(_WIN32)
|
||||
response.encode(handle);
|
||||
}
|
||||
return ret;
|
||||
|
Reference in New Issue
Block a user