Skip to content

Commit f1978be

Browse files
committed
Add is_driver() function to check if a path corresponds to a driver
1 parent 15af9a1 commit f1978be

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/dmdevfs.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ static int configure_drivers(dmfsi_context_t ctx, const char* driver_name, const
7575
static driver_node_t* configure_driver(const char* driver_name, dmini_context_t config_ctx);
7676
static int unconfigure_drivers(dmfsi_context_t ctx);
7777
static bool is_file(const char* path);
78+
static bool is_driver( const char* name);
7879
static void read_base_name(const char* path, char* base_name, size_t name_size);
7980
static dmini_context_t read_driver_for_config(const char* config_path, char* driver_name, size_t name_size, const char* default_driver);
8081
static Dmod_Context_t* prepare_driver_module(const char* driver_name, bool* was_loaded, bool* was_enabled);
@@ -855,6 +856,10 @@ static int configure_drivers(dmfsi_context_t ctx, const char* driver_name, const
855856
// read driver name from directory name
856857
char module_name[DMOD_MAX_MODULE_NAME_LENGTH];
857858
read_base_name(entry, module_name, sizeof(module_name));
859+
if(is_driver(module_name))
860+
{
861+
driver_name = module_name;
862+
}
858863
int res = configure_drivers(ctx, driver_name, full_path);
859864
if (res != DMFSI_OK)
860865
{
@@ -981,6 +986,15 @@ static bool is_file(const char* path)
981986
return true; // It's a file
982987
}
983988

989+
/**
990+
* @brief Check if a path is a directory
991+
*/
992+
static bool is_driver( const char* name)
993+
{
994+
char module_name[DMOD_MAX_MODULE_NAME_LENGTH] = {0};
995+
return Dmod_FindMatch(name, module_name, sizeof(module_name));
996+
}
997+
984998
/**
985999
* @brief Extract base name from a path
9861000
*/

0 commit comments

Comments
 (0)