fuse unit tests and fixes
This commit is contained in:
parent
f022be6fb9
commit
2e587fd897
@ -181,9 +181,14 @@ auto fuse_drive::create_impl(std::string api_path, mode_t mode,
|
||||
return api_error::item_exists;
|
||||
}
|
||||
} else {
|
||||
if (is_directory_op ? file_exists : dir_exists) {
|
||||
return is_directory_op ? api_error::item_exists
|
||||
: api_error::directory_exists;
|
||||
}
|
||||
|
||||
if (not(is_directory_op ? dir_exists : file_exists)) {
|
||||
return (is_directory_op ? api_error::directory_not_found
|
||||
: api_error::item_not_found);
|
||||
return is_directory_op ? api_error::directory_not_found
|
||||
: api_error::item_not_found;
|
||||
}
|
||||
|
||||
if ((is_exclusive || is_truncate_op) && not file_exists) {
|
||||
@ -674,6 +679,7 @@ void fuse_drive::notify_fuse_main_exit(int &ret) {
|
||||
|
||||
auto fuse_drive::open_impl(std::string api_path,
|
||||
struct fuse_file_info *file_info) -> api_error {
|
||||
|
||||
file_info->flags &= (~O_CREAT);
|
||||
return create_impl(api_path, 0, file_info);
|
||||
}
|
||||
@ -700,6 +706,14 @@ auto fuse_drive::opendir_impl(std::string api_path,
|
||||
return api_error::directory_not_found;
|
||||
}
|
||||
|
||||
if ((file_info->flags & O_APPEND) == O_APPEND) {
|
||||
return api_error::directory_exists;
|
||||
}
|
||||
|
||||
if ((file_info->flags & O_EXCL) == O_EXCL) {
|
||||
return api_error::directory_exists;
|
||||
}
|
||||
|
||||
directory_item_list list{};
|
||||
res = provider_.get_directory_items(api_path, list);
|
||||
if (res != api_error::success) {
|
||||
|
@ -470,6 +470,37 @@ TYPED_TEST(fuse_test, create_fails_if_invalid) {
|
||||
EXPECT_EQ(EINVAL, errno);
|
||||
}
|
||||
}
|
||||
|
||||
TYPED_TEST(fuse_test, create_open_fails_if_path_is_directory) {
|
||||
std::array<int, 10U> ops{
|
||||
O_APPEND,
|
||||
O_EXCL | O_WRONLY,
|
||||
O_EXCL,
|
||||
O_RDWR | O_APPEND,
|
||||
O_RDWR | O_EXCL,
|
||||
O_RDWR | O_TRUNC,
|
||||
O_RDWR,
|
||||
O_TRUNC,
|
||||
O_WRONLY | O_APPEND,
|
||||
O_WRONLY,
|
||||
};
|
||||
|
||||
std::string dir_name{"create_test"};
|
||||
auto dir_path = this->create_directory_and_test(dir_name);
|
||||
|
||||
for (auto &&flags : ops) {
|
||||
auto handle = open(dir_path.c_str(), flags, ACCESSPERMS);
|
||||
EXPECT_EQ(-1, handle);
|
||||
if (handle != -1) {
|
||||
std::cout << std::oct << flags << std::endl;
|
||||
}
|
||||
|
||||
EXPECT_EQ(EISDIR, errno);
|
||||
}
|
||||
|
||||
this->rmdir_and_test(dir_path);
|
||||
}
|
||||
|
||||
} // namespace repertory
|
||||
|
||||
#endif // !defined(_WIN32)
|
||||
|
Loading…
x
Reference in New Issue
Block a user