Skip to content

Fix opendir/readdir returning no entries when drivers have major/minor device numbers#33

Merged
JohnAmadis merged 2 commits intomainfrom
copilot/fix-dmdevfs-directory-listing
Mar 10, 2026
Merged

Fix opendir/readdir returning no entries when drivers have major/minor device numbers#33
JohnAmadis merged 2 commits intomainfrom
copilot/fix-dmdevfs-directory-listing

Conversation

Copy link
Contributor

Copilot AI commented Mar 10, 2026

compare_driver_directory used exact-match between the listed path and a driver's parent directory. Drivers with major+minor numbers (e.g. path dmgpio8/1, parent dmgpio8/) never matched when listing /, so get_next_driver_node always returned NULL.

Changes

  • compare_driver_directory: extended from exact-match to prefix-match. Root "/" now matches all drivers; any other path matches drivers whose parent starts with path + "/".

  • read_next_subdir_name (new helper): given the listing base path and a driver's parent path, extracts the correct immediate child name:

    base="/"       full="dmgpio8/"   → "dmgpio8"
    base="/"       full="a/b/c/"     → "a"
    base="a/"      full="a/b/c/"     → "b"
    
  • readdir else branch: replaced read_dir_name_from_path(parent_dir, ...) with read_next_subdir_name(dir_node->directory_path, parent_dir, ...) so subdirectory entries always resolve to the correct depth-relative name instead of the leaf of the full parent path.

Original prompt

This section details on the original issue you should resolve

<issue_title>opendir i readdir nie zwracają plików</issue_title>
<issue_description>dmdevfs nie listuje katalogów w środku głównej ścieżki. Np:

[INFO] Preinit function not set
DMGPIO module initialized (STM32F7)
[INFO] Module enabled: dmgpio
dmdevfs: [INFO] Prepared driver module: dmgpio (was_loaded: 0, was_enabled: 0)
[███░░░] dmdevfs: Resolving driver interface: dmgpio
[████░░] dmdevfs: Creating driver context: dmgpio
dmgpio: [INFO] GPIO PI[0x2] configured: mode=output, pull=none, speed=minimum, circuit=push_pull
dmgpio: [INFO] GPIO device created for PI[0x2]
[█████░] dmdevfs: Reading driver node path: dmgpio
[  OK  ] dmdevfs: Configured driver: dmgpio (path: dmgpio8/1)

A potem:

stm32f746xg@/> ls /dev/

stm32f746xg@/> 

Z tego co widziałem, to coś jest nie tak w compare_driver_directory - path mamy /, a parent_dir jest dmgpio i przez to jakos get_next_driver_node zwraca NULL</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…ory to match subdirectories

Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix dmdevfs to list directories in main path Fix opendir/readdir returning no entries when drivers have major/minor device numbers Mar 10, 2026
@JohnAmadis JohnAmadis marked this pull request as ready for review March 10, 2026 15:27
@JohnAmadis JohnAmadis merged commit 53e3330 into main Mar 10, 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.

opendir i readdir nie zwracają plików

2 participants