Compare commits

..

No commits in common. "dfa170022a8583ea786ffc8fff7e543fe85db57e" and "c2dbfc970a1f72023a791d6162f127c8c6498f5f" have entirely different histories.

4 changed files with 55 additions and 62 deletions

View File

@ -10,7 +10,6 @@
* ~~\#33 Complete initial v2.0 documentation~~ * ~~\#33 Complete initial v2.0 documentation~~
* \#42 [bug] Remote mount directory listing on Windows connected to Linux is failing * \#42 [bug] Remote mount directory listing on Windows connected to Linux is failing
* \#43 [bug] Directories are not importing properly for Sia * \#43 [bug] Directories are not importing properly for Sia
* \#44 [bug] Windows-to-Linux remote mount ignores `CREATE_NEW`
### Changes from v2.0.5-rc ### Changes from v2.0.5-rc

View File

@ -222,6 +222,7 @@ using WCHAR = wchar_t;
#define MAX_PATH 260 #define MAX_PATH 260
#define STATUS_SUCCESS std::uint32_t{0U}
#define STATUS_ACCESS_DENIED std::uint32_t{0xC0000022L} #define STATUS_ACCESS_DENIED std::uint32_t{0xC0000022L}
#define STATUS_DEVICE_BUSY std::uint32_t{0x80000011L} #define STATUS_DEVICE_BUSY std::uint32_t{0x80000011L}
#define STATUS_DEVICE_INSUFFICIENT_RESOURCES std::uint32_t{0xC0000468L} #define STATUS_DEVICE_INSUFFICIENT_RESOURCES std::uint32_t{0xC0000468L}
@ -234,13 +235,11 @@ using WCHAR = wchar_t;
#define STATUS_INVALID_HANDLE std::uint32_t{0xC0000006L} #define STATUS_INVALID_HANDLE std::uint32_t{0xC0000006L}
#define STATUS_INVALID_IMAGE_FORMAT std::uint32_t{0xC000007BL} #define STATUS_INVALID_IMAGE_FORMAT std::uint32_t{0xC000007BL}
#define STATUS_INVALID_PARAMETER std::uint32_t{0xC000000DL} #define STATUS_INVALID_PARAMETER std::uint32_t{0xC000000DL}
#define STATUS_NOT_IMPLEMENTED std::uint32_t{0xC0000002L}
#define STATUS_NO_MEMORY std::uint32_t{0xC0000017L} #define STATUS_NO_MEMORY std::uint32_t{0xC0000017L}
#define STATUS_OBJECT_NAME_COLLISION std::uint32_t{0xC0000035L} #define STATUS_NOT_IMPLEMENTED std::uint32_t{0xC0000002L}
#define STATUS_OBJECT_NAME_EXISTS std::uint32_t{0x40000000L} #define STATUS_OBJECT_NAME_EXISTS std::uint32_t{0x40000000L}
#define STATUS_OBJECT_NAME_NOT_FOUND std::uint32_t{0xC0000034L} #define STATUS_OBJECT_NAME_NOT_FOUND std::uint32_t{0xC0000034L}
#define STATUS_OBJECT_PATH_INVALID std::uint32_t{0xC0000039L} #define STATUS_OBJECT_PATH_INVALID std::uint32_t{0xC0000039L}
#define STATUS_SUCCESS std::uint32_t{0U}
#define STATUS_UNEXPECTED_IO_ERROR std::uint32_t{0xC00000E9L} #define STATUS_UNEXPECTED_IO_ERROR std::uint32_t{0xC00000E9L}
#define CONVERT_STATUS_NOT_IMPLEMENTED(e) \ #define CONVERT_STATUS_NOT_IMPLEMENTED(e) \

View File

@ -1120,56 +1120,49 @@ auto remote_server::winfsp_create(PWSTR file_name, UINT32 create_options,
-> packet::error_type { -> packet::error_type {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
auto relative_path = utils::string::to_utf8(file_name); const auto relative_path = utils::string::to_utf8(file_name);
auto file_path = construct_path(relative_path); const auto file_path = construct_path(relative_path);
exists = utils::file::file{file_path}.exists() || exists = utils::file::file(file_path).exists();
utils::file::directory{file_path}.exists();
auto ret{static_cast<packet::error_type>(STATUS_SUCCESS)}; if ((create_options & FILE_DIRECTORY_FILE) != 0U) {
if (exists) { attributes |= FILE_ATTRIBUTE_DIRECTORY;
ret = static_cast<packet::error_type>(STATUS_OBJECT_NAME_COLLISION);
} else { } else {
if ((create_options & FILE_DIRECTORY_FILE) != 0U) { attributes &= static_cast<UINT32>(~FILE_ATTRIBUTE_DIRECTORY);
attributes |= FILE_ATTRIBUTE_DIRECTORY; attributes |= FILE_ATTRIBUTE_ARCHIVE;
} else {
attributes &= static_cast<UINT32>(~FILE_ATTRIBUTE_DIRECTORY);
attributes |= FILE_ATTRIBUTE_ARCHIVE;
}
remote::file_mode mode{0U};
std::uint32_t flags{0U};
utils::windows_create_to_unix(create_options, granted_access, flags, mode);
auto res{0};
if ((create_options & FILE_DIRECTORY_FILE) != 0U) {
res = mkdir(file_path.c_str(), mode);
if (res >= 0) {
res = open(file_path.c_str(), static_cast<int>(flags));
}
} else {
res = open(file_path.c_str(), static_cast<int>(flags), mode);
}
if (res >= 0) {
*file_desc = reinterpret_cast<PVOID>(res);
drive_.set_item_meta(construct_api_path(file_path), META_ATTRIBUTES,
std::to_string(attributes));
set_open_info(res, open_info{
"",
nullptr,
{},
file_path,
});
const auto api_path = utils::path::create_api_path(relative_path);
normalized_name = utils::string::replace_copy(api_path, '/', '\\');
populate_file_info(api_path, 0, attributes, *file_info);
}
ret = static_cast<packet::error_type>(
utils::unix_error_to_windows((res < 0) ? errno : 0));
} }
remote::file_mode mode{0U};
std::uint32_t flags{0U};
utils::windows_create_to_unix(create_options, granted_access, flags, mode);
int res = 0;
if ((create_options & FILE_DIRECTORY_FILE) != 0U) {
res = mkdir(file_path.c_str(), mode);
if (res >= 0) {
res = open(file_path.c_str(), static_cast<int>(flags));
}
} else {
res = open(file_path.c_str(), static_cast<int>(flags), mode);
}
if (res >= 0) {
*file_desc = reinterpret_cast<PVOID>(res);
drive_.set_item_meta(construct_api_path(file_path), META_ATTRIBUTES,
std::to_string(attributes));
set_open_info(res, open_info{
"",
nullptr,
{},
file_path,
});
const auto api_path = utils::path::create_api_path(relative_path);
normalized_name = utils::string::replace_copy(api_path, '/', '\\');
populate_file_info(api_path, 0, attributes, *file_info);
}
auto ret = static_cast<packet::error_type>(
utils::unix_error_to_windows((res < 0) ? errno : 0));
RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, file_path, ret); RAISE_REMOTE_FUSE_SERVER_EVENT(function_name, file_path, ret);
return ret; return ret;
} }

View File

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