Skip to content

unix: get mainline kernel version in Ubuntu#4131

Merged
santigimeno merged 2 commits intolibuv:v1.xfrom
santigimeno:santi/ubuntu_kernel_version
Sep 1, 2023
Merged

unix: get mainline kernel version in Ubuntu#4131
santigimeno merged 2 commits intolibuv:v1.xfrom
santigimeno:santi/ubuntu_kernel_version

Conversation

@santigimeno
Copy link
Copy Markdown
Member

In Ubuntu, the kernel version reported by uname() follows the versioning format that Ubuntu uses for their kernels which does not have a direct correspondence with the mainline kernel version they're based on. Get that version from /proc/version_signature as documented in:

https://wiki.ubuntu.com/Kernel/FAQ#Kernel.2FFAQ.2FGeneralVersionRunning.How_can_we_determine_the_version_of_the_running_kernel.3F

@santigimeno santigimeno requested a review from bnoordhuis August 30, 2023 19:35
@santigimeno
Copy link
Copy Markdown
Member Author

santigimeno commented Aug 30, 2023

While trying to move forward the proposal in #4101, I noticed this quirk in Ubuntu. Not sure how common is this problem in linux distributions but just in case we want to keep working on this.

Copy link
Copy Markdown
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a suggestion. Good catch.

Debian has a similar issue, the real kernel version is in u.version (uname -v), not in u.release (uname -r)

u.version is fairly free-form. A proper scanner looks like this:

needle = strstr(u.version, "Debian ");
if (needle != NULL)
  if (3 == sscanf(needle, "Debian %u.%u.%u", &major, &minor, &patch))
    goto calculate_version;

@santigimeno
Copy link
Copy Markdown
Member Author

LGTM with a suggestion. Good catch.

Debian has a similar issue, the real kernel version is in u.version (uname -v), not in u.release (uname -r)

u.version is fairly free-form. A proper scanner looks like this:

needle = strstr(u.version, "Debian ");
if (needle != NULL)
  if (3 == sscanf(needle, "Debian %u.%u.%u", &major, &minor, &patch))
    goto calculate_version;

Are you ok if I add this code as well?

@bnoordhuis
Copy link
Copy Markdown
Member

Of course! :)

@santigimeno santigimeno force-pushed the santi/ubuntu_kernel_version branch from 5819eb6 to 057a8e5 Compare August 31, 2023 21:47
@santigimeno
Copy link
Copy Markdown
Member Author

@bnoordhuis I added the Debian check in a new commit (and set yourself as the Author). PTAL. Thanks!

@santigimeno santigimeno requested a review from bnoordhuis August 31, 2023 21:51
santigimeno and others added 2 commits September 1, 2023 11:22
In Ubuntu, the kernel version reported by `uname()` follows the
versioning format that Ubuntu uses for their kernels which does not have
a direct correspondence with the mainline kernel version they're based
on. Get that version from `/proc/version_signature` as documented in:

https://wiki.ubuntu.com/Kernel/FAQ#Kernel.2FFAQ.2FGeneralVersionRunning.How_can_we_determine_the_version_of_the_running_kernel.3F
In Debian, the mainline kernel version is reported via the `uname()`
`version` field.
@santigimeno santigimeno force-pushed the santi/ubuntu_kernel_version branch from 057a8e5 to d76c515 Compare September 1, 2023 09:23
@santigimeno santigimeno merged commit 0d78f3c into libuv:v1.x Sep 1, 2023
santigimeno added a commit that referenced this pull request Sep 1, 2023
In Ubuntu, the kernel version reported by `uname()` follows the
versioning format that Ubuntu uses for their kernels which does not have
a direct correspondence with the mainline kernel version they're based
on. Get that version from `/proc/version_signature` as documented in:

https://wiki.ubuntu.com/Kernel/FAQ#Kernel.2FFAQ.2FGeneralVersionRunning.How_can_we_determine_the_version_of_the_running_kernel.3F
@santigimeno santigimeno deleted the santi/ubuntu_kernel_version branch September 1, 2023 09:24
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