[bug] Windows-to-Linux remote mount ignores CREATE_NEW #44
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

This commit is contained in:
Scott E. Graves 2025-04-04 10:55:01 -05:00
parent dfa170022a
commit 281d3758e0
4 changed files with 21 additions and 19 deletions

View File

@ -1126,9 +1126,7 @@ auto remote_server::winfsp_create(PWSTR file_name, UINT32 create_options,
utils::file::directory{file_path}.exists();
auto ret{static_cast<packet::error_type>(STATUS_SUCCESS)};
if (exists) {
ret = static_cast<packet::error_type>(STATUS_OBJECT_NAME_COLLISION);
} else {
if (not exists) {
if ((create_options & FILE_DIRECTORY_FILE) != 0U) {
attributes |= FILE_ATTRIBUTE_DIRECTORY;
} else {

View File

@ -188,20 +188,23 @@ auto remote_client::winfsp_create(PWSTR file_name, UINT32 create_options,
DECODE_OR_IGNORE(&response, normalized_name);
DECODE_OR_IGNORE(&response, exists);
*file_desc = reinterpret_cast<PVOID>(handle);
set_open_info(to_handle(*file_desc), open_info{
"",
nullptr,
{},
utils::string::to_utf8(file_name),
});
}
if (exists == 0U) {
*file_desc = reinterpret_cast<PVOID>(handle);
set_open_info(to_handle(*file_desc),
open_info{
"",
nullptr,
{},
utils::string::to_utf8(file_name),
});
}
#if defined(_WIN32)
if (ret == STATUS_OBJECT_NAME_COLLISION && exists != 0U) {
::SetLastError(ERROR_ALREADY_EXISTS);
}
else {
ret = STATUS_OBJECT_NAME_COLLISION;
::SetLastError(ERROR_FILE_EXISTS);
}
#endif // defined(_WIN32)
}
return ret;
}

View File

@ -131,14 +131,14 @@ auto remote_winfsp_drive::Create(PWSTR file_name, UINT32 create_options,
UINT64 allocation_size, PVOID * /*file_node*/,
PVOID *file_desc, OpenFileInfo *ofi)
-> NTSTATUS {
remote::file_info fi{};
remote::file_info f_info{};
std::string normalized_name;
BOOLEAN exists = 0;
BOOLEAN exists{0};
auto ret = remote_instance_->winfsp_create(
file_name, create_options, granted_access, attributes, allocation_size,
file_desc, &fi, normalized_name, exists);
file_desc, &f_info, normalized_name, exists);
if (ret == STATUS_SUCCESS) {
set_file_info(ofi->FileInfo, fi);
set_file_info(ofi->FileInfo, f_info);
auto file_path = utils::string::from_utf8(normalized_name);
wcsncpy(ofi->NormalizedName, file_path.data(), wcslen(file_path.c_str()));
ofi->NormalizedNameSize =

View File

@ -263,6 +263,7 @@ protected:
}
static void execute_unmount(auto args, auto location) {
std::this_thread::sleep_for(10s);
auto unmounted{false};
auto unmount_cmd =