Skip to content

Deduplicate directory entries in readdir for shared driver parent paths#52

Merged
JohnAmadis merged 2 commits into
mainfrom
copilot/fix-dmgpio8-duplicates
May 28, 2026
Merged

Deduplicate directory entries in readdir for shared driver parent paths#52
JohnAmadis merged 2 commits into
mainfrom
copilot/fix-dmgpio8-duplicates

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 27, 2026

Multiple dmgpio section configurations can resolve to the same parent directory (e.g. /dmgpio8/), causing readdir("/") to emit duplicate directory names (dmgpio8 twice). This PR updates directory iteration so each immediate subdirectory is returned once per listing pass.

  • Root cause

    • readdir advanced one driver at a time and emitted directory names derived from parent paths without collapsing consecutive entries mapping to the same immediate subdirectory.
  • Change in directory iteration

    • In _readdir, after emitting a directory entry, iteration now skips subsequent driver nodes that would produce the same read_next_subdir_name(...) result for the current listing path.
    • File entries in the current directory are not collapsed; only duplicate directory-name emissions are filtered.
  • Scope

    • Minimal localized change in src/dmdevfs.c (_readdir flow), no API or path-format changes.
// After emitting a directory entry, skip drivers that map to same subdir name
driver_node_t* next_driver = get_next_driver_node(ctx, driver, dir_node->directory_path);
if (!file_should_be_listed) {
    while (next_driver != NULL) {
        read_driver_parent_directory(next_driver, next_parent_dir, sizeof(next_parent_dir));
        read_next_subdir_name(dir_node->directory_path, next_parent_dir, next_subdir_name, sizeof(next_subdir_name));
        if (strcmp(next_subdir_name, entry->name) != 0) break;
        next_driver = get_next_driver_node(ctx, next_driver, dir_node->directory_path);
    }
}
dir_node->driver = next_driver;

Copilot AI linked an issue May 27, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix duplicated dmgpio8 directories Deduplicate directory entries in readdir for shared driver parent paths May 27, 2026
Copilot AI requested a review from JohnAmadis May 27, 2026 15:36
@JohnAmadis JohnAmadis marked this pull request as ready for review May 28, 2026 05:34
@JohnAmadis JohnAmadis merged commit 117d5bf into main May 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Zduplikowane katalogi dmgpio8

2 participants