Skip to content
Snippets Groups Projects
Commit e2554eaf authored by Nadav Har'El's avatar Nadav Har'El
Browse files

Use same version in <linux/version.h> and uname()


We had a different Linux version compiled into uname() (3.7.0) than
we had compiled into other code (via <linux/version.h>).

This patch makes them both pretend to be 3.7.0 - arbitrarily chosen
as the current Linux version at the time OSv was created. The new code
verifies with a static assertion that both files contain the same version,
so if they diverge, uname.c will fail compilation.

Signed-off-by: default avatarNadav Har'El <nyh@cloudius-systems.com>
parent cd39acb1
No related branches found
No related tags found
No related merge requests found
#define LINUX_VERSION_CODE 198669
#define LINUX_VERSION_CODE 198400
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
......@@ -8,10 +8,25 @@
#include <sys/utsname.h>
#include <string.h>
// The Linux version we're pretending to be
#define LINUX_MAJOR 3
#define LINUX_MINOR 7
#define LINUX_PATCH 0
// Verify that the version defined in <linux/version.h> is the same
#include <linux/version.h>
_Static_assert(KERNEL_VERSION(LINUX_MAJOR, LINUX_MINOR, LINUX_PATCH)
== LINUX_VERSION_CODE,
"LINUX_VERSION_CODE in include/glibc-compat/linux/version.h "
"does not match version in libc/misc/uname.c");
#define str(s) #s
#define str2(s) str(s)
struct utsname utsname = {
.sysname = "Linux", /* lie, to avoid confusing the payload. */
.nodename = "osv.local",
.release = "3.7",
.release = str2(LINUX_MAJOR) "." str2(LINUX_MINOR) "." str2(LINUX_PATCH),
.version = "#1 SMP",
.machine = "x86_64",
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment