@@ -71,6 +71,7 @@ pub mod uprobe;
71
71
pub mod xdp;
72
72
73
73
use std:: {
74
+ borrow:: Cow ,
74
75
ffi:: CString ,
75
76
io,
76
77
os:: fd:: { AsFd , BorrowedFd } ,
@@ -493,7 +494,7 @@ impl Program {
493
494
494
495
#[ derive( Debug ) ]
495
496
pub ( crate ) struct ProgramData < T : Link > {
496
- pub ( crate ) name : Option < String > ,
497
+ pub ( crate ) name : Option < Cow < ' static , str > > ,
497
498
pub ( crate ) obj : Option < ( aya_obj:: Program , aya_obj:: Function ) > ,
498
499
pub ( crate ) fd : Option < ProgramFd > ,
499
500
pub ( crate ) links : Links < T > ,
@@ -509,7 +510,7 @@ pub(crate) struct ProgramData<T: Link> {
509
510
510
511
impl < T : Link > ProgramData < T > {
511
512
pub ( crate ) fn new (
512
- name : Option < String > ,
513
+ name : Option < Cow < ' static , str > > ,
513
514
obj : ( aya_obj:: Program , aya_obj:: Function ) ,
514
515
btf_fd : Option < Arc < crate :: MockableFd > > ,
515
516
verifier_log_level : VerifierLogLevel ,
@@ -531,7 +532,7 @@ impl<T: Link> ProgramData<T> {
531
532
}
532
533
533
534
pub ( crate ) fn from_bpf_prog_info (
534
- name : Option < String > ,
535
+ name : Option < Cow < ' static , str > > ,
535
536
fd : crate :: MockableFd ,
536
537
path : & Path ,
537
538
info : bpf_prog_info ,
@@ -576,7 +577,7 @@ impl<T: Link> ProgramData<T> {
576
577
} ) ?;
577
578
578
579
let info = ProgramInfo :: new_from_fd ( fd. as_fd ( ) ) ?;
579
- let name = info. name_as_str ( ) . map ( |s| s . to_string ( ) ) ;
580
+ let name = info. name_as_str ( ) . map ( ToOwned :: to_owned ) . map ( Into :: into ) ;
580
581
Self :: from_bpf_prog_info ( name, fd, path. as_ref ( ) , info. 0 , verifier_log_level)
581
582
}
582
583
}
0 commit comments