Skip to content

fix: device nodes incorrectly reported as directories by Dmod_ReadDirEx#50

Merged
JohnAmadis merged 2 commits into
mainfrom
copilot/fix-devices-reporting-issue
May 26, 2026
Merged

fix: device nodes incorrectly reported as directories by Dmod_ReadDirEx#50
JohnAmadis merged 2 commits into
mainfrom
copilot/fix-devices-reporting-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 26, 2026

Dmod_ReadDirEx returns Dmod_DirEntryType_Dir for device nodes (e.g. led_ld1 under /dev/dmgpio8/) because dmdrvi_stat_t.mode from the driver can have the DMFSI_ATTR_DIRECTORY bit (0x10) set, and _readdir was assigning it directly to entry->attr.

Changes

  • src/dmdevfs.c_readdir: Clear DMFSI_ATTR_DIRECTORY from entry->attr when populating a device node (file) entry. Device nodes in the file_should_be_listed branch are by definition files; the directory bit must never propagate from the driver's stat mode.

    // Before
    entry->attr = stat.mode;
    
    // After
    entry->attr = stat.mode & ~DMFSI_ATTR_DIRECTORY;
  • src/dmdevfs.c_readdir: Initialize dmdrvi_stat_t stat = {0} to prevent uninitialized memory from leaking into entry attributes when a driver does not populate all stat fields.

Copilot AI linked an issue May 26, 2026 that may be closed by this pull request
Device nodes are files, not directories. Ensure the DMFSI_ATTR_DIRECTORY
bit is never set in entry->attr when returning a device node entry so that
Dmod_ReadDirEx correctly reports Dmod_DirEntryType_File instead of
Dmod_DirEntryType_Dir.

Also initialize dmdrvi_stat_t to zero to avoid using uninitialized memory.

Fixes: tab completion appending '/' to device node names in dmell shell.

Agent-Logs-Url: https://github.com/choco-technologies/dmdevfs/sessions/7c0e9d52-6e03-439d-b1ff-ba896e68f2ed

Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Dmod_ReadDirEx reporting incorrect directory type fix: device nodes incorrectly reported as directories by Dmod_ReadDirEx May 26, 2026
Copilot AI requested a review from JohnAmadis May 26, 2026 07:43
@JohnAmadis JohnAmadis marked this pull request as ready for review May 26, 2026 07:59
@JohnAmadis JohnAmadis merged commit a3171e9 into main May 26, 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.

Dmod_ReadDirEx

2 participants