Skip to content

Fix subdirectory listing under /dev mount point#37

Merged
JohnAmadis merged 2 commits intomainfrom
copilot/fix-directory-listing-issue-again
Mar 11, 2026
Merged

Fix subdirectory listing under /dev mount point#37
JohnAmadis merged 2 commits intomainfrom
copilot/fix-directory-listing-issue-again

Conversation

Copy link
Contributor

Copilot AI commented Mar 11, 2026

ls /dev/dmgpio8 failed with "Directory not found" because read_driver_parent_directory() built paths without a leading / (e.g. "dmgpio8/") while DMVFS strips the mount prefix and passes paths with a leading / (e.g. "/dmgpio8"), causing all comparisons in is_directory() to fail.

Changes

  • read_driver_parent_directory — prepend / to non-root parent paths:

    // Before
    Dmod_SnPrintf(path_buffer, buffer_size, "%s%u/", driver_name, node->dev_num.major);
    // After
    Dmod_SnPrintf(path_buffer, buffer_size, "/%s%u/", driver_name, node->dev_num.major);
  • read_next_subdir_name — when listing from root /, skip the leading / now present in full_path before extracting the next component:

    // Before: assumed full_path had no leading slash
    start = full_path;
    // After
    start = (full_path[0] == '/') ? full_path + 1 : full_path;
Original prompt

This section details on the original issue you should resolve

<issue_title>Problem z listowaniem katalogów</issue_title>
<issue_description>Już jest lepiej, bo da się wylistować główny katalog, ale już plików wewnątrz nie:

stm32f746xg@/> ls /dev
dmgpio8  
[WARN] dmheap: Module ls is not registered.
stm32f746xg@/> ls /dev/dmgpio8
dmdevfs: [ERROR] Directory not found: /dmgpio8
dmdevfs: [ERROR] File not found: /dmgpio8
[ERROR] Failed to open file '/dev/dmgpio8'
ls: [ERROR] Cannot access '/dev/dmgpio8': No such file or directory
[WARN] dmheap: Module ls is not registered.
stm32f746xg@/> 

```</issue_description>

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

<comments>
</comments>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

read_driver_parent_directory() was generating paths without a leading
'/' (e.g. "dmgpio8/") while DMVFS passes paths with a leading '/'
(e.g. "/dmgpio8"). This caused all path comparisons in is_directory()
and related functions to fail, resulting in:

  dmdevfs: [ERROR] Directory not found: /dmgpio8
  dmdevfs: [ERROR] File not found: /dmgpio8

Fix:
- read_driver_parent_directory: add leading '/' to non-root parent
  paths ("/%s%u/" and "/%sx/" instead of "%s%u/" and "%sx/")
- read_next_subdir_name: when listing from root '/', skip the leading
  '/' now present in full_path before extracting the next component

Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix directory listing issue for /dev folders Fix subdirectory listing under /dev mount point Mar 11, 2026
@JohnAmadis JohnAmadis marked this pull request as ready for review March 11, 2026 08:45
@JohnAmadis JohnAmadis merged commit cafacd0 into main Mar 11, 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.

Problem z listowaniem katalogów

2 participants