@ -492,8 +492,13 @@ impl<'a> BpfLoader<'a> {
let mut map = match obj . pinning ( ) {
let mut map = match obj . pinning ( ) {
PinningType ::None = > MapData ::create ( obj , & name , btf_fd ) ? ,
PinningType ::None = > MapData ::create ( obj , & name , btf_fd ) ? ,
PinningType ::ByName = > {
PinningType ::ByName = > {
let path = map_pin_path . as_ref ( ) . ok_or ( BpfError ::NoPinPath ) ? ;
// pin maps in /sys/fs/bpf by default to align with libbpf
MapData ::create_pinned ( path , obj , & name , btf_fd ) ?
// behavior https://github.com/libbpf/libbpf/blob/v1.2.2/src/libbpf.c#L2161.
let path = map_pin_path
. as_deref ( )
. unwrap_or_else ( | | Path ::new ( "/sys/fs/bpf" ) ) ;
MapData ::create_pinned_by_name ( path , obj , & name , btf_fd ) ?
}
}
} ;
} ;
map . finalize ( ) ? ;
map . finalize ( ) ? ;
@ -951,10 +956,6 @@ pub enum BpfError {
error : io ::Error ,
error : io ::Error ,
} ,
} ,
/// Pinning requested but no path provided
#[ error( " pinning requested but no path provided " ) ]
NoPinPath ,
/// Unexpected pinning type
/// Unexpected pinning type
#[ error( " unexpected pinning type {name} " ) ]
#[ error( " unexpected pinning type {name} " ) ]
UnexpectedPinningType {
UnexpectedPinningType {