@@ -1161,16 +1161,16 @@ static void read_dir_name_from_path(const char* path, char* dir_name, size_t nam
11611161
11621162/**
11631163 * @brief Extract the first path component of full_path that comes after base_path
1164- * @param base_path The directory currently being listed (e.g., "/" or "foo/ ")
1165- * @param full_path The driver's parent directory path (e.g., "foo/bar/")
1164+ * @param base_path The directory currently being listed (e.g., "/" or "/foo ")
1165+ * @param full_path The driver's parent directory path (e.g., "/ foo/bar/")
11661166 * @param dir_name Output buffer for the immediate subdirectory name
11671167 * @param name_size Size of the output buffer
11681168 *
11691169 * Examples:
1170- * - base="/", full="dmgpio8/" -> "dmgpio8"
1171- * - base="/", full="a/b/c/" -> "a"
1172- * - base="a/ ", full="a/b/c/" -> "b"
1173- * - base="a/b/ ", full="a/b/c/" -> "c"
1170+ * - base="/", full="/ dmgpio8/" -> "dmgpio8"
1171+ * - base="/", full="/ a/b/c/" -> "a"
1172+ * - base="/a ", full="/ a/b/c/" -> "b"
1173+ * - base="/ a/b", full="/ a/b/c/" -> "c"
11741174 */
11751175static void read_next_subdir_name (const char * base_path , const char * full_path , char * dir_name , size_t name_size )
11761176{
@@ -1193,8 +1193,8 @@ static void read_next_subdir_name(const char* base_path, const char* full_path,
11931193 const char * start ;
11941194 if (base_len == 1 && base_path [0 ] == '/' )
11951195 {
1196- // Base is the root directory; full_path has no leading slash
1197- start = full_path ;
1196+ // Base is the root directory; skip the leading '/' in full_path if present
1197+ start = ( full_path [ 0 ] == '/' ) ? full_path + 1 : full_path ;
11981198 }
11991199 else
12001200 {
@@ -1327,11 +1327,11 @@ static int read_driver_parent_directory( const driver_node_t* node, char* path_b
13271327 bool minor_given = (node -> dev_num .flags & DMDRVI_NUM_MINOR ) != 0 ;
13281328 if (major_given && minor_given )
13291329 {
1330- Dmod_SnPrintf (path_buffer , buffer_size , "%s%u/" , driver_name , node -> dev_num .major );
1330+ Dmod_SnPrintf (path_buffer , buffer_size , "/ %s%u/" , driver_name , node -> dev_num .major );
13311331 }
13321332 else if (minor_given )
13331333 {
1334- Dmod_SnPrintf (path_buffer , buffer_size , "%sx/" , driver_name );
1334+ Dmod_SnPrintf (path_buffer , buffer_size , "/ %sx/" , driver_name );
13351335 }
13361336 else
13371337 {
0 commit comments