@@ -40,7 +40,6 @@ static int symlink_libraries(struct error *, const struct nvc_container *, cons
4040static void filter_libraries (const struct nvc_driver_info * , char * [], size_t * );
4141static int device_mount_dxcore (struct nvc_context * , const struct nvc_container * );
4242static int device_mount_native (struct nvc_context * , const struct nvc_container * , const struct nvc_device * );
43- static int cap_device_from_path (struct nvc_context * , const char * , struct nvc_device_node * );
4443static int cap_device_mount (struct nvc_context * , const struct nvc_container * , const char * );
4544static int setup_mig_minor_cgroups (struct error * , const struct nvc_container * , int , const struct nvc_device_node * );
4645
@@ -643,40 +642,14 @@ device_mount_native(struct nvc_context *ctx, const struct nvc_container *cnt, co
643642 return (rv );
644643}
645644
646- static int
647- cap_device_from_path (struct nvc_context * ctx , const char * cap_path , struct nvc_device_node * node )
648- {
649- char abs_cap_path [PATH_MAX ];
650- char dev_name [PATH_MAX ];
651- int major , minor ;
652- int rv = -1 ;
653-
654- if (path_join (& ctx -> err , abs_cap_path , ctx -> cfg .root , cap_path ) < 0 )
655- goto fail ;
656-
657- if (nvidia_cap_get_device_file_attrs (abs_cap_path , & major , & minor , dev_name ) == 0 ) {
658- error_set (& ctx -> err , "unable to get cap device attributes: %s" , cap_path );
659- goto fail ;
660- }
661-
662- if ((node -> path = xstrdup (& ctx -> err , dev_name )) == NULL )
663- goto fail ;
664- node -> id = makedev ((unsigned int )major , (unsigned int )minor );
665-
666- rv = 0 ;
667-
668- fail :
669- return (rv );
670- }
671-
672645static int
673646cap_device_mount (struct nvc_context * ctx , const struct nvc_container * cnt , const char * cap_path )
674647{
675648 char * dev_mnt = NULL ;
676649 struct nvc_device_node node = {0 };
677650 int rv = -1 ;
678651
679- if (cap_device_from_path (ctx , cap_path , & node ) < 0 )
652+ if (nvc_nvcaps_device_from_proc_path (ctx , cap_path , & node ) < 0 )
680653 goto fail ;
681654
682655 if (!(cnt -> flags & OPT_NO_DEVBIND )) {
@@ -978,7 +951,7 @@ nvc_mig_config_global_caps_mount(struct nvc_context *ctx, const struct nvc_conta
978951 if ((dev_mnt = mount_directory (& ctx -> err , ctx -> cfg .root , cnt , NV_CAPS_DEVICE_DIR )) == NULL )
979952 goto fail ;
980953
981- if (cap_device_from_path (ctx , config , & node ) < 0 )
954+ if (nvc_nvcaps_device_from_proc_path (ctx , config , & node ) < 0 )
982955 goto fail ;
983956
984957 if (!(cnt -> flags & OPT_NO_CGROUPS ))
@@ -1041,7 +1014,7 @@ nvc_mig_monitor_global_caps_mount(struct nvc_context *ctx, const struct nvc_cont
10411014 if ((dev_mnt = mount_directory (& ctx -> err , ctx -> cfg .root , cnt , NV_CAPS_DEVICE_DIR )) == NULL )
10421015 goto fail ;
10431016
1044- if (cap_device_from_path (ctx , monitor , & node ) < 0 )
1017+ if (nvc_nvcaps_device_from_proc_path (ctx , monitor , & node ) < 0 )
10451018 goto fail ;
10461019
10471020 if (!(cnt -> flags & OPT_NO_CGROUPS ))
0 commit comments