-
Notifications
You must be signed in to change notification settings - Fork 49
kernelversion: add package for checking kernel versions #205
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
base: main
Are you sure you want to change the base?
Conversation
36b7be3 to
559b0dc
Compare
This implementation comes from github.com/cyphar/filepath-securejoin's internal/kernelversion package. Signed-off-by: Aleksa Sarai <[email protected]>
559b0dc to
9d4b40e
Compare
kolyshkin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guess you have to make it buildable on !linux (if only to return an error) as some users have code for multiple platforms
| @@ -0,0 +1,13 @@ | |||
| // SPDX-License-Identifier: BSD-3-Clause | |||
| //go:build linux && go1.20 | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wonder why package doc requires go1.20 :)
| // same as GreaterEqualThan(KernelVersion{4, 0, 0, ..., 0, 0}), and that if the | ||
| // host kernel version is "4" then GreaterEqualThan(KernelVersion{4, 1}) will | ||
| // return false (because the host version will be treated as "4.0"). | ||
| func GreaterEqualThan(wantKver KernelVersion) (bool, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Proper English would be something like "greater than or equal".
Or, we can use another name, say AtLeast. It will look like
if kernelversion.AtLeast(kernelversion.KernelVersion{4,2})which is still too much occurrences of "kernel" and "version", but otherwise ok.
Or, we can use a variadic function to simplify callers. Something like:
func AtLeast(want ...uint64)So the call can look simpler:
if kernelversion.AtLeast(2, 6, 19) {
...Or does it incur greater runtime overhead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Proper English would be something like "greater than or equal".
Or, we can use another name, say
AtLeast. It will look likeif kernelversion.AtLeast(kernelversion.KernelVersion{4,2})which is still too much occurrences of "kernel" and "version", but otherwise ok.
Or, we can use a variadic function to simplify callers. Something like:
func AtLeast(want ...uint64)So the call can look simpler:
if kernelversion.AtLeast(2, 6, 19) { ...Or does it incur greater runtime overhead?
|
@cyphar PTAL |
This implementation comes from github.com/cyphar/filepath-securejoin's
internal/kernelversion package.
Closes #204
Signed-off-by: Aleksa Sarai [email protected]