diff --git a/repertory/librepertory/include/events/events.hpp b/repertory/librepertory/include/events/events.hpp deleted file mode 100644 index 988acdd5..00000000 --- a/repertory/librepertory/include/events/events.hpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - Copyright <2018-2025> - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. -*/ -#ifndef REPERTORY_INCLUDE_EVENTS_EVENTS_HPP_ -#define REPERTORY_INCLUDE_EVENTS_EVENTS_HPP_ -#if 0 - -#include "types/repertory.hpp" - -namespace repertory { -// clang-format off -//WINFSP -E_SIMPLE3(remote_winfsp_client_event, debug, - std::string, function, func, E_FROM_STRING, - std::string, api_path, ap, E_FROM_STRING, - packet::error_type, result, res, E_FROM_INT32 -); -E_SIMPLE3(remote_winfsp_server_event, debug, - std::string, function, FUNC, E_FROM_STRING, - std::string, api_path, AP, E_FROM_STRING, - packet::error_type, result, RES, E_FROM_INT32 -); - -//FUSE -E_SIMPLE3(fuse_event, debug, - std::string, function, func, E_FROM_STRING, - std::string, api_path, ap, E_FROM_STRING, - int, result, res, E_FROM_INT32 -); - -E_SIMPLE1(fuse_args_parsed, info, - std::string, arguments, args, E_FROM_STRING -); - -E_SIMPLE3(remote_fuse_server_event, debug, - std::string, function, func, E_FROM_STRING, - std::string, api_path, ap, E_FROM_STRING, - packet::error_type, result, res, E_FROM_INT32 -); -// clang-format on -} // namespace repertory - -#endif // 0 -#endif // REPERTORY_INCLUDE_EVENTS_EVENTS_HPP_ diff --git a/repertory/librepertory/include/events/types/fuse_args_parsed.hpp b/repertory/librepertory/include/events/types/fuse_args_parsed.hpp new file mode 100644 index 00000000..c38a71c2 --- /dev/null +++ b/repertory/librepertory/include/events/types/fuse_args_parsed.hpp @@ -0,0 +1,70 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_FUSE_ARGS_PARSED_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_FUSE_ARGS_PARSED_HPP_ +#if !defined(_WIN32) + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct fuse_args_parsed final : public i_event { + fuse_args_parsed() = default; + fuse_args_parsed(std::string_view args_, std::string_view function_name_) + : args(std::move(args_)), function_name(std::string{function_name_}) {} + + static constexpr const event_level level{event_level::info}; + static constexpr const std::string_view name{"fuse_args_parsed"}; + + std::string args; + std::string function_name; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return level; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|args|{}", name, function_name, args); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::fuse_args_parsed &value) { + data["args"] = value.args; + data["function_name"] = value.function_name; + } + + static void from_json(const json &data, repertory::fuse_args_parsed &value) { + data.at("args").get_to(value.args); + data.at("function_name").get_to(value.function_name); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // !defined(_WIN32) +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FUSE_ARGS_PARSED_HPP_ diff --git a/repertory/librepertory/include/events/types/fuse_event.hpp b/repertory/librepertory/include/events/types/fuse_event.hpp new file mode 100644 index 00000000..5f50c7fa --- /dev/null +++ b/repertory/librepertory/include/events/types/fuse_event.hpp @@ -0,0 +1,77 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_FUSE_EVENT_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_FUSE_EVENT_HPP_ +#if !defined(_WIN32) + +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct fuse_event final : public i_event { + fuse_event() = default; + fuse_event(std::string_view api_path_, std::int32_t error_, + std::string_view function_name_) + : api_path(std::string{api_path_}), + error(error_), + function_name(std::string{function_name_}) {} + + static constexpr const event_level level{event_level::debug}; + static constexpr const std::string_view name{"fuse_event"}; + + std::string api_path; + std::int32_t error{}; + std::string function_name; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return level; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|ap|{}|error|{}", name, function_name, + api_path, error); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::fuse_event &value) { + data["api_path"] = value.api_path; + data["error"] = value.error; + data["function_name"] = value.function_name; + } + + static void from_json(const json &data, repertory::fuse_event &value) { + data.at("api_path").get_to(value.api_path); + data.at("error").get_to(value.error); + data.at("function_name").get_to(value.function_name); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // !defined(_WIN32) +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_FUSE_EVENT_HPP_ diff --git a/repertory/librepertory/include/events/types/remote_server_event.hpp b/repertory/librepertory/include/events/types/remote_server_event.hpp new file mode 100644 index 00000000..bb5c847c --- /dev/null +++ b/repertory/librepertory/include/events/types/remote_server_event.hpp @@ -0,0 +1,77 @@ +/* + Copyright <2018-2025> + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +*/ +#ifndef REPERTORY_INCLUDE_EVENTS_TYPES_REMOTE_SERVER_EVENT_HPP_ +#define REPERTORY_INCLUDE_EVENTS_TYPES_REMOTE_SERVER_EVENT_HPP_ + +#include "comm/packet/packet.hpp" +#include "events/i_event.hpp" +#include "types/repertory.hpp" + +namespace repertory { +struct remote_server_event final : public i_event { + remote_server_event() = default; + remote_server_event(std::string api_path_, packet::error_type error_, + std::string_view function_name_) + : api_path(std::move(api_path_)), + error(error_), + function_name(std::string{function_name_}) {} + + static constexpr const event_level level{event_level::debug}; + static constexpr const std::string_view name{"remote_server_event"}; + + std::string api_path; + packet::error_type error{}; + std::string function_name; + + [[nodiscard]] auto get_event_level() const -> event_level override { + return level; + } + + [[nodiscard]] auto get_name() const -> std::string_view override { + return name; + } + + [[nodiscard]] auto get_single_line() const -> std::string override { + return fmt::format("{}|func|{}|ap|{}|error|{}", name, function_name, + api_path, error); + } +}; +} // namespace repertory + +NLOHMANN_JSON_NAMESPACE_BEGIN +template <> struct adl_serializer { + static void to_json(json &data, const repertory::remote_server_event &value) { + data["api_path"] = value.api_path; + data["error"] = value.error; + data["function_name"] = value.function_name; + } + + static void from_json(const json &data, + repertory::remote_server_event &value) { + data.at("api_path").get_to(value.api_path); + data.at("error").get_to(value.error); + data.at("function_name").get_to(value.function_name); + } +}; +NLOHMANN_JSON_NAMESPACE_END + +#endif // REPERTORY_INCLUDE_EVENTS_TYPES_REMOTE_SERVER_EVENT_HPP_ diff --git a/repertory/librepertory/src/drives/fuse/fuse_base.cpp b/repertory/librepertory/src/drives/fuse/fuse_base.cpp index 4d23999e..c28b9b6d 100644 --- a/repertory/librepertory/src/drives/fuse/fuse_base.cpp +++ b/repertory/librepertory/src/drives/fuse/fuse_base.cpp @@ -25,6 +25,8 @@ #include "app_config.hpp" #include "events/event_system.hpp" +#include "events/types/fuse_args_parsed.hpp" +#include "events/types/fuse_event.hpp" #include "events/types/unmount_requested.hpp" #include "events/types/unmount_result.hpp" #include "initialize.hpp" @@ -118,8 +120,8 @@ auto fuse_base::chflags_(const char *path, uint32_t flags) -> int { #endif // __APPLE__ #if FUSE_USE_VERSION >= 30 -auto fuse_base::chmod_(const char *path, mode_t mode, - struct fuse_file_info *fi) -> int { +auto fuse_base::chmod_(const char *path, mode_t mode, struct fuse_file_info *fi) + -> int { REPERTORY_USES_FUNCTION_NAME(); return instance().execute_callback( @@ -186,7 +188,7 @@ void fuse_base::display_options( #if FUSE_USE_VERSION >= 30 fuse_cmdline_help(); #else - struct fuse_operations fuse_ops {}; + struct fuse_operations fuse_ops{}; fuse_main(args.size(), reinterpret_cast(const_cast(args.data())), &fuse_ops, nullptr); @@ -196,7 +198,7 @@ void fuse_base::display_options( } void fuse_base::display_version_information(std::vector args) { - struct fuse_operations fuse_ops {}; + struct fuse_operations fuse_ops{}; fuse_main(static_cast(args.size()), reinterpret_cast(const_cast(args.data())), &fuse_ops, nullptr); @@ -334,8 +336,8 @@ auto fuse_base::getxtimes_(const char *path, struct timespec *bkuptime, #endif // __APPLE__ #if FUSE_USE_VERSION >= 30 -auto fuse_base::init_(struct fuse_conn_info *conn, - struct fuse_config *cfg) -> void * { +auto fuse_base::init_(struct fuse_conn_info *conn, struct fuse_config *cfg) + -> void * { REPERTORY_USES_FUNCTION_NAME(); return execute_void_pointer_callback(function_name, [&]() -> void * { @@ -408,7 +410,7 @@ auto fuse_base::mount(std::vector args) -> int { char *mount_location{nullptr}; #if FUSE_USE_VERSION >= 30 - struct fuse_cmdline_opts opts {}; + struct fuse_cmdline_opts opts{}; fuse_parse_cmdline(&fa, &opts); mount_location = opts.mountpoint; #else @@ -477,8 +479,8 @@ auto fuse_base::read_(const char *path, char *buffer, size_t read_size, #if FUSE_USE_VERSION >= 30 auto fuse_base::readdir_(const char *path, void *buf, fuse_fill_dir_t fuse_fill_dir, off_t offset, - struct fuse_file_info *fi, - fuse_readdir_flags flags) -> int { + struct fuse_file_info *fi, fuse_readdir_flags flags) + -> int { REPERTORY_USES_FUNCTION_NAME(); return instance().execute_callback( @@ -510,8 +512,8 @@ auto fuse_base::release_(const char *path, struct fuse_file_info *fi) -> int { }); } -auto fuse_base::releasedir_(const char *path, - struct fuse_file_info *fi) -> int { +auto fuse_base::releasedir_(const char *path, struct fuse_file_info *fi) + -> int { REPERTORY_USES_FUNCTION_NAME(); return instance().execute_callback( @@ -521,8 +523,8 @@ auto fuse_base::releasedir_(const char *path, } #if FUSE_USE_VERSION >= 30 -auto fuse_base::rename_(const char *from, const char *to, - unsigned int flags) -> int { +auto fuse_base::rename_(const char *from, const char *to, unsigned int flags) + -> int { REPERTORY_USES_FUNCTION_NAME(); return instance().execute_callback( @@ -601,12 +603,17 @@ auto fuse_base::listxattr_(const char *path, char *buffer, size_t size) -> int { } void fuse_base::notify_fuse_args_parsed(const std::vector &args) { - event_system::instance().raise(std::accumulate( - args.begin(), args.end(), std::string(), - [](auto &&command_line, auto &&arg) -> auto { - command_line += (command_line.empty() ? arg : (" " + std::string(arg))); - return command_line; - })); + REPERTORY_USES_FUNCTION_NAME(); + + event_system::instance().raise( + std::accumulate(args.begin(), args.end(), std::string(), + [](auto &&command_line, auto &&arg) -> auto { + command_line += + (command_line.empty() ? arg + : (" " + std::string(arg))); + return command_line; + }), + function_name); } auto fuse_base::parse_args(std::vector &args) -> int { @@ -701,7 +708,7 @@ void fuse_base::raise_fuse_event(std::string_view function_name, (config_.get_event_level() >= event_level::trace)) { std::string func{function_name}; event_system::instance().raise( - utils::string::right_trim(func, '_'), std::string{api_path}, ret); + api_path, ret, utils::string::right_trim(func, '_')); } } @@ -754,7 +761,7 @@ void fuse_base::shutdown() { auto res = unmount(get_mount_location()); event_system::instance().raise(function_name, - get_mount_location(), res); + get_mount_location(), res); } #if defined(__APPLE__) @@ -767,8 +774,8 @@ auto fuse_base::setattr_x_(const char *path, struct setattr_x *attr) -> int { }); } -auto fuse_base::setbkuptime_(const char *path, - const struct timespec *bkuptime) -> int { +auto fuse_base::setbkuptime_(const char *path, const struct timespec *bkuptime) + -> int { REPERTORY_USES_FUNCTION_NAME(); return instance().execute_callback( @@ -777,8 +784,8 @@ auto fuse_base::setbkuptime_(const char *path, }); } -auto fuse_base::setchgtime_(const char *path, - const struct timespec *chgtime) -> int { +auto fuse_base::setchgtime_(const char *path, const struct timespec *chgtime) + -> int { REPERTORY_USES_FUNCTION_NAME(); return instance().execute_callback( @@ -787,8 +794,8 @@ auto fuse_base::setchgtime_(const char *path, }); } -auto fuse_base::setcrtime_(const char *path, - const struct timespec *crtime) -> int { +auto fuse_base::setcrtime_(const char *path, const struct timespec *crtime) + -> int { REPERTORY_USES_FUNCTION_NAME(); return instance().execute_callback( diff --git a/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp b/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp index 29fc9413..0041d7a0 100644 --- a/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp +++ b/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp @@ -28,6 +28,7 @@ #include "drives/directory_iterator.hpp" #include "drives/remote/remote_open_file_table.hpp" #include "events/event_system.hpp" +#include "events/types/remote_server_event.hpp" #include "platform/platform.hpp" #include "types/remote.hpp" #include "types/repertory.hpp" @@ -40,11 +41,10 @@ namespace repertory::remote_fuse { #define RAISE_REMOTE_FUSE_SERVER_EVENT(func, file, ret) \ if (config_.get_enable_drive_events() && \ - (((config_.get_event_level() >= remote_fuse_server_event::level) && \ + (((config_.get_event_level() >= remote_server_event::level) && \ ((ret) < 0)) || \ (config_.get_event_level() >= event_level::trace))) \ - event_system::instance().raise(std::string{func}, \ - file, ret) + event_system::instance().raise(file, func, ret) remote_server::remote_server(app_config &config, i_fuse_drive &drive, const std::string &mount_location) @@ -200,8 +200,8 @@ auto remote_server::fuse_access(const char *path, const std::int32_t &mask) return ret; } -auto remote_server::fuse_chflags(const char *path, - std::uint32_t flags) -> packet::error_type { +auto remote_server::fuse_chflags(const char *path, std::uint32_t flags) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); const auto api_path = utils::path::create_api_path(path); @@ -313,9 +313,10 @@ length); ret = ((res < 0) ? -errno : 0); #endif return ret; }*/ -auto remote_server::fuse_fgetattr( - const char *path, remote::stat &r_stat, bool &directory, - const remote::file_handle &handle) -> packet::error_type { +auto remote_server::fuse_fgetattr(const char *path, remote::stat &r_stat, + bool &directory, + const remote::file_handle &handle) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); r_stat = {}; @@ -325,7 +326,7 @@ auto remote_server::fuse_fgetattr( auto res = has_open_info(static_cast(handle), EBADF); if (res == 0) { directory = utils::file::directory(file_path).exists(); - struct stat64 unix_st {}; + struct stat64 unix_st{}; res = fstat64(static_cast(handle), &unix_st); if (res == 0) { populate_stat(unix_st, r_stat); @@ -337,9 +338,10 @@ auto remote_server::fuse_fgetattr( return ret; } -auto remote_server::fuse_fsetattr_x( - const char *path, const remote::setattr_x &attr, - const remote::file_handle &handle) -> packet::error_type { +auto remote_server::fuse_fsetattr_x(const char *path, + const remote::setattr_x &attr, + const remote::file_handle &handle) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); const auto api_path = utils::path::create_api_path(path); @@ -455,9 +457,10 @@ auto remote_server::fuse_fsync(const char *path, const std::int32_t &datasync, return ret; } -auto remote_server::fuse_ftruncate( - const char *path, const remote::file_offset &size, - const remote::file_handle &handle) -> packet::error_type { +auto remote_server::fuse_ftruncate(const char *path, + const remote::file_offset &size, + const remote::file_handle &handle) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); const auto file_path = construct_path(path); @@ -485,7 +488,7 @@ auto remote_server::fuse_getattr(const char *path, remote::stat &r_stat, directory = utils::file::directory(file_path).exists(); - struct stat64 unix_st {}; + struct stat64 unix_st{}; auto res = stat64(file_path.c_str(), &unix_st); if (res == 0) { populate_stat(unix_st, r_stat); @@ -550,9 +553,10 @@ STATUS_NOT_IMPLEMENTED; #endif RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, file_path, ret); return ret; }*/ -auto remote_server::fuse_getxtimes( - const char *path, remote::file_time &bkuptime, - remote::file_time &crtime) -> packet::error_type { +auto remote_server::fuse_getxtimes(const char *path, + remote::file_time &bkuptime, + remote::file_time &crtime) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); const auto api_path = utils::path::create_api_path(path); @@ -657,10 +661,11 @@ auto remote_server::fuse_opendir(const char *path, remote::file_handle &handle) return ret; } -auto remote_server::fuse_read( - const char *path, char *buffer, const remote::file_size &read_size, - const remote::file_offset &read_offset, - const remote::file_handle &handle) -> packet::error_type { +auto remote_server::fuse_read(const char *path, char *buffer, + const remote::file_size &read_size, + const remote::file_offset &read_offset, + const remote::file_handle &handle) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); const auto file_path = construct_path(path); @@ -681,8 +686,8 @@ auto remote_server::fuse_read( return static_cast(ret); } -auto remote_server::fuse_rename(const char *from, - const char *to) -> packet::error_type { +auto remote_server::fuse_rename(const char *from, const char *to) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); const auto from_path = utils::path::combine(mount_location_, {from}); @@ -720,8 +725,9 @@ auto remote_server::fuse_readdir(const char *path, return ret; } -auto remote_server::fuse_release( - const char *path, const remote::file_handle &handle) -> packet::error_type { +auto remote_server::fuse_release(const char *path, + const remote::file_handle &handle) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); packet::error_type ret = 0; @@ -738,8 +744,9 @@ auto remote_server::fuse_release( return ret; } -auto remote_server::fuse_releasedir( - const char *path, const remote::file_handle &handle) -> packet::error_type { +auto remote_server::fuse_releasedir(const char *path, + const remote::file_handle &handle) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); const auto file_path = construct_path(path); @@ -784,8 +791,9 @@ auto remote_server::fuse_setattr_x(const char *path, remote::setattr_x &attr) return ret; } -auto remote_server::fuse_setbkuptime( - const char *path, const remote::file_time &bkuptime) -> packet::error_type { +auto remote_server::fuse_setbkuptime(const char *path, + const remote::file_time &bkuptime) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); const auto api_path = utils::path::create_api_path(path); @@ -804,8 +812,9 @@ auto remote_server::fuse_setbkuptime( return ret; } -auto remote_server::fuse_setchgtime( - const char *path, const remote::file_time &chgtime) -> packet::error_type { +auto remote_server::fuse_setchgtime(const char *path, + const remote::file_time &chgtime) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); const auto api_path = utils::path::create_api_path(path); @@ -824,8 +833,9 @@ auto remote_server::fuse_setchgtime( return ret; } -auto remote_server::fuse_setcrtime( - const char *path, const remote::file_time &crtime) -> packet::error_type { +auto remote_server::fuse_setcrtime(const char *path, + const remote::file_time &crtime) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); const auto api_path = utils::path::create_api_path(path); @@ -916,8 +926,9 @@ auto remote_server::fuse_statfs_x(const char *path, std::uint64_t bsize, return 0; } -auto remote_server::fuse_truncate( - const char *path, const remote::file_offset &size) -> packet::error_type { +auto remote_server::fuse_truncate(const char *path, + const remote::file_offset &size) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); const auto file_path = construct_path(path); @@ -938,8 +949,8 @@ auto remote_server::fuse_unlink(const char *path) -> packet::error_type { } auto remote_server::fuse_utimens(const char *path, const remote::file_time *tv, - std::uint64_t op0, - std::uint64_t op1) -> packet::error_type { + std::uint64_t op0, std::uint64_t op1) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); const auto file_path = construct_path(path); @@ -966,10 +977,11 @@ auto remote_server::fuse_utimens(const char *path, const remote::file_time *tv, return ret; } -auto remote_server::fuse_write( - const char *path, const char *buffer, const remote::file_size &write_size, - const remote::file_offset &write_offset, - const remote::file_handle &handle) -> packet::error_type { +auto remote_server::fuse_write(const char *path, const char *buffer, + const remote::file_size &write_size, + const remote::file_offset &write_offset, + const remote::file_handle &handle) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); const auto file_path = construct_path(path); @@ -999,8 +1011,8 @@ auto remote_server::fuse_write_base64( } // WinFSP Layer -auto remote_server::winfsp_can_delete(PVOID file_desc, - PWSTR file_name) -> packet::error_type { +auto remote_server::winfsp_can_delete(PVOID file_desc, PWSTR file_name) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); const auto relative_path = utils::string::to_utf8(file_name); @@ -1025,8 +1037,8 @@ auto remote_server::winfsp_can_delete(PVOID file_desc, } auto remote_server::winfsp_cleanup(PVOID /*file_desc*/, PWSTR file_name, - UINT32 flags, - BOOLEAN &was_deleted) -> packet::error_type { + UINT32 flags, BOOLEAN &was_deleted) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); const auto relative_path = utils::string::to_utf8(file_name); @@ -1103,8 +1115,8 @@ auto remote_server::winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access, UINT32 attributes, UINT64 /*allocation_size*/, PVOID *file_desc, remote::file_info *file_info, - std::string &normalized_name, - BOOLEAN &exists) -> packet::error_type { + std::string &normalized_name, BOOLEAN &exists) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); const auto relative_path = utils::string::to_utf8(file_name); @@ -1176,8 +1188,9 @@ auto remote_server::winfsp_flush(PVOID file_desc, remote::file_info *file_info) return ret; } -auto remote_server::winfsp_get_file_info( - PVOID file_desc, remote::file_info *file_info) -> packet::error_type { +auto remote_server::winfsp_get_file_info(PVOID file_desc, + remote::file_info *file_info) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); const auto handle = reinterpret_cast(file_desc); @@ -1220,9 +1233,10 @@ auto remote_server::winfsp_get_security_by_name( return ret; } -auto remote_server::winfsp_get_volume_info( - UINT64 &total_size, UINT64 &free_size, - std::string &volume_label) -> packet::error_type { +auto remote_server::winfsp_get_volume_info(UINT64 &total_size, + UINT64 &free_size, + std::string &volume_label) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); drive_.get_volume_info(total_size, free_size, volume_label); @@ -1239,10 +1253,11 @@ auto remote_server::winfsp_mounted(const std::wstring &location) return STATUS_SUCCESS; } -auto remote_server::winfsp_open( - PWSTR file_name, UINT32 create_options, UINT32 granted_access, - PVOID *file_desc, remote::file_info *file_info, - std::string &normalized_name) -> packet::error_type { +auto remote_server::winfsp_open(PWSTR file_name, UINT32 create_options, + UINT32 granted_access, PVOID *file_desc, + remote::file_info *file_info, + std::string &normalized_name) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); const auto relative_path = utils::string::to_utf8(file_name); @@ -1283,10 +1298,11 @@ auto remote_server::winfsp_open( return ret; } -auto remote_server::winfsp_overwrite( - PVOID file_desc, UINT32 attributes, BOOLEAN replace_attributes, - UINT64 /*allocation_size*/, - remote::file_info *file_info) -> packet::error_type { +auto remote_server::winfsp_overwrite(PVOID file_desc, UINT32 attributes, + BOOLEAN replace_attributes, + UINT64 /*allocation_size*/, + remote::file_info *file_info) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); const auto handle = reinterpret_cast(file_desc); @@ -1402,9 +1418,10 @@ auto remote_server::winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/, return ret; } -auto remote_server::winfsp_rename( - PVOID /*file_desc*/, PWSTR file_name, PWSTR new_file_name, - BOOLEAN replace_if_exists) -> packet::error_type { +auto remote_server::winfsp_rename(PVOID /*file_desc*/, PWSTR file_name, + PWSTR new_file_name, + BOOLEAN replace_if_exists) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); const auto relative_path = utils::string::to_utf8(file_name); @@ -1498,9 +1515,10 @@ auto remote_server::winfsp_set_basic_info( return ret; } -auto remote_server::winfsp_set_file_size( - PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size, - remote::file_info *file_info) -> packet::error_type { +auto remote_server::winfsp_set_file_size(PVOID file_desc, UINT64 new_size, + BOOLEAN set_allocation_size, + remote::file_info *file_info) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); const auto handle = reinterpret_cast(file_desc); @@ -1536,10 +1554,12 @@ auto remote_server::winfsp_unmounted(const std::wstring &location) return STATUS_SUCCESS; } -auto remote_server::winfsp_write( - PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, - BOOLEAN write_to_end, BOOLEAN constrained_io, PUINT32 bytes_transferred, - remote::file_info *file_info) -> packet::error_type { +auto remote_server::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, + UINT32 length, BOOLEAN write_to_end, + BOOLEAN constrained_io, + PUINT32 bytes_transferred, + remote::file_info *file_info) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); *bytes_transferred = 0; @@ -1587,8 +1607,9 @@ auto remote_server::winfsp_write( return ret; } -auto remote_server::json_create_directory_snapshot( - const std::string &path, json &json_data) -> packet::error_type { +auto remote_server::json_create_directory_snapshot(const std::string &path, + json &json_data) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); const auto api_path = utils::path::create_api_path(path); @@ -1647,8 +1668,8 @@ auto remote_server::json_read_directory_snapshot( } auto remote_server::json_release_directory_snapshot( - const std::string &path, - const remote::file_handle &handle) -> packet::error_type { + const std::string &path, const remote::file_handle &handle) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); const auto file_path = construct_path(path); diff --git a/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_client.cpp b/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_client.cpp index b5cc2c4b..0b9737a3 100644 --- a/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_client.cpp +++ b/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_client.cpp @@ -32,19 +32,11 @@ #include "version.hpp" namespace repertory::remote_winfsp { -#define RAISE_REMOTE_WINFSP_CLIENT_EVENT(func, file, ret) \ - if (config_.get_enable_drive_events() && \ - (((config_.get_event_level() >= remote_winfsp_client_event::level) && \ - ((ret) != STATUS_SUCCESS)) || \ - (config_.get_event_level() >= event_level::trace))) \ - event_system::instance().raise( \ - std::string{func}, file, ret) - remote_client::remote_client(const app_config &config) : config_(config), packet_client_(config.get_remote_config()) {} -auto remote_client::winfsp_can_delete(PVOID file_desc, - PWSTR file_name) -> packet::error_type { +auto remote_client::winfsp_can_delete(PVOID file_desc, PWSTR file_name) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); packet request; @@ -56,14 +48,12 @@ auto remote_client::winfsp_can_delete(PVOID file_desc, packet_client_.send(function_name, request, service_flags), }; - RAISE_REMOTE_WINFSP_CLIENT_EVENT( - function_name, - utils::path::create_api_path(utils::string::to_utf8(file_name)), ret); return ret; } -auto remote_client::json_create_directory_snapshot( - const std::string &path, json &json_data) -> packet::error_type { +auto remote_client::json_create_directory_snapshot(const std::string &path, + json &json_data) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); packet request; @@ -78,7 +68,6 @@ auto remote_client::json_create_directory_snapshot( ret = packet::decode_json(response, json_data); } - RAISE_REMOTE_WINFSP_CLIENT_EVENT(function_name, path, ret); return ret; } @@ -101,13 +90,12 @@ auto remote_client::json_read_directory_snapshot( ret = packet::decode_json(response, json_data); } - RAISE_REMOTE_WINFSP_CLIENT_EVENT(function_name, path, ret); return ret; } auto remote_client::json_release_directory_snapshot( - const std::string &path, - const remote::file_handle &handle) -> packet::error_type { + const std::string &path, const remote::file_handle &handle) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); packet request; @@ -119,13 +107,12 @@ auto remote_client::json_release_directory_snapshot( packet_client_.send(function_name, request, service_flags), }; - RAISE_REMOTE_WINFSP_CLIENT_EVENT(function_name, path, ret); return ret; } auto remote_client::winfsp_cleanup(PVOID file_desc, PWSTR file_name, - UINT32 flags, - BOOLEAN &was_deleted) -> packet::error_type { + UINT32 flags, BOOLEAN &was_deleted) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); auto handle{ @@ -154,7 +141,6 @@ auto remote_client::winfsp_cleanup(PVOID file_desc, PWSTR file_name, remove_all(file_path); } - RAISE_REMOTE_WINFSP_CLIENT_EVENT(function_name, file_path, ret); return ret; } @@ -179,7 +165,6 @@ auto remote_client::winfsp_close(PVOID file_desc) -> packet::error_type { if ((ret == STATUS_SUCCESS) || (ret == static_cast(STATUS_INVALID_HANDLE))) { remove_open_info(handle); - RAISE_REMOTE_WINFSP_CLIENT_EVENT(function_name, file_path, ret); } } @@ -190,8 +175,8 @@ auto remote_client::winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access, UINT32 attributes, UINT64 allocation_size, PVOID *file_desc, remote::file_info *file_info, - std::string &normalized_name, - BOOLEAN &exists) -> packet::error_type { + std::string &normalized_name, BOOLEAN &exists) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); packet request; @@ -230,8 +215,6 @@ auto remote_client::winfsp_create(PWSTR file_name, UINT32 create_options, } } - RAISE_REMOTE_WINFSP_CLIENT_EVENT( - function_name, get_open_file_path(to_handle(*file_desc)), ret); return ret; } @@ -249,8 +232,6 @@ auto remote_client::winfsp_flush(PVOID file_desc, remote::file_info *file_info) }; DECODE_OR_IGNORE(&response, *file_info); - RAISE_REMOTE_WINFSP_CLIENT_EVENT( - function_name, get_open_file_path(to_handle(file_desc)), ret); return ret; } @@ -265,8 +246,9 @@ auto remote_client::winfsp_get_dir_buffer([[maybe_unused]] PVOID file_desc, return static_cast(STATUS_INVALID_HANDLE); } -auto remote_client::winfsp_get_file_info( - PVOID file_desc, remote::file_info *file_info) -> packet::error_type { +auto remote_client::winfsp_get_file_info(PVOID file_desc, + remote::file_info *file_info) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); packet request; @@ -279,14 +261,14 @@ auto remote_client::winfsp_get_file_info( }; DECODE_OR_IGNORE(&response, *file_info); - RAISE_REMOTE_WINFSP_CLIENT_EVENT( - function_name, get_open_file_path(to_handle(file_desc)), ret); return ret; } -auto remote_client::winfsp_get_security_by_name( - PWSTR file_name, PUINT32 attributes, std::uint64_t *descriptor_size, - std::wstring &string_descriptor) -> packet::error_type { +auto remote_client::winfsp_get_security_by_name(PWSTR file_name, + PUINT32 attributes, + std::uint64_t *descriptor_size, + std::wstring &string_descriptor) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); packet request; @@ -311,14 +293,13 @@ auto remote_client::winfsp_get_security_by_name( DECODE_OR_IGNORE(&response, *attributes); } - RAISE_REMOTE_WINFSP_CLIENT_EVENT(function_name, - utils::string::to_utf8(file_name), ret); return ret; } -auto remote_client::winfsp_get_volume_info( - UINT64 &total_size, UINT64 &free_size, - std::string &volume_label) -> packet::error_type { +auto remote_client::winfsp_get_volume_info(UINT64 &total_size, + UINT64 &free_size, + std::string &volume_label) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); packet request; @@ -352,14 +333,14 @@ auto remote_client::winfsp_mounted(const std::wstring &location) }; event_system::instance().raise(function_name, mount_location); - RAISE_REMOTE_WINFSP_CLIENT_EVENT(function_name, mount_location, ret); return ret; } -auto remote_client::winfsp_open( - PWSTR file_name, UINT32 create_options, UINT32 granted_access, - PVOID *file_desc, remote::file_info *file_info, - std::string &normalized_name) -> packet::error_type { +auto remote_client::winfsp_open(PWSTR file_name, UINT32 create_options, + UINT32 granted_access, PVOID *file_desc, + remote::file_info *file_info, + std::string &normalized_name) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); packet request; @@ -390,15 +371,14 @@ auto remote_client::winfsp_open( } } - RAISE_REMOTE_WINFSP_CLIENT_EVENT( - function_name, get_open_file_path(to_handle(*file_desc)), ret); return ret; } -auto remote_client::winfsp_overwrite( - PVOID file_desc, UINT32 attributes, BOOLEAN replace_attributes, - UINT64 allocation_size, - remote::file_info *file_info) -> packet::error_type { +auto remote_client::winfsp_overwrite(PVOID file_desc, UINT32 attributes, + BOOLEAN replace_attributes, + UINT64 allocation_size, + remote::file_info *file_info) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); packet request; @@ -414,8 +394,6 @@ auto remote_client::winfsp_overwrite( }; DECODE_OR_IGNORE(&response, *file_info); - RAISE_REMOTE_WINFSP_CLIENT_EVENT( - function_name, get_open_file_path(to_handle(file_desc)), ret); return ret; } @@ -439,17 +417,12 @@ auto remote_client::winfsp_read(PVOID file_desc, PVOID buffer, UINT64 offset, ret = response.decode(buffer, *bytes_transferred); #if defined(_WIN32) if ((ret == STATUS_SUCCESS) && - (not *bytes_transferred || (*bytes_transferred != length))) { + (not*bytes_transferred || (*bytes_transferred != length))) { ::SetLastError(ERROR_HANDLE_EOF); } #endif } - if (ret != STATUS_SUCCESS) { - RAISE_REMOTE_WINFSP_CLIENT_EVENT( - function_name, get_open_file_path(to_handle(file_desc)), ret); - } - return ret; } @@ -472,14 +445,13 @@ auto remote_client::winfsp_read_directory(PVOID file_desc, PWSTR pattern, ret = packet::decode_json(response, item_list); } - RAISE_REMOTE_WINFSP_CLIENT_EVENT( - function_name, get_open_file_path(to_handle(file_desc)), ret); return ret; } -auto remote_client::winfsp_rename( - PVOID file_desc, PWSTR file_name, PWSTR new_file_name, - BOOLEAN replace_if_exists) -> packet::error_type { +auto remote_client::winfsp_rename(PVOID file_desc, PWSTR file_name, + PWSTR new_file_name, + BOOLEAN replace_if_exists) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); packet request; @@ -493,11 +465,6 @@ auto remote_client::winfsp_rename( packet_client_.send(function_name, request, service_flags), }; - RAISE_REMOTE_WINFSP_CLIENT_EVENT( - function_name, - utils::path::create_api_path(utils::string::to_utf8(file_name)) + "|" + - utils::path::create_api_path(utils::string::to_utf8(new_file_name)), - ret); return ret; } @@ -522,14 +489,13 @@ auto remote_client::winfsp_set_basic_info( }; DECODE_OR_IGNORE(&response, *file_info); - RAISE_REMOTE_WINFSP_CLIENT_EVENT( - function_name, get_open_file_path(to_handle(file_desc)), ret); return ret; } -auto remote_client::winfsp_set_file_size( - PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size, - remote::file_info *file_info) -> packet::error_type { +auto remote_client::winfsp_set_file_size(PVOID file_desc, UINT64 new_size, + BOOLEAN set_allocation_size, + remote::file_info *file_info) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); packet request; @@ -544,8 +510,6 @@ auto remote_client::winfsp_set_file_size( }; DECODE_OR_IGNORE(&response, *file_info); - RAISE_REMOTE_WINFSP_CLIENT_EVENT( - function_name, get_open_file_path(to_handle(file_desc)), ret); return ret; } @@ -557,7 +521,7 @@ auto remote_client::winfsp_unmounted(const std::wstring &location) utils::string::to_utf8(location), }; event_system::instance().raise(function_name, - mount_location); + mount_location); packet request; request.encode(location); @@ -566,16 +530,17 @@ auto remote_client::winfsp_unmounted(const std::wstring &location) packet_client_.send(function_name, request, service_flags), }; event_system::instance().raise(function_name, - mount_location); + mount_location); - RAISE_REMOTE_WINFSP_CLIENT_EVENT(function_name, mount_location, ret); return ret; } -auto remote_client::winfsp_write( - PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, - BOOLEAN write_to_end, BOOLEAN constrained_io, PUINT32 bytes_transferred, - remote::file_info *file_info) -> packet::error_type { +auto remote_client::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, + UINT32 length, BOOLEAN write_to_end, + BOOLEAN constrained_io, + PUINT32 bytes_transferred, + remote::file_info *file_info) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); packet request; @@ -596,10 +561,6 @@ auto remote_client::winfsp_write( DECODE_OR_IGNORE(&response, *bytes_transferred); DECODE_OR_IGNORE(&response, *file_info); - if (ret != STATUS_SUCCESS) { - RAISE_REMOTE_WINFSP_CLIENT_EVENT( - function_name, get_open_file_path(to_handle(file_desc)), ret); - } return ret; } diff --git a/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_server.cpp b/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_server.cpp index 7e6ed7ac..2dedd6dc 100644 --- a/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_server.cpp +++ b/repertory/librepertory/src/drives/winfsp/remotewinfsp/remote_server.cpp @@ -33,6 +33,7 @@ #include "drives/remote/remote_open_file_table.hpp" #include "drives/winfsp/remotewinfsp/i_remote_instance.hpp" #include "events/event_system.hpp" +#include "events/types/remote_server_event.hpp" #include "platform/platform.hpp" #include "types/remote.hpp" #include "types/repertory.hpp" @@ -45,11 +46,10 @@ namespace repertory::remote_winfsp { #define RAISE_REMOTE_WINFSP_SERVER_EVENT(func, file, ret) \ if (config_.get_enable_drive_events() && \ - (((config_.get_event_level() >= remote_winfsp_server_event::level) && \ + (((config_.get_event_level() >= remote_server_event::level) && \ ((ret) != STATUS_SUCCESS)) || \ (config_.get_event_level() >= event_level::trace))) \ - event_system::instance().raise( \ - std::string{func}, file, ret) + event_system::instance().raise(file, func, ret) auto remote_server::get_next_handle() -> std::uint64_t { if (++next_handle_ == 0U) { @@ -141,9 +141,10 @@ auto remote_server::fuse_chmod(const char *path, return ret; } -auto remote_server::fuse_chown( - const char *path, const remote::user_id & /*uid*/, - const remote::group_id & /*gid*/) -> packet::error_type { +auto remote_server::fuse_chown(const char *path, + const remote::user_id & /*uid*/, + const remote::group_id & /*gid*/) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); auto file_path = construct_path(path); @@ -171,9 +172,10 @@ construct_path(path); auto res = HasOpenFileCompatInfo(handle, EBADF); if (res return ret; }*/ -auto remote_server::fuse_fgetattr( - const char *path, remote::stat &r_stat, bool &directory, - const remote::file_handle &handle) -> packet::error_type { +auto remote_server::fuse_fgetattr(const char *path, remote::stat &r_stat, + bool &directory, + const remote::file_handle &handle) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); r_stat = {}; @@ -185,7 +187,7 @@ auto remote_server::fuse_fgetattr( }; if (res == 0) { directory = utils::file::directory(file_path).exists(); - struct _stat64 unix_st {}; + struct _stat64 unix_st{}; res = _fstat64(static_cast(handle), &unix_st); if (res == 0) { populate_stat(path, directory, r_stat, unix_st); @@ -197,9 +199,10 @@ auto remote_server::fuse_fgetattr( return ret; } -auto remote_server::fuse_fsetattr_x( - const char *path, const remote::setattr_x & /*attr*/, - const remote::file_handle & /*handle*/) -> packet::error_type { +auto remote_server::fuse_fsetattr_x(const char *path, + const remote::setattr_x & /*attr*/, + const remote::file_handle & /*handle*/) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); auto file_path = construct_path(path); @@ -208,9 +211,10 @@ auto remote_server::fuse_fsetattr_x( return ret; } -auto remote_server::fuse_fsync( - const char *path, const std::int32_t & /*datasync*/, - const remote::file_handle &handle) -> packet::error_type { +auto remote_server::fuse_fsync(const char *path, + const std::int32_t & /*datasync*/, + const remote::file_handle &handle) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); auto file_path = construct_path(path); @@ -237,9 +241,10 @@ auto remote_server::fuse_fsync( return ret; } -auto remote_server::fuse_ftruncate( - const char *path, const remote::file_offset &size, - const remote::file_handle &handle) -> packet::error_type { +auto remote_server::fuse_ftruncate(const char *path, + const remote::file_offset &size, + const remote::file_handle &handle) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); auto file_path = construct_path(path); @@ -279,7 +284,7 @@ auto remote_server::fuse_getattr(const char *path, remote::stat &r_st, directory = utils::file::directory(file_path).exists(); - struct _stat64 st1 {}; + struct _stat64 st1{}; auto res{ _stat64(file_path.c_str(), &st1), }; @@ -305,9 +310,10 @@ STATUS_NOT_IMPLEMENTED; RAISE_REMOTE_WINFSP_SERVER_EVENT(function_name, file_path, ret); return ret; }*/ -auto remote_server::fuse_getxtimes( - const char *path, remote::file_time & /*bkuptime*/, - remote::file_time & /*crtime*/) -> packet::error_type { +auto remote_server::fuse_getxtimes(const char *path, + remote::file_time & /*bkuptime*/, + remote::file_time & /*crtime*/) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); auto file_path = construct_path(path); @@ -438,10 +444,11 @@ auto remote_server::fuse_open(const char *path, const remote::open_flags &flags, return ret; } -auto remote_server::fuse_read( - const char *path, char *buffer, const remote::file_size &read_size, - const remote::file_offset &read_offset, - const remote::file_handle &handle) -> packet::error_type { +auto remote_server::fuse_read(const char *path, char *buffer, + const remote::file_size &read_size, + const remote::file_offset &read_offset, + const remote::file_handle &handle) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); auto file_path = construct_path(path); @@ -472,8 +479,8 @@ auto remote_server::fuse_read( return ret; } -auto remote_server::fuse_rename(const char *from, - const char *to) -> packet::error_type { +auto remote_server::fuse_rename(const char *from, const char *to) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); auto from_path = utils::path::combine(mount_location_, {from}); @@ -488,10 +495,11 @@ auto remote_server::fuse_rename(const char *from, return ret; } -auto remote_server::fuse_write( - const char *path, const char *buffer, const remote::file_size &write_size, - const remote::file_offset &write_offset, - const remote::file_handle &handle) -> packet::error_type { +auto remote_server::fuse_write(const char *path, const char *buffer, + const remote::file_size &write_size, + const remote::file_offset &write_offset, + const remote::file_handle &handle) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); auto file_path = construct_path(path); @@ -558,8 +566,9 @@ auto remote_server::fuse_readdir(const char *path, return ret; } -auto remote_server::fuse_release( - const char *path, const remote::file_handle &handle) -> packet::error_type { +auto remote_server::fuse_release(const char *path, + const remote::file_handle &handle) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); auto file_path = construct_path(path); @@ -603,8 +612,9 @@ auto remote_server::fuse_rmdir(const char *path) -> packet::error_type { return ret; } -auto remote_server::fuse_setattr_x( - const char *path, remote::setattr_x & /*attr*/) -> packet::error_type { +auto remote_server::fuse_setattr_x(const char *path, + remote::setattr_x & /*attr*/) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); auto file_path = construct_path(path); @@ -716,8 +726,9 @@ auto remote_server::fuse_statfs_x(const char *path, std::uint64_t bsize, return 0; } -auto remote_server::fuse_truncate( - const char *path, const remote::file_offset &size) -> packet::error_type { +auto remote_server::fuse_truncate(const char *path, + const remote::file_offset &size) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); auto file_path = construct_path(path); @@ -764,8 +775,8 @@ auto remote_server::fuse_unlink(const char *path) -> packet::error_type { } auto remote_server::fuse_utimens(const char *path, const remote::file_time *tv, - std::uint64_t op0, - std::uint64_t op1) -> packet::error_type { + std::uint64_t op0, std::uint64_t op1) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); auto file_path = construct_path(path); @@ -824,8 +835,9 @@ auto remote_server::fuse_utimens(const char *path, const remote::file_time *tv, } // JSON Layer -auto remote_server::json_create_directory_snapshot( - const std::string &path, json &json_data) -> packet::error_type { +auto remote_server::json_create_directory_snapshot(const std::string &path, + json &json_data) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); auto file_path = construct_path(path); @@ -883,8 +895,8 @@ auto remote_server::json_read_directory_snapshot( } auto remote_server::json_release_directory_snapshot( - const std::string &path, - const remote::file_handle & /*handle*/) -> packet::error_type { + const std::string &path, const remote::file_handle & /*handle*/) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); auto file_path = construct_path(path); @@ -915,8 +927,8 @@ auto remote_server::winfsp_can_delete(PVOID file_desc, PWSTR /*file_name*/) } auto remote_server::winfsp_cleanup(PVOID file_desc, PWSTR /*file_name*/, - UINT32 flags, - BOOLEAN &was_deleted) -> packet::error_type { + UINT32 flags, BOOLEAN &was_deleted) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); auto file_path = get_open_file_path(file_desc); @@ -953,8 +965,8 @@ auto remote_server::winfsp_create(PWSTR file_name, UINT32 create_options, UINT32 granted_access, UINT32 attributes, UINT64 /*allocation_size*/, PVOID *file_desc, remote::file_info *file_info, - std::string &normalized_name, - BOOLEAN &exists) -> packet::error_type { + std::string &normalized_name, BOOLEAN &exists) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); auto file_path = utils::string::from_utf8(utils::path::combine( @@ -1022,8 +1034,9 @@ auto remote_server::winfsp_flush(PVOID file_desc, remote::file_info *file_info) return ret; } -auto remote_server::winfsp_get_file_info( - PVOID file_desc, remote::file_info *file_info) -> packet::error_type { +auto remote_server::winfsp_get_file_info(PVOID file_desc, + remote::file_info *file_info) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); auto *handle = reinterpret_cast(file_desc); @@ -1037,9 +1050,11 @@ auto remote_server::winfsp_get_file_info( return ret; } -auto remote_server::winfsp_get_security_by_name( - PWSTR file_name, PUINT32 attributes, std::uint64_t *descriptor_size, - std::wstring &string_descriptor) -> packet::error_type { +auto remote_server::winfsp_get_security_by_name(PWSTR file_name, + PUINT32 attributes, + std::uint64_t *descriptor_size, + std::wstring &string_descriptor) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); auto file_path = utils::string::from_utf8(utils::path::combine( @@ -1078,9 +1093,10 @@ auto remote_server::winfsp_get_security_by_name( return ret; } -auto remote_server::winfsp_get_volume_info( - UINT64 &total_size, UINT64 &free_size, - std::string &volume_label) -> packet::error_type { +auto remote_server::winfsp_get_volume_info(UINT64 &total_size, + UINT64 &free_size, + std::string &volume_label) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); drive_.get_volume_info(total_size, free_size, volume_label); @@ -1097,10 +1113,11 @@ auto remote_server::winfsp_mounted(const std::wstring &location) return STATUS_SUCCESS; } -auto remote_server::winfsp_open( - PWSTR file_name, UINT32 create_options, UINT32 granted_access, - PVOID *file_desc, remote::file_info *file_info, - std::string &normalized_name) -> packet::error_type { +auto remote_server::winfsp_open(PWSTR file_name, UINT32 create_options, + UINT32 granted_access, PVOID *file_desc, + remote::file_info *file_info, + std::string &normalized_name) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); auto file_path = utils::string::from_utf8(utils::path::combine( @@ -1136,10 +1153,11 @@ auto remote_server::winfsp_open( return ret; } -auto remote_server::winfsp_overwrite( - PVOID file_desc, UINT32 attributes, BOOLEAN replace_attributes, - UINT64 /*allocation_size*/, - remote::file_info *file_info) -> packet::error_type { +auto remote_server::winfsp_overwrite(PVOID file_desc, UINT32 attributes, + BOOLEAN replace_attributes, + UINT64 /*allocation_size*/, + remote::file_info *file_info) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); auto *handle = reinterpret_cast(file_desc); @@ -1240,9 +1258,10 @@ auto remote_server::winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/, return ret; } -auto remote_server::winfsp_rename( - PVOID /*file_desc*/, PWSTR file_name, PWSTR new_file_name, - BOOLEAN replace_if_exists) -> packet::error_type { +auto remote_server::winfsp_rename(PVOID /*file_desc*/, PWSTR file_name, + PWSTR new_file_name, + BOOLEAN replace_if_exists) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); auto from_path = utils::string::from_utf8(utils::path::combine( @@ -1293,9 +1312,10 @@ auto remote_server::winfsp_set_basic_info( return ret; } -auto remote_server::winfsp_set_file_size( - PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size, - remote::file_info *file_info) -> packet::error_type { +auto remote_server::winfsp_set_file_size(PVOID file_desc, UINT64 new_size, + BOOLEAN set_allocation_size, + remote::file_info *file_info) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); auto *handle = reinterpret_cast(file_desc); @@ -1338,10 +1358,12 @@ auto remote_server::winfsp_unmounted(const std::wstring &location) return STATUS_SUCCESS; } -auto remote_server::winfsp_write( - PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length, - BOOLEAN /*write_to_end*/, BOOLEAN constrained_io, PUINT32 bytes_transferred, - remote::file_info *file_info) -> packet::error_type { +auto remote_server::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, + UINT32 length, BOOLEAN /*write_to_end*/, + BOOLEAN constrained_io, + PUINT32 bytes_transferred, + remote::file_info *file_info) + -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); auto *handle = reinterpret_cast(file_desc);