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

Function newToken

internal/sys/token.go:164–189  ·  view source on GitHub ↗
(mount string)

Source from the content-addressed store, hash-verified

162}
163
164func newToken(mount string) (*Token, error) {
165 fsfd, err := unix.Open(mount, unix.O_DIRECTORY|unix.O_RDONLY, 0)
166 if err != nil {
167 return nil, fmt.Errorf("open bpffs mount %q: %w", mount, err)
168 }
169 defer unix.Close(fsfd)
170
171 tfd, err := TokenCreate(&TokenCreateAttr{BpffsFd: uint32(fsfd)})
172 if err != nil {
173 return nil, err
174 }
175
176 t := &Token{
177 fd: tfd,
178 }
179
180 var ti TokenInfo
181 if err := ObjInfo(tfd, &ti); err == nil {
182 t.info = &ti
183 } else if !errors.Is(err, unix.EINVAL) {
184 _ = tfd.Close()
185 return nil, fmt.Errorf("get token info: %w", err)
186 }
187
188 return t, nil
189}
190
191// tokenAttr sets the appropriate token fields in the BPF syscall attribute
192// struct for the given command, if a token is available.

Callers 1

findTokenFunction · 0.85

Calls 6

OpenFunction · 0.92
CloseFunction · 0.92
TokenCreateFunction · 0.85
ObjInfoFunction · 0.85
CloseMethod · 0.65
IsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…