@@ -310,18 +310,35 @@ int uct_rocm_base_is_dmabuf_supported()
310310 struct utsname utsname ;
311311 char kernel_conf_file [128 ];
312312 char buf [256 ];
313-
313+ const char * fmts [] = {
314+ "/boot/config-%s" ,
315+ "/usr/src/linux-%s/.config" ,
316+ "/usr/src/linux/.config" ,
317+ "/usr/lib/modules/%s/config" ,
318+ "/usr/lib/ostree-boot/config-%s" ,
319+ "/usr/lib/kernel/config-%s" ,
320+ "/usr/src/linux-headers-%s/.config" ,
321+ "/lib/modules/%s/build/.config"
322+ };
323+
314324 if (uname (& utsname ) == -1 ) {
315325 ucs_trace ("could not get kernel name" );
316326 goto out ;
317327 }
318328
319- ucs_snprintf_safe (kernel_conf_file , sizeof (kernel_conf_file ),
320- "/boot/config-%s" , utsname .release );
321- fp = fopen (kernel_conf_file , "r" );
329+ for (size_t i = 0 ; i < sizeof (fmts ) / sizeof (fmts [0 ]); ++ i ) {
330+ const char * path = fmts [i ];
331+ ucs_snprintf_safe (kernel_conf_file , sizeof (kernel_conf_file ), path , utsname .release );
332+ fp = fopen (path , "r" );
333+ if (fp != NULL ) {
334+ ucs_trace ("reading kernel config from %s" , path );
335+ break ;
336+ }
337+ ucs_trace ("could not open kernel conf file %s error: %m" , path );
338+ }
339+
322340 if (fp == NULL ) {
323- ucs_trace ("could not open kernel conf file %s error: %m" ,
324- kernel_conf_file );
341+ ucs_trace ("no kernel conf file found" );
325342 goto out ;
326343 }
327344
0 commit comments