fuse unit tests and fixes
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good
This commit is contained in:
parent
0b7a9c6a56
commit
80d8d6f32f
@ -121,16 +121,6 @@ auto fuse_drive::create_impl(std::string api_path, mode_t mode,
|
||||
auto is_exclusive = ((file_info->flags & O_EXCL) == O_EXCL);
|
||||
auto is_truncate_op = ((file_info->flags & O_TRUNC) == O_TRUNC);
|
||||
|
||||
if (((file_info->flags & O_WRONLY) != 0) ||
|
||||
((file_info->flags & O_RDWR) != 0)) {
|
||||
auto res = provider_.is_file_writeable(api_path)
|
||||
? api_error::success
|
||||
: api_error::permission_denied;
|
||||
if (res != api_error::success) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
auto res = check_parent_access(api_path, X_OK);
|
||||
if (res != api_error::success) {
|
||||
return res;
|
||||
@ -152,6 +142,12 @@ auto fuse_drive::create_impl(std::string api_path, mode_t mode,
|
||||
return res;
|
||||
}
|
||||
|
||||
if ((((file_info->flags & O_WRONLY) == O_WRONLY) ||
|
||||
((file_info->flags & O_RDWR) == O_RDWR)) &&
|
||||
not provider_.is_file_writeable(api_path)) {
|
||||
return api_error::permission_denied;
|
||||
}
|
||||
|
||||
if (is_create_op && is_directory_op) {
|
||||
return api_error::invalid_operation;
|
||||
}
|
||||
@ -162,17 +158,23 @@ auto fuse_drive::create_impl(std::string api_path, mode_t mode,
|
||||
return res;
|
||||
}
|
||||
|
||||
if (is_create_op) {
|
||||
if (is_exclusive && file_exists) {
|
||||
return api_error::item_exists;
|
||||
}
|
||||
} else {
|
||||
bool dir_exists{};
|
||||
bool dir_exists{};
|
||||
if (not file_exists) {
|
||||
res = provider_.is_directory(api_path, dir_exists);
|
||||
if (res != api_error::success) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_create_op) {
|
||||
if (dir_exists) {
|
||||
return api_error::directory_exists;
|
||||
}
|
||||
|
||||
if (is_exclusive && file_exists) {
|
||||
return api_error::item_exists;
|
||||
}
|
||||
} else {
|
||||
if (not(is_directory_op ? dir_exists : file_exists)) {
|
||||
return (is_directory_op ? api_error::directory_not_found
|
||||
: api_error::item_not_found);
|
||||
|
@ -176,8 +176,8 @@ auto fuse_drive_base::check_parent_access(const std::string &api_path,
|
||||
for (auto parent = utils::path::get_parent_path(api_path);
|
||||
(ret == api_error::success) && not parent.empty();
|
||||
parent = utils::path::get_parent_path(parent)) {
|
||||
if (((ret = check_access(parent, X_OK)) == api_error::success) &&
|
||||
(parent == "/")) {
|
||||
ret = check_access(parent, X_OK);
|
||||
if ((ret == api_error::success) && (parent == "/")) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -456,8 +456,8 @@ TYPED_TEST(fuse_test, create_fails_with_excl_if_file_exists) {
|
||||
this->unlink_file_and_test(file_path);
|
||||
}
|
||||
|
||||
// 3. O_CREAT|O_EXCL-Failure: EISDIR (Is a directory) if a directory exists
|
||||
// instead of a file.
|
||||
// 3. O_CREAT|O_EXCL-Failure: EEXIST (File exists) if the file or directory
|
||||
// already exists.
|
||||
TYPED_TEST(fuse_test, create_fails_with_excl_if_path_is_directory) {
|
||||
std::string dir_name{"create_test"};
|
||||
auto dir_path = this->create_directory_and_test(dir_name);
|
||||
@ -465,7 +465,7 @@ TYPED_TEST(fuse_test, create_fails_with_excl_if_path_is_directory) {
|
||||
auto handle = open(dir_path.c_str(), O_CREAT | O_EXCL, ACCESSPERMS);
|
||||
EXPECT_EQ(-1, handle);
|
||||
|
||||
EXPECT_EQ(EISDIR, errno);
|
||||
EXPECT_EQ(EEXIST, errno);
|
||||
|
||||
this->rmdir_and_test(dir_path);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user