refactor
This commit is contained in:
parent
bcccc5c4b8
commit
add21a5608
@ -39,8 +39,6 @@
|
||||
#include "utils/base64.hpp"
|
||||
#include "utils/path.hpp"
|
||||
|
||||
#define REPERTORY_DIRECTORY_PAGE_SIZE std::size_t(100U)
|
||||
|
||||
namespace repertory {
|
||||
template <typename drive>
|
||||
class remote_server_base : public remote_open_file_table,
|
||||
@ -153,30 +151,6 @@ private:
|
||||
return this->handle_fuse_destroy();
|
||||
},
|
||||
},
|
||||
/*handlerLookup_.insert({"::fuse_fallocate",
|
||||
[this](std::uint32_t serviceFlags, const
|
||||
std::string &client_id, std::uint64_t threadId, const std::string
|
||||
&method, packet *request, packet &response) -> packet::error_type {
|
||||
auto ret{0};
|
||||
|
||||
std::string path;
|
||||
DECODE_OR_RETURN(request, path);
|
||||
|
||||
std::int32_t mode;
|
||||
DECODE_OR_RETURN(request, mode);
|
||||
|
||||
remote::file_offset offset;
|
||||
DECODE_OR_RETURN(request, offset);
|
||||
|
||||
remote::file_offset length;
|
||||
DECODE_OR_RETURN(request, length);
|
||||
|
||||
remote::file_handle handle;
|
||||
DECODE_OR_RETURN(request, handle);
|
||||
|
||||
return this->fuse_fallocate(path.c_str(), mode,
|
||||
offset, length, handle);
|
||||
}});*/
|
||||
{
|
||||
"::fuse_fgetattr",
|
||||
[this](auto && /* service_flags */, auto && /* client_id */,
|
||||
@ -217,45 +191,6 @@ private:
|
||||
return this->handle_fuse_getattr(request, response);
|
||||
},
|
||||
},
|
||||
/*handlerLookup_.insert({"::fuse_getxattr",
|
||||
[this](std::uint32_t serviceFlags, const
|
||||
std::string &client_id, std::uint64_t threadId, const std::string
|
||||
&method, packet *request, packet &response) -> packet::error_type { auto
|
||||
ret{0};
|
||||
|
||||
std::string path;
|
||||
DECODE_OR_RETURN(request, path);
|
||||
|
||||
std::string name;
|
||||
DECODE_OR_RETURN(request, name);
|
||||
|
||||
remote::file_size size;
|
||||
DECODE_OR_RETURN(request, size);
|
||||
|
||||
return this->fuse_getxattr(path.c_str(),
|
||||
&name[0], nullptr, size);
|
||||
}});
|
||||
handlerLookup_.insert({"::fuse_getxattr_osx",
|
||||
[this](std::uint32_t serviceFlags, const
|
||||
std::string &client_id, std::uint64_t threadId, const std::string
|
||||
&method, packet *request, packet &response) -> packet::error_type { auto
|
||||
ret{0};
|
||||
|
||||
std::string path;
|
||||
DECODE_OR_RETURN(request, path);
|
||||
|
||||
std::string name;
|
||||
DECODE_OR_RETURN(request, name);
|
||||
|
||||
remote::file_size size;
|
||||
DECODE_OR_RETURN(request, size);
|
||||
|
||||
std::uint32_t position;
|
||||
DECODE_OR_RETURN(request, position);
|
||||
|
||||
return this->fuse_getxattr_osx(path.c_str(),
|
||||
&name[0], nullptr, size, position);
|
||||
}});*/
|
||||
{
|
||||
"::fuse_getxtimes",
|
||||
[this](auto && /* service_flags */, auto && /* client_id */,
|
||||
@ -272,21 +207,6 @@ private:
|
||||
return this->handle_fuse_init();
|
||||
},
|
||||
},
|
||||
/*handlerLookup_.insert({"::remote_fuseListxattr",
|
||||
[this](std::uint32_t serviceFlags, const
|
||||
std::string &client_id, std::uint64_t threadId, const std::string
|
||||
&method, packet *request, packet &response) -> packet::error_type {
|
||||
auto ret{0};
|
||||
|
||||
std::string path;
|
||||
DECODE_OR_RETURN(request, path);
|
||||
|
||||
remote::file_size size;
|
||||
DECODE_OR_RETURN(request, size);
|
||||
|
||||
return this->fuse_listxattr(path.c_str(),
|
||||
nullptr, size);
|
||||
}});*/
|
||||
{
|
||||
"::fuse_mkdir",
|
||||
[this](auto && /* service_flags */, auto && /* client_id */,
|
||||
@ -343,21 +263,6 @@ private:
|
||||
return this->handle_fuse_releasedir(client_id, request);
|
||||
},
|
||||
},
|
||||
/*handlerLookup_.insert({"::fuse_removexattr",
|
||||
[this](std::uint32_t serviceFlags, const
|
||||
std::string &client_id, std::uint64_t threadId, const std::string
|
||||
&method, packet *request, packet &response) -> packet::error_type {
|
||||
auto ret{0};
|
||||
|
||||
std::string path;
|
||||
DECODE_OR_RETURN(request, path);
|
||||
|
||||
std::string name;
|
||||
DECODE_OR_RETURN(request, name);
|
||||
|
||||
return this->fuse_removexattr(path.c_str(),
|
||||
&name[0]);
|
||||
}});*/
|
||||
{
|
||||
"::fuse_rename",
|
||||
[this](auto && /* service_flags */, auto && /* client_id */,
|
||||
@ -414,67 +319,6 @@ private:
|
||||
return this->handle_fuse_setvolname(request);
|
||||
},
|
||||
},
|
||||
/*handlerLookup_.insert({"::fuse_setxattr",
|
||||
[this](std::uint32_t serviceFlags, const
|
||||
std::string &client_id, std::uint64_t threadId, const std::string
|
||||
&method, packet *request, packet &response) -> packet::error_type { auto
|
||||
ret{0};
|
||||
|
||||
std::string path;
|
||||
DECODE_OR_RETURN(request, path);
|
||||
|
||||
std::string name;
|
||||
DECODE_OR_RETURN(request, name);
|
||||
|
||||
remote::file_size size;
|
||||
DECODE_OR_RETURN(request, size);
|
||||
|
||||
if (size >
|
||||
std::numeric_limits<std::size_t>::max()) { return -ERANGE;
|
||||
}
|
||||
|
||||
data_buffer
|
||||
value(static_cast<std::size_t>(size)); ret = request->Decode(&value[0],
|
||||
value.size()); if (ret == 0) { std::int32_t flags;
|
||||
DECODE_OR_RETURN(request, flags);
|
||||
|
||||
ret = this->fuse_setxattr(path.c_str(),
|
||||
&name[0], &value[0], size, flags);
|
||||
}
|
||||
return ret;
|
||||
}});
|
||||
handlerLookup_.insert({"::fuse_setxattr_osx",
|
||||
[this](std::uint32_t serviceFlags, const
|
||||
std::string &client_id, std::uint64_t threadId, const std::string
|
||||
&method, packet *request, packet &response) -> packet::error_type { auto
|
||||
ret{0};
|
||||
|
||||
std::string path;
|
||||
DECODE_OR_RETURN(request, path);
|
||||
|
||||
std::string name;
|
||||
DECODE_OR_RETURN(request, name);
|
||||
|
||||
remote::file_size size;
|
||||
DECODE_OR_RETURN(request, size);
|
||||
|
||||
if (size >
|
||||
std::numeric_limits<std::size_t>::max()) { return -ERANGE;
|
||||
}
|
||||
|
||||
data_buffer
|
||||
value(static_cast<std::size_t>(size)); ret = request->Decode(&value[0],
|
||||
value.size()); if (ret == 0) { std::int32_t flags;
|
||||
DECODE_OR_RETURN(request, flags);
|
||||
|
||||
std::uint32_t position;
|
||||
DECODE_OR_RETURN(request, position);
|
||||
|
||||
ret = this->fuse_setxattr_osx(path.c_str(),
|
||||
&name[0], &value[0], size, flags, position);
|
||||
}
|
||||
return ret;
|
||||
}});*/
|
||||
{
|
||||
"::fuse_statfs",
|
||||
[this](auto && /* service_flags */, auto && /* client_id */,
|
||||
@ -1792,3 +1636,158 @@ protected:
|
||||
} // namespace repertory
|
||||
|
||||
#endif // REPERTORY_INCLUDE_DRIVES_REMOTE_REMOTE_SERVER_BASE_HPP_
|
||||
|
||||
/*handlerLookup_.insert({"::fuse_fallocate",
|
||||
[this](std::uint32_t serviceFlags, const
|
||||
std::string &client_id, std::uint64_t threadId, const std::string
|
||||
&method, packet *request, packet &response) -> packet::error_type {
|
||||
auto ret{0};
|
||||
|
||||
std::string path;
|
||||
DECODE_OR_RETURN(request, path);
|
||||
|
||||
std::int32_t mode;
|
||||
DECODE_OR_RETURN(request, mode);
|
||||
|
||||
remote::file_offset offset;
|
||||
DECODE_OR_RETURN(request, offset);
|
||||
|
||||
remote::file_offset length;
|
||||
DECODE_OR_RETURN(request, length);
|
||||
|
||||
remote::file_handle handle;
|
||||
DECODE_OR_RETURN(request, handle);
|
||||
|
||||
return this->fuse_fallocate(path.c_str(), mode,
|
||||
offset, length, handle);
|
||||
}});*/
|
||||
/*handlerLookup_.insert({"::fuse_getxattr",
|
||||
[this](std::uint32_t serviceFlags, const
|
||||
std::string &client_id, std::uint64_t threadId, const std::string
|
||||
&method, packet *request, packet &response) -> packet::error_type { auto
|
||||
ret{0};
|
||||
|
||||
std::string path;
|
||||
DECODE_OR_RETURN(request, path);
|
||||
|
||||
std::string name;
|
||||
DECODE_OR_RETURN(request, name);
|
||||
|
||||
remote::file_size size;
|
||||
DECODE_OR_RETURN(request, size);
|
||||
|
||||
return this->fuse_getxattr(path.c_str(),
|
||||
&name[0], nullptr, size);
|
||||
}});
|
||||
handlerLookup_.insert({"::fuse_getxattr_osx",
|
||||
[this](std::uint32_t serviceFlags, const
|
||||
std::string &client_id, std::uint64_t threadId, const std::string
|
||||
&method, packet *request, packet &response) -> packet::error_type { auto
|
||||
ret{0};
|
||||
|
||||
std::string path;
|
||||
DECODE_OR_RETURN(request, path);
|
||||
|
||||
std::string name;
|
||||
DECODE_OR_RETURN(request, name);
|
||||
|
||||
remote::file_size size;
|
||||
DECODE_OR_RETURN(request, size);
|
||||
|
||||
std::uint32_t position;
|
||||
DECODE_OR_RETURN(request, position);
|
||||
|
||||
return this->fuse_getxattr_osx(path.c_str(),
|
||||
&name[0], nullptr, size, position);
|
||||
}});*/
|
||||
/*handlerLookup_.insert({"::remote_fuseListxattr",
|
||||
[this](std::uint32_t serviceFlags, const
|
||||
std::string &client_id, std::uint64_t threadId, const std::string
|
||||
&method, packet *request, packet &response) -> packet::error_type {
|
||||
auto ret{0};
|
||||
|
||||
std::string path;
|
||||
DECODE_OR_RETURN(request, path);
|
||||
|
||||
remote::file_size size;
|
||||
DECODE_OR_RETURN(request, size);
|
||||
|
||||
return this->fuse_listxattr(path.c_str(),
|
||||
nullptr, size);
|
||||
}});*/
|
||||
/*handlerLookup_.insert({"::fuse_removexattr",
|
||||
[this](std::uint32_t serviceFlags, const
|
||||
std::string &client_id, std::uint64_t threadId, const std::string
|
||||
&method, packet *request, packet &response) -> packet::error_type {
|
||||
auto ret{0};
|
||||
|
||||
std::string path;
|
||||
DECODE_OR_RETURN(request, path);
|
||||
|
||||
std::string name;
|
||||
DECODE_OR_RETURN(request, name);
|
||||
|
||||
return this->fuse_removexattr(path.c_str(),
|
||||
&name[0]);
|
||||
}});*/
|
||||
/*handlerLookup_.insert({"::fuse_setxattr",
|
||||
[this](std::uint32_t serviceFlags, const
|
||||
std::string &client_id, std::uint64_t threadId, const std::string
|
||||
&method, packet *request, packet &response) -> packet::error_type { auto
|
||||
ret{0};
|
||||
|
||||
std::string path;
|
||||
DECODE_OR_RETURN(request, path);
|
||||
|
||||
std::string name;
|
||||
DECODE_OR_RETURN(request, name);
|
||||
|
||||
remote::file_size size;
|
||||
DECODE_OR_RETURN(request, size);
|
||||
|
||||
if (size >
|
||||
std::numeric_limits<std::size_t>::max()) { return -ERANGE;
|
||||
}
|
||||
|
||||
data_buffer
|
||||
value(static_cast<std::size_t>(size)); ret = request->Decode(&value[0],
|
||||
value.size()); if (ret == 0) { std::int32_t flags;
|
||||
DECODE_OR_RETURN(request, flags);
|
||||
|
||||
ret = this->fuse_setxattr(path.c_str(),
|
||||
&name[0], &value[0], size, flags);
|
||||
}
|
||||
return ret;
|
||||
}});
|
||||
handlerLookup_.insert({"::fuse_setxattr_osx",
|
||||
[this](std::uint32_t serviceFlags, const
|
||||
std::string &client_id, std::uint64_t threadId, const std::string
|
||||
&method, packet *request, packet &response) -> packet::error_type { auto
|
||||
ret{0};
|
||||
|
||||
std::string path;
|
||||
DECODE_OR_RETURN(request, path);
|
||||
|
||||
std::string name;
|
||||
DECODE_OR_RETURN(request, name);
|
||||
|
||||
remote::file_size size;
|
||||
DECODE_OR_RETURN(request, size);
|
||||
|
||||
if (size >
|
||||
std::numeric_limits<std::size_t>::max()) { return -ERANGE;
|
||||
}
|
||||
|
||||
data_buffer
|
||||
value(static_cast<std::size_t>(size)); ret = request->Decode(&value[0],
|
||||
value.size()); if (ret == 0) { std::int32_t flags;
|
||||
DECODE_OR_RETURN(request, flags);
|
||||
|
||||
std::uint32_t position;
|
||||
DECODE_OR_RETURN(request, position);
|
||||
|
||||
ret = this->fuse_setxattr_osx(path.c_str(),
|
||||
&name[0], &value[0], size, flags, position);
|
||||
}
|
||||
return ret;
|
||||
}});*/
|
||||
|
@ -33,6 +33,7 @@ inline constexpr const auto PACKET_SERVICE_FLAGS{PACKET_SERVICE_WINFSP};
|
||||
inline constexpr const auto PACKET_SERVICE_FLAGS{PACKET_SERVICE_FUSE};
|
||||
#endif // defined(_WIN32)
|
||||
|
||||
constexpr const auto default_remote_directory_page_size{std::size_t(100U)};
|
||||
constexpr const auto default_remote_client_pool_size{20U};
|
||||
constexpr const auto default_remote_max_connections{20U};
|
||||
constexpr const auto default_remote_receive_timeout_ms{120U * 1000U};
|
||||
@ -217,8 +218,8 @@ struct statfs_x final : public statfs {
|
||||
#if !defined(_WIN32)
|
||||
[[nodiscard]] auto create_open_flags(std::uint32_t flags) -> open_flags;
|
||||
|
||||
[[nodiscard]] auto
|
||||
create_os_open_flags(const open_flags &flags) -> std::uint32_t;
|
||||
[[nodiscard]] auto create_os_open_flags(const open_flags &flags)
|
||||
-> std::uint32_t;
|
||||
#endif // !defined(_WIN32)
|
||||
} // namespace repertory::remote
|
||||
|
||||
|
@ -1655,7 +1655,7 @@ auto remote_server::json_create_directory_snapshot(const std::string &path,
|
||||
json_data["handle"] = handle;
|
||||
json_data["path"] = path;
|
||||
json_data["page_count"] = utils::divide_with_ceiling(
|
||||
iter->get_count(), REPERTORY_DIRECTORY_PAGE_SIZE);
|
||||
iter->get_count(), default_remote_directory_page_size);
|
||||
res = 0;
|
||||
errno = 0;
|
||||
}
|
||||
@ -1677,17 +1677,18 @@ auto remote_server::json_read_directory_snapshot(
|
||||
if (iter != nullptr) {
|
||||
std::size_t offset{};
|
||||
json item_json;
|
||||
while (
|
||||
(json_data["directory_list"].size() < REPERTORY_DIRECTORY_PAGE_SIZE) &&
|
||||
(res = iter->get_json((page * REPERTORY_DIRECTORY_PAGE_SIZE) + offset++,
|
||||
item_json)) == 0) {
|
||||
while ((json_data["directory_list"].size() <
|
||||
default_remote_directory_page_size) &&
|
||||
(res = iter->get_json((page * default_remote_directory_page_size) +
|
||||
offset++,
|
||||
item_json)) == 0) {
|
||||
json_data["directory_list"].emplace_back(item_json);
|
||||
}
|
||||
json_data["handle"] = handle;
|
||||
json_data["path"] = path;
|
||||
json_data["page"] = page;
|
||||
json_data["page_count"] = utils::divide_with_ceiling(
|
||||
iter->get_count(), REPERTORY_DIRECTORY_PAGE_SIZE);
|
||||
iter->get_count(), default_remote_directory_page_size);
|
||||
}
|
||||
|
||||
auto ret = ((res < 0) ? -errno : 0);
|
||||
|
@ -855,7 +855,7 @@ auto remote_server::json_create_directory_snapshot(const std::string &path,
|
||||
json_data["path"] = path;
|
||||
json_data["handle"] = handle;
|
||||
json_data["page_count"] = utils::divide_with_ceiling(
|
||||
iter->get_count(), REPERTORY_DIRECTORY_PAGE_SIZE);
|
||||
iter->get_count(), default_remote_directory_page_size);
|
||||
res = 0;
|
||||
errno = 0;
|
||||
}
|
||||
@ -877,17 +877,18 @@ auto remote_server::json_read_directory_snapshot(
|
||||
if (iter != nullptr) {
|
||||
std::size_t offset{};
|
||||
json item_json;
|
||||
while (
|
||||
(json_data["directory_list"].size() < REPERTORY_DIRECTORY_PAGE_SIZE) &&
|
||||
(res = iter->get_json((page * REPERTORY_DIRECTORY_PAGE_SIZE) + offset++,
|
||||
item_json)) == 0) {
|
||||
while ((json_data["directory_list"].size() <
|
||||
default_remote_directory_page_size) &&
|
||||
(res = iter->get_json((page * default_remote_directory_page_size) +
|
||||
offset++,
|
||||
item_json)) == 0) {
|
||||
json_data["directory_list"].emplace_back(item_json);
|
||||
}
|
||||
json_data["handle"] = handle;
|
||||
json_data["path"] = path;
|
||||
json_data["page"] = page;
|
||||
json_data["page_count"] = utils::divide_with_ceiling(
|
||||
iter->get_count(), REPERTORY_DIRECTORY_PAGE_SIZE);
|
||||
iter->get_count(), default_remote_directory_page_size);
|
||||
}
|
||||
|
||||
auto ret = ((res < 0) ? -errno : 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user