From c9f9c2a24c696a33a10cd96bb8df74b64841bb5a Mon Sep 17 00:00:00 2001 From: "Scott E. Graves" Date: Thu, 17 Oct 2024 17:13:20 -0500 Subject: [PATCH] fix --- .../drives/fuse/remotefuse/remote_server.cpp | 170 ++++++++---------- 1 file changed, 76 insertions(+), 94 deletions(-) diff --git a/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp b/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp index 9e8426e9..34c0d52c 100644 --- a/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp +++ b/repertory/librepertory/src/drives/fuse/remotefuse/remote_server.cpp @@ -199,14 +199,17 @@ auto remote_server::fuse_access(const char *path, const std::int32_t &mask) -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); + const auto api_path = utils::path::create_api_path(path); + const auto file_path = construct_path(path); + const auto res = access(file_path.c_str(), mask); auto ret = ((res < 0) ? -errno : 0); RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, file_path, ret); 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,10 +316,9 @@ 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 = {}; @@ -326,7 +328,7 @@ auto remote_server::fuse_fgetattr(const char *path, remote::stat &r_stat, 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); @@ -338,10 +340,9 @@ auto remote_server::fuse_fgetattr(const char *path, remote::stat &r_stat, 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); @@ -457,10 +458,9 @@ 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); @@ -488,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); @@ -553,10 +553,9 @@ 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); @@ -656,11 +655,10 @@ 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 +679,8 @@ auto remote_server::fuse_read(const char *path, char *buffer, 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,9 +718,8 @@ 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; @@ -739,9 +736,8 @@ auto remote_server::fuse_release(const char *path, 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); @@ -792,9 +788,8 @@ 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); @@ -813,9 +808,8 @@ auto remote_server::fuse_setbkuptime(const char *path, 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); @@ -834,9 +828,8 @@ auto remote_server::fuse_setchgtime(const char *path, 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); @@ -927,9 +920,8 @@ 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); @@ -950,8 +942,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); @@ -978,11 +970,10 @@ 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); @@ -1012,8 +1003,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); @@ -1039,8 +1030,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_closed) - -> packet::error_type { + UINT32 flags, + BOOLEAN &was_closed) -> packet::error_type { REPERTORY_USES_FUNCTION_NAME(); const auto relative_path = utils::string::to_utf8(file_name); @@ -1117,8 +1108,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); @@ -1188,9 +1179,8 @@ 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); @@ -1233,10 +1223,9 @@ 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); @@ -1253,11 +1242,10 @@ 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); @@ -1293,11 +1281,10 @@ auto remote_server::winfsp_open(PWSTR file_name, UINT32 create_options, 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); @@ -1414,10 +1401,9 @@ 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); @@ -1511,10 +1497,9 @@ 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); @@ -1550,12 +1535,10 @@ 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; @@ -1603,9 +1586,8 @@ auto remote_server::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, 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); @@ -1664,8 +1646,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);