Skip to content

[API Proposal]: Add OperatingSystem.IsLinuxKernelVersionAtLeast #128685

@Neme12

Description

@Neme12

Background and motivation

Sometimes, I need to know whether I'm on a Linux kernel with at least a specified version to know whether a certain syscall is available and I can do the PInvoke.

API Proposal

namespace System;

public sealed partial class OperatingSystem
{
    public static bool IsLinuxKernelVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0);

    // Or alternatively, since Linux is a kernel, not an OS
    public static bool HasLinuxKernelVersionAtLeast(int major, int minor = 0, int build = 0, int revision = 0)
}

API Usage

if (OperatingSystem.IsLinuxKernelVersionAtLeast(6, 1)
    // use PInvoke introduced only in linux kernel 6.1

Alternative Designs

No response

Risks

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions