Skip to content

Conversation

cyphar
Copy link
Contributor

@cyphar cyphar commented Sep 10, 2025

This implementation comes from github.com/cyphar/filepath-securejoin's
internal/kernelversion package.

Closes #204
Signed-off-by: Aleksa Sarai [email protected]

This implementation comes from github.com/cyphar/filepath-securejoin's
internal/kernelversion package.

Signed-off-by: Aleksa Sarai <[email protected]>
Copy link
Collaborator

@kolyshkin kolyshkin left a 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
Copy link
Collaborator

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) {
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants