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
74546807f4
commit
d2a26f0c09
@ -119,6 +119,7 @@ auto fuse_drive::create_impl(std::string api_path, mode_t mode,
|
||||
auto is_create_op = ((file_info->flags & O_CREAT) == O_CREAT);
|
||||
auto is_directory_op = ((file_info->flags & O_DIRECTORY) == O_DIRECTORY);
|
||||
auto is_truncate_op = ((file_info->flags & O_TRUNC) == O_TRUNC);
|
||||
auto is_exclusive = ((file_info->flags & O_EXCL) == O_EXCL);
|
||||
|
||||
if (((file_info->flags & O_WRONLY) != 0) ||
|
||||
((file_info->flags & O_RDWR) != 0)) {
|
||||
@ -152,25 +153,29 @@ auto fuse_drive::create_impl(std::string api_path, mode_t mode,
|
||||
return api_error::invalid_operation;
|
||||
}
|
||||
|
||||
if (not is_create_op) {
|
||||
bool file_exists{};
|
||||
res = provider_.is_file(api_path, file_exists);
|
||||
if (res != api_error::success) {
|
||||
return res;
|
||||
}
|
||||
|
||||
if (is_create_op) {
|
||||
if (is_exclusive && file_exists) {
|
||||
return api_error::item_exists;
|
||||
}
|
||||
} else {
|
||||
bool dir_exists{};
|
||||
res = provider_.is_directory(api_path, dir_exists);
|
||||
if (res != api_error::success) {
|
||||
return res;
|
||||
}
|
||||
|
||||
bool file_exists{};
|
||||
res = provider_.is_file(api_path, file_exists);
|
||||
if (res != api_error::success) {
|
||||
return res;
|
||||
}
|
||||
|
||||
if (not(is_directory_op ? dir_exists : file_exists)) {
|
||||
return (is_directory_op ? api_error::directory_not_found
|
||||
: api_error::item_not_found);
|
||||
}
|
||||
|
||||
if (is_truncate_op && not file_exists) {
|
||||
if ((is_exclusive || is_truncate_op) && not file_exists) {
|
||||
return api_error::item_not_found;
|
||||
}
|
||||
}
|
||||
|
@ -125,6 +125,17 @@ TYPED_TEST(fuse_test, create_can_open_and_truncate_existing_file) {
|
||||
|
||||
this->unlink_file_and_test(file_path);
|
||||
}
|
||||
|
||||
TYPED_TEST(fuse_test, create_can_open_existing_file_with_excl) {
|
||||
std::string file_name{"create_test"};
|
||||
auto file_path = this->create_file_and_test(file_name);
|
||||
|
||||
auto handle = open(file_path.c_str(), O_EXCL, ACCESSPERMS);
|
||||
EXPECT_LE(1, handle);
|
||||
close(handle);
|
||||
|
||||
this->unlink_file_and_test(file_path);
|
||||
}
|
||||
} // namespace repertory
|
||||
|
||||
#endif // !defined(_WIN32)
|
||||
|
Loading…
x
Reference in New Issue
Block a user