@@ -47,8 +47,10 @@ static int find_library_paths(struct error *, struct dxcore_context *, struct nv
4747static int find_binary_paths (struct error * , struct dxcore_context * , struct nvc_driver_info * , const char * , const char * const [], size_t );
4848static int find_device_node (struct error * , const char * , const char * , struct nvc_device_node * );
4949static int find_ipc_path (struct error * , const char * , const char * , char * * );
50+ static int lookup_paths (struct error * , struct dxcore_context * , struct nvc_driver_info * , const char * , int32_t , const char * );
5051static int lookup_libraries (struct error * , struct dxcore_context * , struct nvc_driver_info * , const char * , int32_t , const char * );
5152static int lookup_binaries (struct error * , struct dxcore_context * , struct nvc_driver_info * , const char * , int32_t );
53+ static int lookup_directories (struct error * , struct dxcore_context * , struct nvc_driver_info * , const char * , int32_t );
5254static int lookup_devices (struct error * , const struct nvc_context * , struct nvc_driver_info * , const char * , int32_t );
5355static int lookup_ipcs (struct error * , struct nvc_driver_info * , const char * , int32_t );
5456static int fill_mig_device_info (struct nvc_context * , bool mig_enabled , struct driver_device * , struct nvc_device * );
@@ -350,6 +352,27 @@ find_ipc_path(struct error *err, const char *root, const char *ipc, char **buf)
350352 return (0 );
351353}
352354
355+ static int
356+ lookup_paths (struct error * err , struct dxcore_context * dxcore , struct nvc_driver_info * info , const char * root , int32_t flags , const char * ldcache )
357+ {
358+ if (lookup_libraries (err , dxcore , info , root , flags , ldcache ) < 0 ) {
359+ log_err ("error looking up libraries" );
360+ return (-1 );
361+ }
362+
363+ if (lookup_binaries (err , dxcore , info , root , flags ) < 0 ) {
364+ log_err ("error looking up binaries" );
365+ return (-1 );
366+ }
367+
368+ if (lookup_directories (err , dxcore , info , root , flags ) < 0 ) {
369+ log_err ("error looking up additional paths" );
370+ return (-1 );
371+ }
372+
373+ return (0 );
374+ }
375+
353376static int
354377lookup_libraries (struct error * err , struct dxcore_context * dxcore , struct nvc_driver_info * info , const char * root , int32_t flags , const char * ldcache )
355378{
@@ -406,6 +429,38 @@ lookup_binaries(struct error *err, struct dxcore_context* dxcore, struct nvc_dri
406429 return (0 );
407430}
408431
432+ static int
433+ lookup_directories (struct error * err , struct dxcore_context * dxcore , struct nvc_driver_info * info , const char * root , int32_t flags ) {
434+ int fd ;
435+ char * firmware_path = NULL ;
436+
437+ if (dxcore -> initialized ) {
438+ log_info ("skipping path lookup for dxcore" );
439+ return 0 ;
440+ }
441+
442+ // If the NVIDIA driver firmware path exists, include this in the mounted folders.
443+ if (xasprintf (err , & firmware_path , NV_FIRMWARE_DRIVER_PATH , info -> nvrm_version ) < 0 ) {
444+ log_errf ("error constructing firmware path for %s" , info -> nvrm_version );
445+ return (-1 );
446+ }
447+ if ((fd = xopen (err , firmware_path , O_PATH |O_DIRECTORY )) < 0 ) {
448+ log_infof ("missing firmware path %s" , firmware_path );
449+ return (0 );
450+ }
451+ close (fd );
452+
453+ info -> dirs = array_new (err , 1 );
454+ if (info -> dirs == NULL ) {
455+ log_err ("error creating path array" );
456+ return (-1 );
457+ }
458+ info -> dirs [0 ] = firmware_path ;
459+ info -> ndirs = 1 ;
460+
461+ return (0 );
462+ }
463+
409464static int
410465lookup_devices (struct error * err , const struct nvc_context * ctx , struct nvc_driver_info * info , const char * root , int32_t flags )
411466{
@@ -762,9 +817,7 @@ nvc_driver_info_new(struct nvc_context *ctx, const char *opts)
762817 goto fail ;
763818 if (driver_get_cuda_version (& ctx -> drv , & info -> cuda_version ) < 0 )
764819 goto fail ;
765- if (lookup_libraries (& ctx -> err , & ctx -> dxcore , info , ctx -> cfg .root , flags , ctx -> cfg .ldcache ) < 0 )
766- goto fail ;
767- if (lookup_binaries (& ctx -> err , & ctx -> dxcore , info , ctx -> cfg .root , flags ) < 0 )
820+ if (lookup_paths (& ctx -> err , & ctx -> dxcore , info , ctx -> cfg .root , flags , ctx -> cfg .ldcache ) < 0 )
768821 goto fail ;
769822 if (lookup_devices (& ctx -> err , ctx , info , ctx -> cfg .root , flags ) < 0 )
770823 goto fail ;
0 commit comments