MCPcopy
hub / github.com/cilium/ebpf / LoadPinnedMap

Function LoadPinnedMap

map.go:1731–1751  ·  view source on GitHub ↗

LoadPinnedMap opens a Map from a pin (file) on the BPF virtual filesystem. Requires at least Linux 4.5.

(fileName string, opts *LoadPinOptions)

Source from the content-addressed store, hash-verified

1729//
1730// Requires at least Linux 4.5.
1731func LoadPinnedMap(fileName string, opts *LoadPinOptions) (*Map, error) {
1732 fd, typ, err := sys.ObjGetTyped(&sys.ObjGetAttr{
1733 Pathname: sys.NewStringPointer(fileName),
1734 FileFlags: opts.Marshal(),
1735 })
1736 if err != nil {
1737 return nil, err
1738 }
1739
1740 if typ != sys.BPF_TYPE_MAP {
1741 _ = fd.Close()
1742 return nil, fmt.Errorf("%s is not a Map", fileName)
1743 }
1744
1745 m, err := newMapFromFD(fd)
1746 if err == nil {
1747 m.pinnedPath = fileName
1748 }
1749
1750 return m, err
1751}
1752
1753// unmarshalMap creates a map from a map ID encoded in host endianness.
1754func unmarshalMap(buf sysenc.Buffer) (*Map, error) {

Callers 10

newMapWithOptionsFunction · 0.85
TestMapPinFunction · 0.85
TestNestedMapPinFunction · 0.85
TestMapPinMultipleFunction · 0.85
TestMapUnpinFunction · 0.85
TestMapLoadPinnedFunction · 0.85
TestMapLoadPinnedUnpinFunction · 0.85
TestLoadWrongPinFunction · 0.85

Calls 5

ObjGetTypedFunction · 0.92
NewStringPointerFunction · 0.92
newMapFromFDFunction · 0.85
CloseMethod · 0.65
MarshalMethod · 0.45

Tested by 9

TestMapPinFunction · 0.68
TestNestedMapPinFunction · 0.68
TestMapPinMultipleFunction · 0.68
TestMapUnpinFunction · 0.68
TestMapLoadPinnedFunction · 0.68
TestMapLoadPinnedUnpinFunction · 0.68
TestLoadWrongPinFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…