fuse unit tests and fixes
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit

This commit is contained in:
2024-11-13 11:58:30 -06:00
parent 5ea9f27645
commit f2eafe0f14
3 changed files with 42 additions and 47 deletions

View File

@ -706,11 +706,8 @@ auto fuse_drive::opendir_impl(std::string api_path,
return api_error::directory_not_found; return api_error::directory_not_found;
} }
if ((file_info->flags & O_APPEND) == O_APPEND) { if ((file_info->flags & O_APPEND) == O_APPEND ||
return api_error::directory_exists; (file_info->flags & O_EXCL) == O_EXCL) {
}
if ((file_info->flags & O_EXCL) == O_EXCL) {
return api_error::directory_exists; return api_error::directory_exists;
} }

View File

@ -40,8 +40,8 @@
#include "utils/utils.hpp" #include "utils/utils.hpp"
namespace repertory::remote_fuse { namespace repertory::remote_fuse {
auto remote_fuse_drive::access_impl(std::string api_path, int mask) auto remote_fuse_drive::access_impl(std::string api_path,
-> api_error { int mask) -> api_error {
return utils::to_api_error( return utils::to_api_error(
remote_instance_->fuse_access(api_path.c_str(), mask)); remote_instance_->fuse_access(api_path.c_str(), mask));
} }
@ -59,8 +59,8 @@ auto remote_fuse_drive::chmod_impl(std::string api_path, mode_t mode,
struct fuse_file_info * /*f_info*/) struct fuse_file_info * /*f_info*/)
-> api_error { -> api_error {
#else #else
auto remote_fuse_drive::chmod_impl(std::string api_path, mode_t mode) auto remote_fuse_drive::chmod_impl(std::string api_path,
-> api_error { mode_t mode) -> api_error {
#endif #endif
return utils::to_api_error(remote_instance_->fuse_chmod( return utils::to_api_error(remote_instance_->fuse_chmod(
api_path.c_str(), static_cast<remote::file_mode>(mode))); api_path.c_str(), static_cast<remote::file_mode>(mode)));
@ -71,8 +71,8 @@ auto remote_fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid,
struct fuse_file_info * /*f_info*/) struct fuse_file_info * /*f_info*/)
-> api_error { -> api_error {
#else #else
auto remote_fuse_drive::chown_impl(std::string api_path, uid_t uid, gid_t gid) auto remote_fuse_drive::chown_impl(std::string api_path, uid_t uid,
-> api_error { gid_t gid) -> api_error {
#endif #endif
return utils::to_api_error( return utils::to_api_error(
remote_instance_->fuse_chown(api_path.c_str(), uid, gid)); remote_instance_->fuse_chown(api_path.c_str(), uid, gid));
@ -116,10 +116,9 @@ void remote_fuse_drive::destroy_impl(void *ptr) {
fuse_base::destroy_impl(ptr); fuse_base::destroy_impl(ptr);
} }
auto remote_fuse_drive::fgetattr_impl(std::string api_path, auto remote_fuse_drive::fgetattr_impl(
struct stat *unix_st, std::string api_path, struct stat *unix_st,
struct fuse_file_info *f_info) struct fuse_file_info *f_info) -> api_error {
-> api_error {
remote::stat r_stat{}; remote::stat r_stat{};
auto directory = false; auto directory = false;
@ -180,8 +179,8 @@ auto remote_fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st,
struct fuse_file_info * /*f_info*/) struct fuse_file_info * /*f_info*/)
-> api_error { -> api_error {
#else #else
auto remote_fuse_drive::getattr_impl(std::string api_path, struct stat *unix_st) auto remote_fuse_drive::getattr_impl(std::string api_path,
-> api_error { struct stat *unix_st) -> api_error {
#endif #endif
bool directory = false; bool directory = false;
remote::stat r_stat{}; remote::stat r_stat{};
@ -264,8 +263,8 @@ auto remote_fuse_drive::init_impl(struct fuse_conn_info *conn) -> void * {
return ret; return ret;
} }
auto remote_fuse_drive::mkdir_impl(std::string api_path, mode_t mode) auto remote_fuse_drive::mkdir_impl(std::string api_path,
-> api_error { mode_t mode) -> api_error {
return utils::to_api_error(remote_instance_->fuse_mkdir( return utils::to_api_error(remote_instance_->fuse_mkdir(
api_path.c_str(), static_cast<remote::file_mode>(mode))); api_path.c_str(), static_cast<remote::file_mode>(mode)));
} }
@ -287,9 +286,12 @@ auto remote_fuse_drive::open_impl(std::string api_path,
f_info->fh)); f_info->fh));
} }
auto remote_fuse_drive::opendir_impl(std::string api_path, auto remote_fuse_drive::opendir_impl(
struct fuse_file_info *f_info) std::string api_path, struct fuse_file_info *f_info) -> api_error {
-> api_error { if ((f_info->flags & O_APPEND) == O_APPEND ||
(f_info->flags & O_EXCL) == O_EXCL) {
return api_error::directory_exists;
}
return utils::to_api_error( return utils::to_api_error(
remote_instance_->fuse_opendir(api_path.c_str(), f_info->fh)); remote_instance_->fuse_opendir(api_path.c_str(), f_info->fh));
@ -378,18 +380,14 @@ auto remote_fuse_drive::read_impl(std::string api_path, char *buffer,
} }
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
auto remote_fuse_drive::readdir_impl(std::string api_path, void *buf, auto remote_fuse_drive::readdir_impl(
fuse_fill_dir_t fuse_fill_dir, std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir,
off_t offset, off_t offset, struct fuse_file_info *f_info,
struct fuse_file_info *f_info, fuse_readdir_flags /*flags*/) -> api_error {
fuse_readdir_flags /*flags*/)
-> api_error {
#else #else
auto remote_fuse_drive::readdir_impl(std::string api_path, void *buf, auto remote_fuse_drive::readdir_impl(
fuse_fill_dir_t fuse_fill_dir, std::string api_path, void *buf, fuse_fill_dir_t fuse_fill_dir,
off_t offset, off_t offset, struct fuse_file_info *f_info) -> api_error {
struct fuse_file_info *f_info)
-> api_error {
#endif #endif
std::string item_path; std::string item_path;
int res = 0; int res = 0;
@ -417,16 +415,14 @@ auto remote_fuse_drive::readdir_impl(std::string api_path, void *buf,
return utils::to_api_error(res); return utils::to_api_error(res);
} }
auto remote_fuse_drive::release_impl(std::string api_path, auto remote_fuse_drive::release_impl(
struct fuse_file_info *f_info) std::string api_path, struct fuse_file_info *f_info) -> api_error {
-> api_error {
return utils::to_api_error( return utils::to_api_error(
remote_instance_->fuse_release(api_path.c_str(), f_info->fh)); remote_instance_->fuse_release(api_path.c_str(), f_info->fh));
} }
auto remote_fuse_drive::releasedir_impl(std::string api_path, auto remote_fuse_drive::releasedir_impl(
struct fuse_file_info *f_info) std::string api_path, struct fuse_file_info *f_info) -> api_error {
-> api_error {
return utils::to_api_error( return utils::to_api_error(
remote_instance_->fuse_releasedir(api_path.c_str(), f_info->fh)); remote_instance_->fuse_releasedir(api_path.c_str(), f_info->fh));
} }
@ -523,8 +519,8 @@ api_error remote_fuse_drive::statfs_x_impl(std::string api_path,
return utils::to_api_error(res); return utils::to_api_error(res);
} }
#else // __APPLE__ #else // __APPLE__
auto remote_fuse_drive::statfs_impl(std::string api_path, struct statvfs *stbuf) auto remote_fuse_drive::statfs_impl(std::string api_path,
-> api_error { struct statvfs *stbuf) -> api_error {
auto res = statvfs(config_.get_data_directory().c_str(), stbuf); auto res = statvfs(config_.get_data_directory().c_str(), stbuf);
if (res == 0) { if (res == 0) {
remote::statfs r_stat{}; remote::statfs r_stat{};
@ -551,8 +547,8 @@ auto remote_fuse_drive::truncate_impl(std::string api_path, off_t size,
struct fuse_file_info * /*f_info*/) struct fuse_file_info * /*f_info*/)
-> api_error { -> api_error {
#else #else
auto remote_fuse_drive::truncate_impl(std::string api_path, off_t size) auto remote_fuse_drive::truncate_impl(std::string api_path,
-> api_error { off_t size) -> api_error {
#endif #endif
return utils::to_api_error(remote_instance_->fuse_truncate( return utils::to_api_error(remote_instance_->fuse_truncate(
api_path.c_str(), static_cast<remote::file_offset>(size))); api_path.c_str(), static_cast<remote::file_offset>(size)));
@ -563,10 +559,9 @@ auto remote_fuse_drive::unlink_impl(std::string api_path) -> api_error {
} }
#if FUSE_USE_VERSION >= 30 #if FUSE_USE_VERSION >= 30
auto remote_fuse_drive::utimens_impl(std::string api_path, auto remote_fuse_drive::utimens_impl(
const struct timespec tv[2], std::string api_path, const struct timespec tv[2],
struct fuse_file_info * /*f_info*/) struct fuse_file_info * /*f_info*/) -> api_error {
-> api_error {
#else #else
auto remote_fuse_drive::utimens_impl(std::string api_path, auto remote_fuse_drive::utimens_impl(std::string api_path,
const struct timespec tv[2]) -> api_error { const struct timespec tv[2]) -> api_error {

View File

@ -484,6 +484,9 @@ TYPED_TEST(fuse_test, create_open_fails_if_path_is_directory) {
for (auto &&flags : ops) { for (auto &&flags : ops) {
auto handle = open(dir_path.c_str(), flags); auto handle = open(dir_path.c_str(), flags);
EXPECT_EQ(-1, handle); EXPECT_EQ(-1, handle);
if (handle != -1) {
std::cout << std::oct << flags << std::endl;
}
EXPECT_EQ(EISDIR, errno); EXPECT_EQ(EISDIR, errno);
} }