Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/parsers: Enable GetKernelVersion on FreeBSD #1425

Merged
merged 1 commit into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions pkg/parsers/kernel/uname_freebsd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package kernel

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

// Utsname represents the system name structure.
// It is passthrough for unix.Utsname in order to make it portable with
// other platforms where it is not available.
type Utsname unix.Utsname

func uname() (*unix.Utsname, error) {
uts := &unix.Utsname{}

if err := unix.Uname(uts); err != nil {
return nil, err
}
return uts, nil
}
9 changes: 5 additions & 4 deletions pkg/parsers/kernel/uname_unsupported.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
//go:build freebsd || openbsd
// +build freebsd openbsd
//go:build openbsd
// +build openbsd

package kernel

import (
"errors"
"fmt"
"runtime'
)

// A stub called by kernel_unix.go .
func uname() (*Utsname, error) {
return nil, errors.New("Kernel version detection is available only on linux")
return nil, fmt.Errorf("Kernel version detection is not available on %s", runtime.GOOS)
}
4 changes: 2 additions & 2 deletions pkg/parsers/kernel/uname_unsupported_type.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build !linux && !solaris
// +build !linux,!solaris
//go:build !linux && !solaris && !freebsd
// +build !linux,!solaris,!freebsd

package kernel

Expand Down