@@ -5973,6 +5973,65 @@ static void stdout_pull_model_ddc_req_log(struct nvme_pull_model_ddc_req_log *lo
59735973 d ((unsigned char * )log -> osp , osp_len , 16 , 1 );
59745974}
59755975
5976+ static void stdout_relatives (nvme_root_t r , const char * name )
5977+ {
5978+ struct nvme_resources res ;
5979+ struct htable_ns_iter it ;
5980+ bool block = true;
5981+ bool first = true;
5982+ nvme_ctrl_t c ;
5983+ nvme_path_t p ;
5984+ nvme_ns_t n ;
5985+ int nsid ;
5986+ int ret ;
5987+ int id ;
5988+
5989+ ret = sscanf (name , "nvme%dn%d" , & id , & nsid );
5990+
5991+ switch (ret ) {
5992+ case 1 :
5993+ block = false;
5994+ break ;
5995+ case 2 :
5996+ break ;
5997+ default :
5998+ return ;
5999+ }
6000+
6001+ nvme_resources_init (r , & res );
6002+
6003+ if (block ) {
6004+ fprintf (stderr , "Namespace %s has parent controller(s):" , name );
6005+ for (n = htable_ns_getfirst (& res .ht_n , name , & it ); n ;
6006+ n = htable_ns_getnext (& res .ht_n , name , & it )) {
6007+ if (nvme_ns_get_ctrl (n )) {
6008+ fprintf (stderr , "%s" , nvme_ctrl_get_name (nvme_ns_get_ctrl (n )));
6009+ break ;
6010+ }
6011+ nvme_namespace_for_each_path (n , p ) {
6012+ c = nvme_path_get_ctrl (p );
6013+ fprintf (stderr , "%s%s" , first ? "" : ", " , nvme_ctrl_get_name (c ));
6014+ if (first )
6015+ first = false;
6016+ }
6017+ }
6018+ fprintf (stderr , "\n\n" );
6019+ } else {
6020+ c = htable_ctrl_get (& res .ht_c , name );
6021+ if (c ) {
6022+ fprintf (stderr , "Controller %s has child namespace(s):" , name );
6023+ nvme_ctrl_for_each_ns (c , n ) {
6024+ fprintf (stderr , "%s%s" , first ? "" : ", " , nvme_ns_get_name (n ));
6025+ if (first )
6026+ first = false;
6027+ }
6028+ fprintf (stderr , "\n\n" );
6029+ }
6030+ }
6031+
6032+ nvme_resources_free (& res );
6033+ }
6034+
59766035static struct print_ops stdout_print_ops = {
59776036 /* libnvme types.h print functions */
59786037 .ana_log = stdout_ana_log ,
@@ -6016,6 +6075,7 @@ static struct print_ops stdout_print_ops = {
60166075 .predictable_latency_event_agg_log = stdout_predictable_latency_event_agg_log ,
60176076 .predictable_latency_per_nvmset = stdout_predictable_latency_per_nvmset ,
60186077 .primary_ctrl_cap = stdout_primary_ctrl_cap ,
6078+ .relatives = stdout_relatives ,
60196079 .resv_notification_log = stdout_resv_notif_log ,
60206080 .resv_report = stdout_resv_report ,
60216081 .sanitize_log_page = stdout_sanitize_log ,
0 commit comments