GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — ebpfmanager/utils.go at master · gojue/ebpfmanager Expand file tree/ Copy pathutils.goMore file actions 62 lines (54 loc) · 1.37 KB / Copy pathutils.goFile metadata and controls62 lines (54 loc) · 1.37 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 package manager import ( "os" "path/filepath" "strconv" "github.com/cilium/ebpf" ) // getEnv retrieves the environment variable key. If it does not exist it returns the default. func getEnv(key string, dfault string, combineWith ...string) string { value := os.Getenv(key) if value == "" { value = dfault } switch len(combineWith) { case 0: return value case 1: return filepath.Join(value, combineWith[0]) default: all := make([]string, len(combineWith)+1) all[0] = value copy(all[1:], combineWith) return filepath.Join(all...) } } // hostProc returns joins the provided path with the host /proc directory func hostProc(combineWith ...string) string { return getEnv("HOST_PROC", "/proc", combineWith...) } // Getpid returns the current process ID in the host namespace if $HOST_PROC is defined, the pid in the current namespace // otherwise func Getpid() int { p, err := os.Readlink(hostProc("/self")) if err == nil { if pid, err := strconv.ParseInt(p, 10, 32); err == nil { return int(pid) } } return os.Getpid() } // cleanupProgramSpec removes unused internal fields to free up some memory func cleanupProgramSpec(spec *ebpf.ProgramSpec) { if spec != nil { spec.Instructions = nil } } // create slice of length n and fill with fillVal func makeAndSet[E any](n int, fillVal E) []E { s := make([]E, n) for i := range s { s[i] = fillVal } return s } |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |