[bug] Remote mount directory listing on Windows connected to Linux is failing #42
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit
This commit is contained in:
parent
883de836c6
commit
bb85015733
@ -59,7 +59,8 @@ private:
|
|||||||
|
|
||||||
static void populate_stat(const struct stat64 &unix_st, remote::stat &r_stat);
|
static void populate_stat(const struct stat64 &unix_st, remote::stat &r_stat);
|
||||||
|
|
||||||
[[nodiscard]] auto update_to_windows_format(json &item) -> json &;
|
[[nodiscard]] auto update_to_windows_format(const std::string &root_api_path,
|
||||||
|
json &item) -> json &;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// FUSE Layer
|
// FUSE Layer
|
||||||
|
@ -1394,7 +1394,7 @@ auto remote_server::winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/,
|
|||||||
auto ret = static_cast<packet::error_type>(
|
auto ret = static_cast<packet::error_type>(
|
||||||
has_open_info(static_cast<native_handle>(handle), STATUS_INVALID_HANDLE));
|
has_open_info(static_cast<native_handle>(handle), STATUS_INVALID_HANDLE));
|
||||||
if (ret == STATUS_SUCCESS) {
|
if (ret == STATUS_SUCCESS) {
|
||||||
const auto api_path = construct_api_path(
|
auto api_path = construct_api_path(
|
||||||
get_open_file_path(static_cast<native_handle>(handle)));
|
get_open_file_path(static_cast<native_handle>(handle)));
|
||||||
directory_iterator iterator(drive_.get_directory_items(api_path));
|
directory_iterator iterator(drive_.get_directory_items(api_path));
|
||||||
auto offset = marker == nullptr
|
auto offset = marker == nullptr
|
||||||
@ -1405,7 +1405,7 @@ auto remote_server::winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/,
|
|||||||
json item;
|
json item;
|
||||||
while (iterator.get_json(offset++, item) == 0) {
|
while (iterator.get_json(offset++, item) == 0) {
|
||||||
try {
|
try {
|
||||||
item_list.emplace_back(update_to_windows_format(item));
|
item_list.emplace_back(update_to_windows_format(api_path, item));
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
utils::error::raise_error(function_name, e, "exception occurred");
|
utils::error::raise_error(function_name, e, "exception occurred");
|
||||||
}
|
}
|
||||||
@ -1679,12 +1679,36 @@ auto remote_server::json_release_directory_snapshot(
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto remote_server::update_to_windows_format(json &item) -> json & {
|
auto remote_server::update_to_windows_format(const std::string &root_api_path,
|
||||||
|
json &item) -> json & {
|
||||||
auto api_path = item[JSON_API_PATH].get<std::string>();
|
auto api_path = item[JSON_API_PATH].get<std::string>();
|
||||||
if (api_path == "." || api_path == "..") {
|
if (api_path == ".") {
|
||||||
|
api_path = root_api_path;
|
||||||
|
|
||||||
|
api_meta_map meta;
|
||||||
|
auto res = drive_.get_item_meta(api_path, meta);
|
||||||
|
if (res != api_error::success) {
|
||||||
|
utils::error::raise_api_path_error(function_name, api_path, error,
|
||||||
|
"failed to get . meta");
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
item[JSON_META] = meta;
|
||||||
|
} else if (api_path == "..") {
|
||||||
|
// TODO handle '/' parent
|
||||||
|
api_path = utils::path::get_parent_api_path(root_api_path);
|
||||||
|
|
||||||
|
api_meta_map meta;
|
||||||
|
auto res = drive_.get_item_meta(api_path, meta);
|
||||||
|
if (res != api_error::success) {
|
||||||
|
utils::error::raise_api_path_error(function_name, api_path, error,
|
||||||
|
"failed to get .. meta");
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
item[JSON_META] = meta;
|
||||||
|
}
|
||||||
|
|
||||||
item[JSON_META][META_ACCESSED] = std::to_string(
|
item[JSON_META][META_ACCESSED] = std::to_string(
|
||||||
utils::string::to_uint64(empty_as_zero(item[JSON_META][META_ACCESSED])));
|
utils::string::to_uint64(empty_as_zero(item[JSON_META][META_ACCESSED])));
|
||||||
item[JSON_META][META_CREATION] = std::to_string(
|
item[JSON_META][META_CREATION] = std::to_string(
|
||||||
|
@ -361,11 +361,10 @@ auto remote_winfsp_drive::ReadDirectory(PVOID /*file_node*/, PVOID file_desc,
|
|||||||
&ret)) {
|
&ret)) {
|
||||||
auto item_found = false;
|
auto item_found = false;
|
||||||
for (const auto &item : item_list) {
|
for (const auto &item : item_list) {
|
||||||
auto item_path = item["path"].get<std::string>();
|
auto item_path = item[JSON_API_PATH].get<std::string>();
|
||||||
auto display_name = utils::string::from_utf8(
|
auto display_name = utils::string::from_utf8(
|
||||||
utils::path::strip_to_file_name(item_path));
|
utils::path::strip_to_file_name(item_path));
|
||||||
if (not marker || (marker && item_found)) {
|
if (not marker || (marker && item_found)) {
|
||||||
// if (not utils::path::is_ads_file_path(item_path)) {
|
|
||||||
union {
|
union {
|
||||||
UINT8 B[FIELD_OFFSET(FSP_FSCTL_DIR_INFO, FileNameBuf) +
|
UINT8 B[FIELD_OFFSET(FSP_FSCTL_DIR_INFO, FileNameBuf) +
|
||||||
((repertory::max_path_length + 1U) * sizeof(WCHAR))];
|
((repertory::max_path_length + 1U) * sizeof(WCHAR))];
|
||||||
@ -380,10 +379,8 @@ auto remote_winfsp_drive::ReadDirectory(PVOID /*file_node*/, PVOID file_desc,
|
|||||||
display_name.size()) *
|
display_name.size()) *
|
||||||
sizeof(WCHAR)));
|
sizeof(WCHAR)));
|
||||||
|
|
||||||
if (not item["meta"].empty() ||
|
|
||||||
((item_path != ".") && (item_path != ".."))) {
|
|
||||||
populate_file_info(item, directory_info->FileInfo);
|
populate_file_info(item, directory_info->FileInfo);
|
||||||
}
|
|
||||||
if (ret == STATUS_SUCCESS) {
|
if (ret == STATUS_SUCCESS) {
|
||||||
::wcscpy_s(&directory_info->FileNameBuf[0],
|
::wcscpy_s(&directory_info->FileNameBuf[0],
|
||||||
repertory::max_path_length, &display_name[0]);
|
repertory::max_path_length, &display_name[0]);
|
||||||
@ -394,7 +391,6 @@ auto remote_winfsp_drive::ReadDirectory(PVOID /*file_node*/, PVOID file_desc,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
} else {
|
} else {
|
||||||
item_found = display_name == std::wstring(marker);
|
item_found = display_name == std::wstring(marker);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user