winfsp unit tests and fixes
This commit is contained in:
@@ -361,7 +361,7 @@ auto remote_winfsp_drive::ReadDirectory(PVOID /*file_node*/, PVOID file_desc,
|
||||
// if (not utils::path::is_ads_file_path(item_path)) {
|
||||
union {
|
||||
UINT8 B[FIELD_OFFSET(FSP_FSCTL_DIR_INFO, FileNameBuf) +
|
||||
((MAX_PATH + 1) * sizeof(WCHAR))];
|
||||
((repertory::max_path_length + 1U) * sizeof(WCHAR))];
|
||||
FSP_FSCTL_DIR_INFO D;
|
||||
} directory_info_buffer;
|
||||
|
||||
@@ -369,7 +369,8 @@ auto remote_winfsp_drive::ReadDirectory(PVOID /*file_node*/, PVOID file_desc,
|
||||
::ZeroMemory(directory_info, sizeof(*directory_info));
|
||||
directory_info->Size = static_cast<UINT16>(
|
||||
FIELD_OFFSET(FSP_FSCTL_DIR_INFO, FileNameBuf) +
|
||||
(std::min(static_cast<size_t>(MAX_PATH), display_name.size()) *
|
||||
(std::min(static_cast<size_t>(repertory::max_path_length),
|
||||
display_name.size()) *
|
||||
sizeof(WCHAR)));
|
||||
|
||||
if (not item["meta"].empty() ||
|
||||
@@ -377,8 +378,8 @@ auto remote_winfsp_drive::ReadDirectory(PVOID /*file_node*/, PVOID file_desc,
|
||||
populate_file_info(item, directory_info->FileInfo);
|
||||
}
|
||||
if (ret == STATUS_SUCCESS) {
|
||||
::wcscpy_s(&directory_info->FileNameBuf[0], MAX_PATH,
|
||||
&display_name[0]);
|
||||
::wcscpy_s(&directory_info->FileNameBuf[0],
|
||||
repertory::max_path_length, &display_name[0]);
|
||||
|
||||
FspFileSystemFillDirectoryBuffer(directory_buffer, directory_info,
|
||||
&ret);
|
||||
|
@@ -568,7 +568,7 @@ auto winfsp_drive::Init(PVOID host) -> NTSTATUS {
|
||||
file_system_host->SetCasePreservedNames(TRUE);
|
||||
file_system_host->SetNamedStreams(FALSE);
|
||||
file_system_host->SetUnicodeOnDisk(TRUE);
|
||||
// file_system_host->SetMaxComponentLength(4096U);
|
||||
file_system_host->SetMaxComponentLength(255U);
|
||||
file_system_host->SetPersistentAcls(FALSE);
|
||||
file_system_host->SetPostCleanupWhenModifiedOnly(TRUE);
|
||||
file_system_host->SetPassQueryDirectoryPattern(FALSE);
|
||||
@@ -926,7 +926,7 @@ auto winfsp_drive::ReadDirectory(PVOID /*file_node*/, PVOID file_desc,
|
||||
utils::path::strip_to_file_name(dir_item.api_path));
|
||||
union {
|
||||
UINT8 B[FIELD_OFFSET(FSP_FSCTL_DIR_INFO, FileNameBuf) +
|
||||
((MAX_PATH + 1) * sizeof(WCHAR))];
|
||||
((repertory::max_path_length + 1U) * sizeof(WCHAR))];
|
||||
FSP_FSCTL_DIR_INFO D;
|
||||
} directory_info_buffer;
|
||||
|
||||
@@ -934,14 +934,14 @@ auto winfsp_drive::ReadDirectory(PVOID /*file_node*/, PVOID file_desc,
|
||||
::ZeroMemory(directory_info, sizeof(*directory_info));
|
||||
directory_info->Size = static_cast<UINT16>(
|
||||
FIELD_OFFSET(FSP_FSCTL_DIR_INFO, FileNameBuf) +
|
||||
(std::min(static_cast<size_t>(MAX_PATH),
|
||||
(std::min(static_cast<size_t>(repertory::max_path_length),
|
||||
display_name.size()) *
|
||||
sizeof(WCHAR)));
|
||||
|
||||
populate_file_info(dir_item.size, dir_item.meta,
|
||||
directory_info->FileInfo);
|
||||
::wcscpy_s(&directory_info->FileNameBuf[0U], MAX_PATH,
|
||||
display_name.data());
|
||||
::wcscpy_s(&directory_info->FileNameBuf[0U],
|
||||
repertory::max_path_length, display_name.data());
|
||||
|
||||
FspFileSystemFillDirectoryBuffer(
|
||||
directory_buffer, directory_info, &status_result);
|
||||
|
@@ -28,6 +28,14 @@
|
||||
//
|
||||
#include "fixtures/winfsp_fixture.hpp"
|
||||
|
||||
// TODO revisit create_related
|
||||
// TODO revisit create_allocation
|
||||
// TODO revisit create_sd
|
||||
// TODO revisit create_notraverse
|
||||
// TODO revisit create_backup
|
||||
// TODO revisit create_restore
|
||||
// TODO revisit create_share
|
||||
|
||||
namespace repertory {
|
||||
TYPED_TEST_CASE(winfsp_test, winfsp_provider_types);
|
||||
|
||||
|
75
repertory/repertory_test/src/winfsp_drive_create_nl_test.cpp
Normal file
75
repertory/repertory_test/src/winfsp_drive_create_nl_test.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#if defined(_WIN32)
|
||||
|
||||
//
|
||||
// Implemented test cases based on WinFsp tests:
|
||||
// https://github.com/winfsp/winfsp/blob/v2.0/tst/winfsp-tests
|
||||
//
|
||||
#include "fixtures/winfsp_fixture.hpp"
|
||||
|
||||
namespace repertory {
|
||||
TYPED_TEST_CASE(winfsp_test, winfsp_provider_types);
|
||||
|
||||
TYPED_TEST(winfsp_test, cr8_nl_can_create_file_of_max_component_length) {
|
||||
DWORD max_length{};
|
||||
EXPECT_TRUE(::GetVolumeInformationA(this->mount_location.c_str(), nullptr, 0,
|
||||
nullptr, &max_length, nullptr, nullptr,
|
||||
0));
|
||||
EXPECT_EQ(255U, max_length);
|
||||
|
||||
auto file_path = utils::path::combine(this->mount_location,
|
||||
{
|
||||
std::string(max_length - 1U, 'a'),
|
||||
});
|
||||
|
||||
auto handle =
|
||||
::CreateFileA(file_path.c_str(), GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, 0, CREATE_NEW,
|
||||
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_DELETE_ON_CLOSE, 0);
|
||||
EXPECT_NE(INVALID_HANDLE_VALUE, handle);
|
||||
EXPECT_TRUE(::CloseHandle(handle));
|
||||
}
|
||||
|
||||
TYPED_TEST(winfsp_test,
|
||||
cr8_nl_can_not_create_file_greater_than_max_component_length) {
|
||||
DWORD max_length{};
|
||||
EXPECT_TRUE(::GetVolumeInformationA(this->mount_location.c_str(), nullptr, 0,
|
||||
nullptr, &max_length, nullptr, nullptr,
|
||||
0));
|
||||
EXPECT_EQ(255U, max_length);
|
||||
|
||||
auto file_path = utils::path::combine(this->mount_location,
|
||||
{
|
||||
std::string(max_length, 'a'),
|
||||
});
|
||||
|
||||
auto handle =
|
||||
::CreateFileA(file_path.c_str(), GENERIC_READ | GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE, 0, CREATE_NEW,
|
||||
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_DELETE_ON_CLOSE, 0);
|
||||
EXPECT_EQ(INVALID_HANDLE_VALUE, handle);
|
||||
EXPECT_EQ(ERROR_INVALID_NAME, ::GetLastError());
|
||||
}
|
||||
} // namespace repertory
|
||||
|
||||
#endif // defined(_WIN32)
|
40
repertory/repertory_test/src/winfsp_drive_test.cpp
Normal file
40
repertory/repertory_test/src/winfsp_drive_test.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
Copyright <2018-2024> <scott.e.graves@protonmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
#if defined(_WIN32)
|
||||
|
||||
//
|
||||
// Implemented test cases based on WinFsp tests:
|
||||
// https://github.com/winfsp/winfsp/blob/v2.0/tst/winfsp-tests
|
||||
//
|
||||
#include "fixtures/winfsp_fixture.hpp"
|
||||
|
||||
namespace repertory {
|
||||
TYPED_TEST_CASE(winfsp_test, winfsp_provider_types);
|
||||
|
||||
TYPED_TEST(winfsp_test, can_set_current_directory_to_mount_location) {
|
||||
EXPECT_TRUE(::SetCurrentDirectoryA(this->mount_location.c_str()));
|
||||
|
||||
EXPECT_TRUE(::SetCurrentDirectoryA(this->current_directory.string().c_str()));
|
||||
}
|
||||
} // namespace repertory
|
||||
|
||||
#endif // defined(_WIN32)
|
Reference in New Issue
Block a user