Skip to content

Commit

Permalink
Merge pull request #78 from coroot/tracefs
Browse files Browse the repository at this point in the history
require either `debugfs` or `tracefs` to be mounted
  • Loading branch information
def authored Apr 30, 2024
2 parents 8b0243e + 4e9a6fc commit 58f0336
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions ebpftracer/tracer.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,11 @@ func (t *Tracer) ebpf(ch chan<- Event) error {
if len(prg) == 0 {
return fmt.Errorf("unsupported kernel version: %s", t.kernelVersion)
}
_, debugFsErr := os.Stat("/sys/kernel/debug/tracing")
_, traceFsErr := os.Stat("/sys/kernel/tracing")

if _, err := os.Stat("/sys/kernel/debug/tracing"); err != nil {
return fmt.Errorf("kernel tracing is not available: %w", err)
if debugFsErr != nil && traceFsErr != nil {
return fmt.Errorf("kernel tracing is not available: debugfs or tracefs must be mounted")
}

collectionSpec, err := ebpf.LoadCollectionSpecFromReader(bytes.NewReader(prg))
Expand Down

0 comments on commit 58f0336

Please sign in to comment.