@@ -39,10 +39,11 @@ static struct nvme_host *default_host;
3939static void __nvme_free_host (nvme_host_t h );
4040static void __nvme_free_ctrl (nvme_ctrl_t c );
4141static int nvme_subsystem_scan_namespace (nvme_root_t r ,
42- struct nvme_subsystem * s , char * name , nvme_scan_filter_t f );
42+ struct nvme_subsystem * s , char * name ,
43+ nvme_scan_filter_t f , void * f_args );
4344static int nvme_init_subsystem (nvme_subsystem_t s , const char * name );
4445static int nvme_scan_subsystem (nvme_root_t r , const char * name ,
45- nvme_scan_filter_t f );
46+ nvme_scan_filter_t f , void * f_args );
4647static int nvme_ctrl_scan_namespace (nvme_root_t r , struct nvme_ctrl * c ,
4748 char * name );
4849static int nvme_ctrl_scan_path (nvme_root_t r , struct nvme_ctrl * c , char * name );
@@ -75,7 +76,7 @@ nvme_host_t nvme_default_host(nvme_root_t r)
7576 return h ;
7677}
7778
78- int nvme_scan_topology (struct nvme_root * r , nvme_scan_filter_t f )
79+ int nvme_scan_topology (struct nvme_root * r , nvme_scan_filter_t f , void * f_args )
7980{
8081 struct dirent * * subsys , * * ctrls ;
8182 int i , num_subsys , num_ctrls , ret ;
@@ -97,7 +98,7 @@ int nvme_scan_topology(struct nvme_root *r, nvme_scan_filter_t f)
9798 ctrls [i ]-> d_name , strerror (errno ));
9899 continue ;
99100 }
100- if ((f ) && !f (NULL , c , NULL )) {
101+ if ((f ) && !f (NULL , c , NULL , f_args )) {
101102 nvme_msg (r , LOG_DEBUG , "filter out controller %s\n" ,
102103 ctrls [i ]-> d_name );
103104 nvme_free_ctrl (c );
@@ -114,7 +115,7 @@ int nvme_scan_topology(struct nvme_root *r, nvme_scan_filter_t f)
114115 }
115116
116117 for (i = 0 ; i < num_subsys ; i ++ ) {
117- ret = nvme_scan_subsystem (r , subsys [i ]-> d_name , f );
118+ ret = nvme_scan_subsystem (r , subsys [i ]-> d_name , f , f_args );
118119 if (ret < 0 ) {
119120 nvme_msg (r , LOG_DEBUG ,
120121 "failed to scan subsystem %s: %s\n" ,
@@ -172,7 +173,7 @@ nvme_root_t nvme_scan(const char *config_file)
172173{
173174 nvme_root_t r = nvme_create_root (NULL , DEFAULT_LOGLEVEL );
174175
175- nvme_scan_topology (r , NULL );
176+ nvme_scan_topology (r , NULL , NULL );
176177 nvme_read_config (r , config_file );
177178 return r ;
178179}
@@ -266,7 +267,7 @@ void nvme_refresh_topology(nvme_root_t r)
266267
267268 nvme_for_each_host_safe (r , h , _h )
268269 __nvme_free_host (h );
269- nvme_scan_topology (r , NULL );
270+ nvme_scan_topology (r , NULL , NULL );
270271}
271272
272273void nvme_free_tree (nvme_root_t r )
@@ -476,7 +477,7 @@ struct nvme_host *nvme_lookup_host(nvme_root_t r, const char *hostnqn,
476477}
477478
478479static int nvme_subsystem_scan_namespaces (nvme_root_t r , nvme_subsystem_t s ,
479- nvme_scan_filter_t f )
480+ nvme_scan_filter_t f , void * f_args )
480481{
481482 struct dirent * * namespaces ;
482483 int i , num_ns , ret ;
@@ -491,7 +492,7 @@ static int nvme_subsystem_scan_namespaces(nvme_root_t r, nvme_subsystem_t s,
491492
492493 for (i = 0 ; i < num_ns ; i ++ ) {
493494 ret = nvme_subsystem_scan_namespace (r , s ,
494- namespaces [i ]-> d_name , f );
495+ namespaces [i ]-> d_name , f , f_args );
495496 if (ret < 0 )
496497 nvme_msg (r , LOG_DEBUG ,
497498 "failed to scan namespace %s: %s\n" ,
@@ -528,7 +529,7 @@ static int nvme_init_subsystem(nvme_subsystem_t s, const char *name)
528529}
529530
530531static int nvme_scan_subsystem (struct nvme_root * r , const char * name ,
531- nvme_scan_filter_t f )
532+ nvme_scan_filter_t f , void * f_args )
532533{
533534 struct nvme_subsystem * s = NULL , * _s ;
534535 char * path , * subsysnqn ;
@@ -584,13 +585,13 @@ static int nvme_scan_subsystem(struct nvme_root *r, const char *name,
584585 if (!s )
585586 return -1 ;
586587
587- if (f && !f (s , NULL , NULL )) {
588+ if (f && !f (s , NULL , NULL , f_args )) {
588589 nvme_msg (r , LOG_DEBUG , "filter out subsystem %s\n" , name );
589590 __nvme_free_subsystem (s );
590591 return 0 ;
591592 }
592593
593- nvme_subsystem_scan_namespaces (r , s , f );
594+ nvme_subsystem_scan_namespaces (r , s , f , f_args );
594595
595596 return 0 ;
596597}
@@ -1410,9 +1411,9 @@ void nvme_rescan_ctrl(struct nvme_ctrl *c)
14101411 nvme_root_t r = c -> s && c -> s -> h ? c -> s -> h -> r : NULL ;
14111412 if (!c -> s )
14121413 return ;
1413- nvme_subsystem_scan_namespaces (r , c -> s , NULL );
14141414 nvme_ctrl_scan_namespaces (r , c );
14151415 nvme_ctrl_scan_paths (r , c );
1416+ nvme_subsystem_scan_namespaces (r , c -> s , NULL , NULL );
14161417}
14171418
14181419static int nvme_bytes_to_lba (nvme_ns_t n , off_t offset , size_t count ,
@@ -1883,7 +1884,7 @@ static void nvme_subsystem_set_ns_path(nvme_subsystem_t s, nvme_ns_t n)
18831884}
18841885
18851886static int nvme_subsystem_scan_namespace (nvme_root_t r , nvme_subsystem_t s ,
1886- char * name , nvme_scan_filter_t f )
1887+ char * name , nvme_scan_filter_t f , void * f_args )
18871888{
18881889 struct nvme_ns * n ;
18891890
@@ -1894,7 +1895,7 @@ static int nvme_subsystem_scan_namespace(nvme_root_t r, nvme_subsystem_t s,
18941895 nvme_msg (r , LOG_DEBUG , "failed to scan namespace %s\n" , name );
18951896 return -1 ;
18961897 }
1897- if (f && !f (NULL , NULL , n )) {
1898+ if (f && !f (NULL , NULL , n , f_args )) {
18981899 nvme_msg (r , LOG_DEBUG , "filter out namespace %s\n" , name );
18991900 __nvme_free_ns (n );
19001901 return 0 ;
0 commit comments