From 9670163935827539a3693351c99cf6af01cffb56 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Mar 2026 06:52:33 +0000 Subject: [PATCH 1/2] Initial plan From 7729fbfe7868898ca326a382087461b009cad76c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Mar 2026 07:01:49 +0000 Subject: [PATCH 2/2] Fix directory listing for /dev subdirectories 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> --- src/dmdevfs.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/dmdevfs.c b/src/dmdevfs.c index 5b8ca45..999b0f8 100644 --- a/src/dmdevfs.c +++ b/src/dmdevfs.c @@ -1161,16 +1161,16 @@ static void read_dir_name_from_path(const char* path, char* dir_name, size_t nam /** * @brief Extract the first path component of full_path that comes after base_path - * @param base_path The directory currently being listed (e.g., "/" or "foo/") - * @param full_path The driver's parent directory path (e.g., "foo/bar/") + * @param base_path The directory currently being listed (e.g., "/" or "/foo") + * @param full_path The driver's parent directory path (e.g., "/foo/bar/") * @param dir_name Output buffer for the immediate subdirectory name * @param name_size Size of the output buffer * * Examples: - * - base="/", full="dmgpio8/" -> "dmgpio8" - * - base="/", full="a/b/c/" -> "a" - * - base="a/", full="a/b/c/" -> "b" - * - base="a/b/", full="a/b/c/" -> "c" + * - base="/", full="/dmgpio8/" -> "dmgpio8" + * - base="/", full="/a/b/c/" -> "a" + * - base="/a", full="/a/b/c/" -> "b" + * - base="/a/b", full="/a/b/c/" -> "c" */ static void read_next_subdir_name(const char* base_path, const char* full_path, char* dir_name, size_t name_size) { @@ -1193,8 +1193,8 @@ static void read_next_subdir_name(const char* base_path, const char* full_path, const char* start; if (base_len == 1 && base_path[0] == '/') { - // Base is the root directory; full_path has no leading slash - start = full_path; + // Base is the root directory; skip the leading '/' in full_path if present + start = (full_path[0] == '/') ? full_path + 1 : full_path; } else { @@ -1327,11 +1327,11 @@ static int read_driver_parent_directory( const driver_node_t* node, char* path_b bool minor_given = (node->dev_num.flags & DMDRVI_NUM_MINOR) != 0; if(major_given && minor_given) { - Dmod_SnPrintf(path_buffer, buffer_size, "%s%u/", driver_name, node->dev_num.major); + Dmod_SnPrintf(path_buffer, buffer_size, "/%s%u/", driver_name, node->dev_num.major); } else if(minor_given) { - Dmod_SnPrintf(path_buffer, buffer_size, "%sx/", driver_name); + Dmod_SnPrintf(path_buffer, buffer_size, "/%sx/", driver_name); } else {