[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

This commit is contained in:
Scott E. Graves 2025-04-02 13:40:15 -05:00
parent 883de836c6
commit bb85015733
3 changed files with 34 additions and 13 deletions

View File

@ -59,7 +59,8 @@ private:
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:
// FUSE Layer

View File

@ -1394,7 +1394,7 @@ auto remote_server::winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/,
auto ret = static_cast<packet::error_type>(
has_open_info(static_cast<native_handle>(handle), STATUS_INVALID_HANDLE));
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)));
directory_iterator iterator(drive_.get_directory_items(api_path));
auto offset = marker == nullptr
@ -1405,7 +1405,7 @@ auto remote_server::winfsp_read_directory(PVOID file_desc, PWSTR /*pattern*/,
json item;
while (iterator.get_json(offset++, item) == 0) {
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) {
utils::error::raise_error(function_name, e, "exception occurred");
}
@ -1679,10 +1679,34 @@ auto remote_server::json_release_directory_snapshot(
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>();
if (api_path == "." || api_path == "..") {
return item;
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;
}
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(

View File

@ -361,11 +361,10 @@ auto remote_winfsp_drive::ReadDirectory(PVOID /*file_node*/, PVOID file_desc,
&ret)) {
auto item_found = false;
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(
utils::path::strip_to_file_name(item_path));
if (not marker || (marker && item_found)) {
// if (not utils::path::is_ads_file_path(item_path)) {
union {
UINT8 B[FIELD_OFFSET(FSP_FSCTL_DIR_INFO, FileNameBuf) +
((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()) *
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) {
::wcscpy_s(&directory_info->FileNameBuf[0],
repertory::max_path_length, &display_name[0]);
@ -394,7 +391,6 @@ auto remote_winfsp_drive::ReadDirectory(PVOID /*file_node*/, PVOID file_desc,
break;
}
}
// }
} else {
item_found = display_name == std::wstring(marker);
}