fixes
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
Scott E. Graves 2024-11-09 16:15:00 -06:00
parent fd46d3ef96
commit 54fdcf6d80
2 changed files with 103 additions and 102 deletions

View File

@ -208,8 +208,8 @@ auto remote_server::fuse_access(const char *path, const std::int32_t &mask)
return ret; return ret;
} }
auto remote_server::fuse_chflags(const char *path, std::uint32_t flags) auto remote_server::fuse_chflags(const char *path,
-> packet::error_type { std::uint32_t flags) -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto api_path = utils::path::create_api_path(path); const auto api_path = utils::path::create_api_path(path);
@ -263,7 +263,12 @@ auto remote_server::fuse_create(const char *path, const remote::file_mode &mode,
static_cast<int>(remote::create_os_open_flags(flags)), mode); static_cast<int>(remote::create_os_open_flags(flags)), mode);
if (res >= 0) { if (res >= 0) {
handle = static_cast<remote::file_handle>(res); handle = static_cast<remote::file_handle>(res);
set_open_info(res, open_info{0, "", nullptr, file_path}); set_open_info(res, open_info{
"",
nullptr,
{},
file_path,
});
} }
auto ret = ((res < 0) ? -errno : 0); auto ret = ((res < 0) ? -errno : 0);
@ -316,10 +321,9 @@ length); ret = ((res < 0) ? -errno : 0); #endif
return ret; return ret;
}*/ }*/
auto remote_server::fuse_fgetattr(const char *path, remote::stat &r_stat, auto remote_server::fuse_fgetattr(
bool &directory, const char *path, remote::stat &r_stat, bool &directory,
const remote::file_handle &handle) const remote::file_handle &handle) -> packet::error_type {
-> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
r_stat = {}; r_stat = {};
@ -329,7 +333,7 @@ auto remote_server::fuse_fgetattr(const char *path, remote::stat &r_stat,
auto res = has_open_info(static_cast<native_handle>(handle), EBADF); auto res = has_open_info(static_cast<native_handle>(handle), EBADF);
if (res == 0) { if (res == 0) {
directory = utils::file::directory(file_path).exists(); directory = utils::file::directory(file_path).exists();
struct stat64 unix_st{}; struct stat64 unix_st {};
res = fstat64(static_cast<native_handle>(handle), &unix_st); res = fstat64(static_cast<native_handle>(handle), &unix_st);
if (res == 0) { if (res == 0) {
populate_stat(unix_st, r_stat); populate_stat(unix_st, r_stat);
@ -341,10 +345,9 @@ auto remote_server::fuse_fgetattr(const char *path, remote::stat &r_stat,
return ret; return ret;
} }
auto remote_server::fuse_fsetattr_x(const char *path, auto remote_server::fuse_fsetattr_x(
const remote::setattr_x &attr, const char *path, const remote::setattr_x &attr,
const remote::file_handle &handle) const remote::file_handle &handle) -> packet::error_type {
-> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto api_path = utils::path::create_api_path(path); const auto api_path = utils::path::create_api_path(path);
@ -460,10 +463,9 @@ auto remote_server::fuse_fsync(const char *path, const std::int32_t &datasync,
return ret; return ret;
} }
auto remote_server::fuse_ftruncate(const char *path, auto remote_server::fuse_ftruncate(
const remote::file_offset &size, const char *path, const remote::file_offset &size,
const remote::file_handle &handle) const remote::file_handle &handle) -> packet::error_type {
-> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -491,7 +493,7 @@ auto remote_server::fuse_getattr(const char *path, remote::stat &r_stat,
directory = utils::file::directory(file_path).exists(); directory = utils::file::directory(file_path).exists();
struct stat64 unix_st{}; struct stat64 unix_st {};
auto res = stat64(file_path.c_str(), &unix_st); auto res = stat64(file_path.c_str(), &unix_st);
if (res == 0) { if (res == 0) {
populate_stat(unix_st, r_stat); populate_stat(unix_st, r_stat);
@ -556,10 +558,9 @@ STATUS_NOT_IMPLEMENTED; #endif RAISE_REMOTE_FUSE_SERVER_EVENT(function_name,
file_path, ret); return ret; file_path, ret); return ret;
}*/ }*/
auto remote_server::fuse_getxtimes(const char *path, auto remote_server::fuse_getxtimes(
remote::file_time &bkuptime, const char *path, remote::file_time &bkuptime,
remote::file_time &crtime) remote::file_time &crtime) -> packet::error_type {
-> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto api_path = utils::path::create_api_path(path); const auto api_path = utils::path::create_api_path(path);
@ -627,7 +628,12 @@ auto remote_server::fuse_open(const char *path, const remote::open_flags &flags,
static_cast<int>(remote::create_os_open_flags(flags))); static_cast<int>(remote::create_os_open_flags(flags)));
if (res >= 0) { if (res >= 0) {
handle = static_cast<remote::file_handle>(res); handle = static_cast<remote::file_handle>(res);
set_open_info(res, open_info{0, "", nullptr, file_path}); set_open_info(res, open_info{
"",
nullptr,
{},
file_path,
});
} }
auto ret = ((res < 0) ? -errno : 0); auto ret = ((res < 0) ? -errno : 0);
RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, file_path, ret); RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, file_path, ret);
@ -659,11 +665,10 @@ auto remote_server::fuse_opendir(const char *path, remote::file_handle &handle)
return ret; return ret;
} }
auto remote_server::fuse_read(const char *path, char *buffer, auto remote_server::fuse_read(
const remote::file_size &read_size, const char *path, char *buffer, const remote::file_size &read_size,
const remote::file_offset &read_offset, const remote::file_offset &read_offset,
const remote::file_handle &handle) const remote::file_handle &handle) -> packet::error_type {
-> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -684,8 +689,8 @@ auto remote_server::fuse_read(const char *path, char *buffer,
return static_cast<packet::error_type>(ret); return static_cast<packet::error_type>(ret);
} }
auto remote_server::fuse_rename(const char *from, const char *to) auto remote_server::fuse_rename(const char *from,
-> packet::error_type { const char *to) -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto from_path = utils::path::combine(mount_location_, {from}); const auto from_path = utils::path::combine(mount_location_, {from});
@ -723,9 +728,8 @@ auto remote_server::fuse_readdir(const char *path,
return ret; return ret;
} }
auto remote_server::fuse_release(const char *path, auto remote_server::fuse_release(
const remote::file_handle &handle) const char *path, const remote::file_handle &handle) -> packet::error_type {
-> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
packet::error_type ret = 0; packet::error_type ret = 0;
@ -742,9 +746,8 @@ auto remote_server::fuse_release(const char *path,
return ret; return ret;
} }
auto remote_server::fuse_releasedir(const char *path, auto remote_server::fuse_releasedir(
const remote::file_handle &handle) const char *path, const remote::file_handle &handle) -> packet::error_type {
-> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -795,9 +798,8 @@ auto remote_server::fuse_setattr_x(const char *path, remote::setattr_x &attr)
return ret; return ret;
} }
auto remote_server::fuse_setbkuptime(const char *path, auto remote_server::fuse_setbkuptime(
const remote::file_time &bkuptime) const char *path, const remote::file_time &bkuptime) -> packet::error_type {
-> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto api_path = utils::path::create_api_path(path); const auto api_path = utils::path::create_api_path(path);
@ -816,9 +818,8 @@ auto remote_server::fuse_setbkuptime(const char *path,
return ret; return ret;
} }
auto remote_server::fuse_setchgtime(const char *path, auto remote_server::fuse_setchgtime(
const remote::file_time &chgtime) const char *path, const remote::file_time &chgtime) -> packet::error_type {
-> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto api_path = utils::path::create_api_path(path); const auto api_path = utils::path::create_api_path(path);
@ -837,9 +838,8 @@ auto remote_server::fuse_setchgtime(const char *path,
return ret; return ret;
} }
auto remote_server::fuse_setcrtime(const char *path, auto remote_server::fuse_setcrtime(
const remote::file_time &crtime) const char *path, const remote::file_time &crtime) -> packet::error_type {
-> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto api_path = utils::path::create_api_path(path); const auto api_path = utils::path::create_api_path(path);
@ -930,9 +930,8 @@ auto remote_server::fuse_statfs_x(const char *path, std::uint64_t bsize,
return 0; return 0;
} }
auto remote_server::fuse_truncate(const char *path, auto remote_server::fuse_truncate(
const remote::file_offset &size) const char *path, const remote::file_offset &size) -> packet::error_type {
-> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -953,8 +952,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, auto remote_server::fuse_utimens(const char *path, const remote::file_time *tv,
std::uint64_t op0, std::uint64_t op1) std::uint64_t op0,
-> packet::error_type { std::uint64_t op1) -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -981,11 +980,10 @@ auto remote_server::fuse_utimens(const char *path, const remote::file_time *tv,
return ret; return ret;
} }
auto remote_server::fuse_write(const char *path, const char *buffer, auto remote_server::fuse_write(
const remote::file_size &write_size, const char *path, const char *buffer, const remote::file_size &write_size,
const remote::file_offset &write_offset, const remote::file_offset &write_offset,
const remote::file_handle &handle) const remote::file_handle &handle) -> packet::error_type {
-> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto file_path = construct_path(path); const auto file_path = construct_path(path);
@ -1015,8 +1013,8 @@ auto remote_server::fuse_write_base64(
} }
// WinFSP Layer // WinFSP Layer
auto remote_server::winfsp_can_delete(PVOID file_desc, PWSTR file_name) auto remote_server::winfsp_can_delete(PVOID file_desc,
-> packet::error_type { PWSTR file_name) -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto relative_path = utils::string::to_utf8(file_name); const auto relative_path = utils::string::to_utf8(file_name);
@ -1041,8 +1039,8 @@ auto remote_server::winfsp_can_delete(PVOID file_desc, PWSTR file_name)
} }
auto remote_server::winfsp_cleanup(PVOID /*file_desc*/, PWSTR file_name, auto remote_server::winfsp_cleanup(PVOID /*file_desc*/, PWSTR file_name,
UINT32 flags, BOOLEAN &was_deleted) UINT32 flags,
-> packet::error_type { BOOLEAN &was_deleted) -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto relative_path = utils::string::to_utf8(file_name); const auto relative_path = utils::string::to_utf8(file_name);
@ -1119,8 +1117,8 @@ auto remote_server::winfsp_create(PWSTR file_name, UINT32 create_options,
UINT32 granted_access, UINT32 attributes, UINT32 granted_access, UINT32 attributes,
UINT64 /*allocation_size*/, PVOID *file_desc, UINT64 /*allocation_size*/, PVOID *file_desc,
remote::file_info *file_info, remote::file_info *file_info,
std::string &normalized_name, BOOLEAN &exists) std::string &normalized_name,
-> packet::error_type { BOOLEAN &exists) -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto relative_path = utils::string::to_utf8(file_name); const auto relative_path = utils::string::to_utf8(file_name);
@ -1152,7 +1150,12 @@ auto remote_server::winfsp_create(PWSTR file_name, UINT32 create_options,
*file_desc = reinterpret_cast<PVOID>(res); *file_desc = reinterpret_cast<PVOID>(res);
drive_.set_item_meta(construct_api_path(file_path), META_ATTRIBUTES, drive_.set_item_meta(construct_api_path(file_path), META_ATTRIBUTES,
std::to_string(attributes)); std::to_string(attributes));
set_open_info(res, open_info{0, "", nullptr, file_path}); set_open_info(res, open_info{
"",
nullptr,
{},
file_path,
});
const auto api_path = utils::path::create_api_path(relative_path); const auto api_path = utils::path::create_api_path(relative_path);
normalized_name = utils::string::replace_copy(api_path, '/', '\\'); normalized_name = utils::string::replace_copy(api_path, '/', '\\');
@ -1187,9 +1190,8 @@ auto remote_server::winfsp_flush(PVOID file_desc, remote::file_info *file_info)
return ret; return ret;
} }
auto remote_server::winfsp_get_file_info(PVOID file_desc, auto remote_server::winfsp_get_file_info(
remote::file_info *file_info) PVOID file_desc, remote::file_info *file_info) -> packet::error_type {
-> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto handle = reinterpret_cast<remote::file_handle>(file_desc); const auto handle = reinterpret_cast<remote::file_handle>(file_desc);
@ -1232,10 +1234,9 @@ auto remote_server::winfsp_get_security_by_name(
return ret; return ret;
} }
auto remote_server::winfsp_get_volume_info(UINT64 &total_size, auto remote_server::winfsp_get_volume_info(
UINT64 &free_size, UINT64 &total_size, UINT64 &free_size,
std::string &volume_label) std::string &volume_label) -> packet::error_type {
-> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
drive_.get_volume_info(total_size, free_size, volume_label); drive_.get_volume_info(total_size, free_size, volume_label);
@ -1252,11 +1253,10 @@ auto remote_server::winfsp_mounted(const std::wstring &location)
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
auto remote_server::winfsp_open(PWSTR file_name, UINT32 create_options, auto remote_server::winfsp_open(
UINT32 granted_access, PVOID *file_desc, PWSTR file_name, UINT32 create_options, UINT32 granted_access,
remote::file_info *file_info, PVOID *file_desc, remote::file_info *file_info,
std::string &normalized_name) std::string &normalized_name) -> packet::error_type {
-> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto relative_path = utils::string::to_utf8(file_name); const auto relative_path = utils::string::to_utf8(file_name);
@ -1274,7 +1274,12 @@ auto remote_server::winfsp_open(PWSTR file_name, UINT32 create_options,
auto res = open(file_path.c_str(), static_cast<int>(flags)); auto res = open(file_path.c_str(), static_cast<int>(flags));
if (res >= 0) { if (res >= 0) {
*file_desc = reinterpret_cast<PVOID>(res); *file_desc = reinterpret_cast<PVOID>(res);
set_open_info(res, open_info{0, "", nullptr, file_path}); set_open_info(res, open_info{
"",
nullptr,
{},
file_path,
});
const auto api_path = utils::path::create_api_path(relative_path); const auto api_path = utils::path::create_api_path(relative_path);
normalized_name = utils::string::replace_copy(api_path, '/', '\\'); normalized_name = utils::string::replace_copy(api_path, '/', '\\');
@ -1292,11 +1297,10 @@ auto remote_server::winfsp_open(PWSTR file_name, UINT32 create_options,
return ret; return ret;
} }
auto remote_server::winfsp_overwrite(PVOID file_desc, UINT32 attributes, auto remote_server::winfsp_overwrite(
BOOLEAN replace_attributes, PVOID file_desc, UINT32 attributes, BOOLEAN replace_attributes,
UINT64 /*allocation_size*/, UINT64 /*allocation_size*/,
remote::file_info *file_info) remote::file_info *file_info) -> packet::error_type {
-> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto handle = reinterpret_cast<remote::file_handle>(file_desc); const auto handle = reinterpret_cast<remote::file_handle>(file_desc);
@ -1412,10 +1416,9 @@ auto remote_server::winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/,
return ret; return ret;
} }
auto remote_server::winfsp_rename(PVOID /*file_desc*/, PWSTR file_name, auto remote_server::winfsp_rename(
PWSTR new_file_name, PVOID /*file_desc*/, PWSTR file_name, PWSTR new_file_name,
BOOLEAN replace_if_exists) BOOLEAN replace_if_exists) -> packet::error_type {
-> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto relative_path = utils::string::to_utf8(file_name); const auto relative_path = utils::string::to_utf8(file_name);
@ -1509,10 +1512,9 @@ auto remote_server::winfsp_set_basic_info(
return ret; return ret;
} }
auto remote_server::winfsp_set_file_size(PVOID file_desc, UINT64 new_size, auto remote_server::winfsp_set_file_size(
BOOLEAN set_allocation_size, PVOID file_desc, UINT64 new_size, BOOLEAN set_allocation_size,
remote::file_info *file_info) remote::file_info *file_info) -> packet::error_type {
-> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto handle = reinterpret_cast<remote::file_handle>(file_desc); const auto handle = reinterpret_cast<remote::file_handle>(file_desc);
@ -1548,12 +1550,10 @@ auto remote_server::winfsp_unmounted(const std::wstring &location)
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
auto remote_server::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset, auto remote_server::winfsp_write(
UINT32 length, BOOLEAN write_to_end, PVOID file_desc, PVOID buffer, UINT64 offset, UINT32 length,
BOOLEAN constrained_io, BOOLEAN write_to_end, BOOLEAN constrained_io, PUINT32 bytes_transferred,
PUINT32 bytes_transferred, remote::file_info *file_info) -> packet::error_type {
remote::file_info *file_info)
-> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
*bytes_transferred = 0; *bytes_transferred = 0;
@ -1601,9 +1601,8 @@ auto remote_server::winfsp_write(PVOID file_desc, PVOID buffer, UINT64 offset,
return ret; return ret;
} }
auto remote_server::json_create_directory_snapshot(const std::string &path, auto remote_server::json_create_directory_snapshot(
json &json_data) const std::string &path, json &json_data) -> packet::error_type {
-> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto api_path = utils::path::create_api_path(path); const auto api_path = utils::path::create_api_path(path);
@ -1662,8 +1661,8 @@ auto remote_server::json_read_directory_snapshot(
} }
auto remote_server::json_release_directory_snapshot( auto remote_server::json_release_directory_snapshot(
const std::string &path, const remote::file_handle &handle) const std::string &path,
-> packet::error_type { const remote::file_handle &handle) -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
const auto file_path = construct_path(path); const auto file_path = construct_path(path);

View File

@ -27,16 +27,16 @@ namespace repertory {
TYPED_TEST_CASE(fuse_test, fuse_provider_types); TYPED_TEST_CASE(fuse_test, fuse_provider_types);
TYPED_TEST(fuse_test, can_create_and_remove_directory) { TYPED_TEST(fuse_test, can_create_and_remove_directory) {
auto dir_name = std::string{"dir"} + std::to_string(++this->idx); auto dir_name = std::string{"dir"};
auto dir_path = utils::path::combine(this->mount_location, {dir_name}); auto dir_path = utils::path::combine(this->mount_location, {dir_name});
EXPECT_EQ(0, mkdir(dir_path.c_str(), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | EXPECT_EQ(0, mkdir(dir_path.c_str(), S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP |
S_IWGRP | S_IXGRP)); S_IWGRP | S_IXGRP));
EXPECT_TRUE(utils::file::is_directory(dir_path)); EXPECT_TRUE(utils::file::directory(dir_path).exists());
EXPECT_FALSE(utils::file::is_file(dir_path)); EXPECT_FALSE(utils::file::file(dir_path).exists());
struct stat64 unix_st{}; struct stat64 unix_st {};
stat64(dir_path.c_str(), &unix_st); stat64(dir_path.c_str(), &unix_st);
EXPECT_EQ(getgid(), unix_st.st_gid); EXPECT_EQ(getgid(), unix_st.st_gid);
@ -45,6 +45,8 @@ TYPED_TEST(fuse_test, can_create_and_remove_directory) {
EXPECT_EQ(static_cast<std::uint32_t>(S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | EXPECT_EQ(static_cast<std::uint32_t>(S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP |
S_IWGRP | S_IXGRP), S_IWGRP | S_IXGRP),
ACCESSPERMS & unix_st.st_mode); ACCESSPERMS & unix_st.st_mode);
EXPECT_TRUE(utils::file::directory(dir_path).remove());
} }
} // namespace repertory } // namespace repertory