Skip to content

Commit 2183763

Browse files
authored
Merge pull request #26 from choco-technologies/copilot/fix-file-listing-issue-again
Fix misleading error when opening device file as directory
2 parents 79691d9 + 374bca9 commit 2183763

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/dmdevfs.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,15 @@ dmod_dmfsi_dif_api_declaration( 1.0, dmdevfs, int, _opendir, (dmfsi_context_t ct
601601

602602
if (!is_directory(ctx, path))
603603
{
604+
// Check if the path is a file (device node)
605+
driver_node_t* driver_node = find_driver_node(ctx, path);
606+
if (driver_node != NULL)
607+
{
608+
// Path exists but is a file, not a directory
609+
DMOD_LOG_ERROR("Not a directory: %s\n", path);
610+
return DMFSI_ERR_NOT_FOUND;
611+
}
612+
// Path doesn't exist at all
604613
DMOD_LOG_ERROR("Directory not found: %s\n", path);
605614
return DMFSI_ERR_NOT_FOUND;
606615
}

0 commit comments

Comments
 (0)