Add kernel parameter for kernel version
PATCH 1/1 Add kernel parameter for kernel version
From: Eric Ernst <[email protected]>
Create a kernel cmdline parameter, "version_addendum", which can be used to add text to the kernel version that is reported from /proc/version.
--- fs/proc/version.c | 14 +++++++++++++- init/version.c | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-)
fs/proc/version.c +13 -1
@@ -5,12 +5,17 @@#include <linux/seq_file.h> #include <linux/utsname.h> +#define ADDENDUM_LENGTH 20 +static char version_addendum[ADDENDUM_LENGTH ]; +static int version_proc_show (struct seq_file *m,void *v) {seq_printf (m, linux_proc_banner,utsname ()->sysname,utsname ()->release, -utsname ()->version); +utsname ()->version, + version_addendum); +return 0 ; }
@@ -26,6 +31,13 @@ static const struct file_operations version_proc_fops = { .release = single_release, }; +static int __init set_version_addendum (char *str) +{ +strncpy (version_addendum, str,ADDENDUM_LENGTH ); +return 0 ; +} +early_param ("version_addendum" , set_version_addendum); +static int __init proc_version_init (void ) {proc_create ("version" ,0 ,NULL , &version_proc_fops);
init/version.c +1 -1
@@ -47,4 +47,4 @@ const char linux_banner[] =const char linux_proc_banner[] ="%s version %s" " (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")" -" (" LINUX_COMPILER ") %s\n" ; +" (" LINUX_COMPILER ") %s " "%s\n" ;
Signature · 1 line
1.7.9.5
Quoted 5 lines · On Tue, May 27, 2014 at 3:40 PM, <[email protected]> wrote:
From: Eric Ernst <[email protected]>
Create a kernel cmdline parameter, "
version_addendum", which can be used to add text to the kernel version that is reported from/proc/version.
Why?
What is the intended purpose of this and why would someone want to use it?
josh
Quoted 10 lines · Josh Boyer
Quoted 5 lines · On Tue, May 27, 2014 at 3:40 PM, <[email protected]> wrote:
From: Eric Ernst <[email protected]>
Create a kernel cmdline parameter, "
version_addendum", which can be used to add text to the kernel version that is reported from/proc/version.Why?
What is the intended purpose of this and why would someone want to use it?
and if the patch were to continue to live, it needs a Documentation addition to kernel-parameters.txt.
Signature · 1 line
~Randy
Quoted 4 lines · Randy Dunlap
Quoted 3 lines · Josh Boyer
Quoted 2 lines · On Tue, May 27, 2014 at 3:40 PM, <[email protected]> wrote:
From: Eric Ernst <[email protected]>
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines
Create a kernel cmdline parameter, "
version_addendum", which can be used to add text to the kernel version that is reported from/proc/version.Why?
What is the intended purpose of this and why would someone want to use it?
and if the patch were to continue to live, it needs a Documentation addition to kernel-parameters.txt.
Randy - ACK.
Josh - we have a need to keep a single product binary (kernel) across multiple android devices. A subset of these platforms are looking for extra versioning information appended to it, accessible via /proc/version. Rather than build multiple otherwise identical kernels with only this extended versioning as differentiation, we are looking to make this a command line parameter. Understandable if there isn't enough value-add for the community in this patch, but I figured I'd give the patch a shot, as we need this functionality locally. Thanks.
PATCH 1/1 Add kernel parameter for kernel version
From: Eric Ernst <[email protected]>
Create a kernel cmdline parameter, "version_addendum", which can be used to add text to the kernel version that is reported from /proc/version.
--- fs/proc/version.c | 14 +++++++++++++- init/version.c | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-)
fs/proc/version.c +13 -1
@@ -5,12 +5,17 @@#include <linux/seq_file.h> #include <linux/utsname.h> +#define ADDENDUM_LENGTH 20 +static char version_addendum[ADDENDUM_LENGTH ]; +static int version_proc_show (struct seq_file *m,void *v) {seq_printf (m, linux_proc_banner,utsname ()->sysname,utsname ()->release, -utsname ()->version); +utsname ()->version, + version_addendum); +return 0 ; }
@@ -26,6 +31,13 @@ static const struct file_operations version_proc_fops = { .release = single_release, }; +static int __init set_version_addendum (char *str) +{ +strncpy (version_addendum, str,ADDENDUM_LENGTH -1 ); +return 0 ; +} +early_param ("version_addendum" , set_version_addendum); +static int __init proc_version_init (void ) {proc_create ("version" ,0 ,NULL , &version_proc_fops);
init/version.c +1 -1
@@ -47,4 +47,4 @@ const char linux_banner[] =const char linux_proc_banner[] ="%s version %s" " (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")" -" (" LINUX_COMPILER ") %s\n" ; +" (" LINUX_COMPILER ") %s " "%s\n" ;
Signature · 1 line
1.7.9.5
Quoted 3 lines · On Thu, 5 Jun 2014 15:09:17 -0700 [email protected] wrote:
Create a kernel cmdline parameter, "
version_addendum", which can be used to add text to the kernel version that is reported from/proc/version.
why?
Quoted 6 lines · Andrew Morton
Quoted 3 lines · On Thu, 5 Jun 2014 15:09:17 -0700 [email protected] wrote:
Create a kernel cmdline parameter, "
version_addendum", which can be used to add text to the kernel version that is reported from/proc/version.why?
We have a need to keep a single product binary (kernel) across multiple android devices. A subset of these platforms are looking for extra versioning information appended to it, accessible via /proc/version. Rather than build multiple otherwise identical kernels with only this extended versioning as differentiation, we are looking to make this a command line parameter. Understandable if there isn't enough value-add for the community in this patch, but I figured I'd give the patch a shot, as we need this functionality locally. Thanks.
Quoted 9 lines · eric ernst
Quoted 6 lines · Andrew Morton
Quoted 3 lines · On Thu, 5 Jun 2014 15:09:17 -0700 [email protected] wrote:
Create a kernel cmdline parameter, "
version_addendum", which can be used to add text to the kernel version that is reported from/proc/version.why?
We have a need to keep a single product binary (kernel) across multiple android devices. A subset of these platforms are looking for extra versioning information appended to it, accessible via
/proc/version. Rather than build multiple otherwise identical kernels with only this extended versioning as differentiation, we are looking to make this a command line parameter. Understandable if there isn't enough value-add for the community in this patch, but I figured I'd give the patch a shot, as we need this functionality locally. Thanks.
Please use a newline character every 70-72 characters instead of assuming that all email programs will break that extra long line up into a readable format. (mine does not.)
What software needs to know the version info? how early does it run? Could it get the version info from 'uname -r' instead of from /proc/version?
thanks,
Signature · 1 line
~Randy
Quoted 4 lines · Randy Dunlap
Quoted 3 lines · eric ernst
Quoted 2 lines · Andrew Morton
On Thu, 5 Jun 2014 15:09:17 -0700 [email protected] wrote:
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
Quoted 3 lines
Create a kernel cmdline parameter, "
version_addendum", which can be used to add text to the kernel version that is reported from/proc/version.why?
We have a need to keep a single product binary (kernel) across multiple android devices. A subset of these platforms are looking for extra versioning information appended to it, accessible via
/proc/version. Rather than build multiple otherwise identical kernels with only this extended versioning as differentiation, we are looking to make this a command line parameter. Understandable if there isn't enough value-add for the community in this patch, but I figured I'd give the patch a shot, as we need this functionality locally. Thanks.Please use a newline character every 70-72 characters instead of assuming that all email programs will break that extra long line up into a readable format. (mine does not.)
Ack - sorry Randy - it was a quick cp / paste from earlier in the thread.
Quoted 5 lines
What software needs to know the version info? how early does it run? Could it get the version info from 'uname -r' instead of from
/proc/version?thanks,
This'll end up being used by a third party customer for tracking particular devices, so I'm sure "much, much later" in user space. While I'm sure they could use uname instead, the specific request was for /proc/version.
The more I look into this patch, the more I think this is a pretty specific use case that probably doesn't have a lot of community value-add outside of our scenario. Thanks for the feedback.
Quoted 35 lines · eric ernst
Quoted 22 lines · Randy Dunlap
Quoted 11 lines · eric ernst
Quoted 8 lines · Andrew Morton
Quoted 3 lines · On Thu, 5 Jun 2014 15:09:17 -0700 [email protected] wrote:
Create a kernel cmdline parameter, "
version_addendum", which can be used to add text to the kernel version that is reported from/proc/version.why?
Quoted 8 lines
We have a need to keep a single product binary (kernel) across multiple android devices. A subset of these platforms are looking for extra versioning information appended to it, accessible via
/proc/version. Rather than build multiple otherwise identical kernels with only this extended versioning as differentiation, we are looking to make this a command line parameter. Understandable if there isn't enough value-add for the community in this patch, but I figured I'd give the patch a shot, as we need this functionality locally. Thanks.Quoted 3 lines
Please use a newline character every 70-72 characters instead of assuming that all email programs will break that extra long line up into a readable format. (mine does not.)
Ack - sorry Randy - it was a quick cp / paste from earlier in the thread.
Quoted 5 lines
What software needs to know the version info? how early does it run? Could it get the version info from 'uname -r' instead of from
/proc/version?
Quoted 5 lines
Quoted 1 line
thanks,
This'll end up being used by a third party customer for tracking particular devices, so I'm sure "much, much later" in user space. While I'm sure they could use uname instead, the specific request was for
/proc/version.
sandpuppy:/home/rw # echo "Windows" > /tmp/version sandpuppy:/home/rw # mount --bind /tmp/version /proc/version sandpuppy:/home/rw # cat /proc/version
Windows
Signature · 2 lines
Thanks, //richard
Quoted 8 lines · eric ernst
We have a need to keep a single product binary (kernel) across multiple android devices. A subset of these platforms are looking for extra versioning information appended to it, accessible via
/proc/version. Rather than build multiple otherwise identical kernels with only this extended versioning as differentiation, we are looking to make this a command line parameter. Understandable if there isn't enough value-add for the community in this patch, but I figured I'd give the patch a shot, as we need this functionality locally. Thanks.
Unrecognized parameters on the kernel command line are disregarded, so your platforms should be able to parse /proc/cmdline for version_addendum=foo already.
Quoted 5 lines · On 06/05/2014 03:09 PM, [email protected] wrote:
From: Eric Ernst <[email protected]>
Create a kernel cmdline parameter, "
version_addendum", which can be used to add text to the kernel version that is reported from/proc/version.
and you still didn't update Documentation/kernel-parameters.txt.
Quoted 54 lines
Signed-off-by Eric Ernst <[email protected]>--- fs/proc/version.c | 14 +++++++++++++- init/version.c | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-)fs/proc/version.c +13
-1@@ -5,12 +5,17 @@#include <linux/seq_file.h> #include <linux/utsname.h> +#define ADDENDUM_LENGTH 20 +static char version_addendum[ADDENDUM_LENGTH ]; +static int version_proc_show (struct seq_file *m,void *v) {seq_printf (m, linux_proc_banner,utsname ()->sysname,utsname ()->release, -utsname ()->version); +utsname ()->version, + version_addendum); +return 0 ; }@@ -26,6 +31,13 @@ static const struct file_operations version_proc_fops = { .release = single_release, }; +static int __init set_version_addendum (char *str) +{ +strncpy (version_addendum, str,ADDENDUM_LENGTH -1 ); +return 0 ; +} +early_param ("version_addendum" , set_version_addendum); +static int __init proc_version_init (void ) {proc_create ("version" ,0 ,NULL , &version_proc_fops);init/version.c +1
-1@@ -47,4 +47,4 @@ const char linux_banner[] =const char linux_proc_banner[] ="%s version %s" " (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")" -" (" LINUX_COMPILER ") %s\n" ; +" (" LINUX_COMPILER ") %s " "%s\n" ;
Signature · 1 line
~Randy
Quoted 8 lines · Randy Dunlap
Quoted 5 lines · On 06/05/2014 03:09 PM, [email protected] wrote:
From: Eric Ernst <[email protected]>
Create a kernel cmdline parameter, "
version_addendum", which can be used to add text to the kernel version that is reported from/proc/version.and you still didn't update
Documentation/kernel-parameters.txt.
Correct - I was waiting for the initial feedback of whether this would be useful to community before doing this, sorry for the thrash, Randy.
Quoted 55 lines
Quoted 54 lines
Signed-off-by Eric Ernst <[email protected]>--- fs/proc/version.c | 14 +++++++++++++- init/version.c | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-)fs/proc/version.c +13
-1@@ -5,12 +5,17 @@#include <linux/seq_file.h> #include <linux/utsname.h> +#define ADDENDUM_LENGTH 20 +static char version_addendum[ADDENDUM_LENGTH ]; +static int version_proc_show (struct seq_file *m,void *v) {seq_printf (m, linux_proc_banner,utsname ()->sysname,utsname ()->release, -utsname ()->version); +utsname ()->version, + version_addendum); +return 0 ; }@@ -26,6 +31,13 @@ static const struct file_operations version_proc_fops = { .release = single_release, }; +static int __init set_version_addendum (char *str) +{ +strncpy (version_addendum, str,ADDENDUM_LENGTH -1 ); +return 0 ; +} +early_param ("version_addendum" , set_version_addendum); +static int __init proc_version_init (void ) {proc_create ("version" ,0 ,NULL , &version_proc_fops);init/version.c +1
-1@@ -47,4 +47,4 @@ const char linux_banner[] =const char linux_proc_banner[] ="%s version %s" " (" LINUX_COMPILE_BY "@" LINUX_COMPILE_HOST ")" -" (" LINUX_COMPILER ") %s\n" ; +" (" LINUX_COMPILER ") %s " "%s\n" ;