Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

Commit

Permalink
fix(ebpf): compilation on windows and freebsd (#815)
Browse files Browse the repository at this point in the history
  • Loading branch information
korniltsev authored Jul 6, 2023
1 parent cdde6dd commit eaffa4f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
15 changes: 12 additions & 3 deletions ebpf/symtab/procmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import (
"reflect"
"strconv"
"unsafe"

"golang.org/x/sys/unix"
)

// ProcMapPermissions contains permission settings read from `/proc/[pid]/maps`.
Expand Down Expand Up @@ -77,7 +75,18 @@ func parseDevice(s []byte) (uint64, error) {
return 0, err
}

return unix.Mkdev(uint32(major), uint32(minor)), nil
return mkdev(uint32(major), uint32(minor)), nil
}

// mkdev returns a Linux device number generated from the given major and minor
// components.
// this is a copy-paste from unix.Mkdev
func mkdev(major, minor uint32) uint64 {
dev := (uint64(major) & 0x00000fff) << 8
dev |= (uint64(major) & 0xfffff000) << 32
dev |= (uint64(minor) & 0x000000ff) << 0
dev |= (uint64(minor) & 0xffffff00) << 12
return dev
}

// parseAddress converts a hex-string to a uintptr.
Expand Down
12 changes: 6 additions & 6 deletions ebpf/symtab/stat_placeholder.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
//go:build !unix
//go:build !linux && !darwin

package symtab

import (
"os"
)

type stat struct {
dev uint64
ino uint64
type Stat struct {
Dev uint64
Ino uint64
}

func statFromFileInfo(file os.FileInfo) stat {
return stat{}
func statFromFileInfo(file os.FileInfo) Stat {
return Stat{}
}

0 comments on commit eaffa4f

Please sign in to comment.