diff --git a/sys/compat/linux/linux_common.c b/sys/compat/linux/linux_common.c --- a/sys/compat/linux/linux_common.c +++ b/sys/compat/linux/linux_common.c @@ -52,6 +52,7 @@ switch(type) { case MOD_LOAD: + linux_prison0_init(); #ifdef INVARIANTS linux_check_errtbl(); #endif diff --git a/sys/compat/linux/linux_mib.h b/sys/compat/linux/linux_mib.h --- a/sys/compat/linux/linux_mib.h +++ b/sys/compat/linux/linux_mib.h @@ -53,10 +53,6 @@ #define LINUX_KERNVER(a,b,c) (((a) << 16) + ((b) << 8) + (c)) #define LINUX_VERSION_CODE LINUX_KERNVER(LINUX_KVERSION, \ LINUX_KPATCHLEVEL, LINUX_KSUBLEVEL) -#define LINUX_KERNVERSTR(x) #x -#define LINUX_XKERNVERSTR(x) LINUX_KERNVERSTR(x) -#define LINUX_VERSION_STR LINUX_XKERNVERSTR(LINUX_KVERSION.LINUX_KPATCHLEVEL.LINUX_KSUBLEVEL) - #define LINUX_KERNVER_2004000 LINUX_KERNVER(2,4,0) #define LINUX_KERNVER_2006039 LINUX_KERNVER(2,6,39) #define LINUX_KERNVER_5004000 LINUX_KERNVER(5,4,0) @@ -73,5 +69,6 @@ struct image_params; int linux_setid_allowed_query(struct thread *td, struct image_params *imgp); +void linux_prison0_init(void); #endif /* _LINUX_MIB_H_ */ diff --git a/sys/compat/linux/linux_mib.c b/sys/compat/linux/linux_mib.c --- a/sys/compat/linux/linux_mib.c +++ b/sys/compat/linux/linux_mib.c @@ -29,6 +29,7 @@ #include __FBSDID("$FreeBSD$"); +#include #include #include #include @@ -49,7 +50,7 @@ static struct linux_prison lprison0 = { .pr_osname = "Linux", - .pr_osrelease = LINUX_VERSION_STR, + .pr_osrelease = "" /* filled in by linux_prison0_init() */, .pr_oss_version = 0x030600, .pr_osrel = LINUX_VERSION_CODE }; @@ -585,3 +586,16 @@ return (0); } + +void +linux_prison0_init(void) +{ + char *p; + + snprintf(lprison0.pr_osrelease, sizeof(lprison0.pr_osrelease), + "%d.%d.%d-%s%s", LINUX_KVERSION, LINUX_KPATCHLEVEL, LINUX_KSUBLEVEL, + ostype, osrelease); + + for (p = lprison0.pr_osrelease; *p != '\0'; p++) + *p = tolower(*p); +} diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c --- a/sys/compat/linux/linux_misc.c +++ b/sys/compat/linux/linux_misc.c @@ -425,7 +425,7 @@ struct l_new_utsname utsname; char osname[LINUX_MAX_UTSNAME]; char osrelease[LINUX_MAX_UTSNAME]; - char *p; + char *p, *hash; linux_get_osname(td, osname); linux_get_osrelease(td, osrelease); @@ -435,7 +435,10 @@ getcredhostname(td->td_ucred, utsname.nodename, LINUX_MAX_UTSNAME); getcreddomainname(td->td_ucred, utsname.domainname, LINUX_MAX_UTSNAME); strlcpy(utsname.release, osrelease, LINUX_MAX_UTSNAME); - strlcpy(utsname.version, version, LINUX_MAX_UTSNAME); + /* Skip everything before '#'; in Linux it belongs in osrelease. */ + hash = strchr(version, '#'); + strlcpy(utsname.version, hash != NULL ? hash : version, + LINUX_MAX_UTSNAME); for (p = utsname.version; *p != '\0'; ++p) if (*p == '\n') { *p = '\0';