2014-06-02 18:46:43

by Eric Ernst

[permalink] [raw]
Subject: Re: [PATCH 1/1] Add kernel parameter for kernel version


On 14-05-27 01:06 PM, Randy Dunlap wrote:
> On 05/27/2014 12:48 PM, Josh Boyer wrote:
>> 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.
>
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.


2014-06-05 22:11:15

by Eric Ernst

[permalink] [raw]
Subject: [PATCH v1 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.

Signed-off-by: Eric Ernst <[email protected]>
---
fs/proc/version.c | 14 +++++++++++++-
init/version.c | 2 +-
2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/fs/proc/version.c b/fs/proc/version.c
index d2154eb6d78f..442e69e3eecb 100644
--- a/fs/proc/version.c
+++ b/fs/proc/version.c
@@ -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);
diff --git a/init/version.c b/init/version.c
index 1a4718e500fe..180059b69b7a 100644
--- a/init/version.c
+++ b/init/version.c
@@ -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";
--
1.7.9.5

2014-06-05 22:16:35

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH v1 1/1] Add kernel parameter for kernel version

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?

2014-06-05 22:17:34

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH v1 1/1] Add kernel parameter for kernel version

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.

> Signed-off-by: Eric Ernst <[email protected]>
> ---
> fs/proc/version.c | 14 +++++++++++++-
> init/version.c | 2 +-
> 2 files changed, 14 insertions(+), 2 deletions(-)
>
> diff --git a/fs/proc/version.c b/fs/proc/version.c
> index d2154eb6d78f..442e69e3eecb 100644
> --- a/fs/proc/version.c
> +++ b/fs/proc/version.c
> @@ -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);
> diff --git a/init/version.c b/init/version.c
> index 1a4718e500fe..180059b69b7a 100644
> --- a/init/version.c
> +++ b/init/version.c
> @@ -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";
>


--
~Randy

2014-06-05 22:17:47

by Eric Ernst

[permalink] [raw]
Subject: Re: [PATCH v1 1/1] Add kernel parameter for kernel version


On 14-06-05 03:16 PM, Andrew Morton wrote:
> 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.

2014-06-05 22:18:44

by Eric Ernst

[permalink] [raw]
Subject: Re: [PATCH v1 1/1] Add kernel parameter for kernel version


On 14-06-05 03:17 PM, Randy Dunlap wrote:
> 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.
>> Signed-off-by: Eric Ernst <[email protected]>
>> ---
>> fs/proc/version.c | 14 +++++++++++++-
>> init/version.c | 2 +-
>> 2 files changed, 14 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/proc/version.c b/fs/proc/version.c
>> index d2154eb6d78f..442e69e3eecb 100644
>> --- a/fs/proc/version.c
>> +++ b/fs/proc/version.c
>> @@ -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);
>> diff --git a/init/version.c b/init/version.c
>> index 1a4718e500fe..180059b69b7a 100644
>> --- a/init/version.c
>> +++ b/init/version.c
>> @@ -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";
>>
>

2014-06-05 22:29:42

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH v1 1/1] Add kernel parameter for kernel version

On 06/05/2014 03:15 PM, eric ernst wrote:
>
> On 14-06-05 03:16 PM, Andrew Morton wrote:
>> 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,
--
~Randy

2014-06-05 22:30:31

by David Rientjes

[permalink] [raw]
Subject: Re: [PATCH v1 1/1] Add kernel parameter for kernel version

On Thu, 5 Jun 2014, eric ernst wrote:

> 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.

2014-06-05 22:58:52

by Eric Ernst

[permalink] [raw]
Subject: Re: [PATCH v1 1/1] Add kernel parameter for kernel version


On 14-06-05 03:29 PM, Randy Dunlap wrote:
> On 06/05/2014 03:15 PM, eric ernst wrote:
>> On 14-06-05 03:16 PM, Andrew Morton wrote:
>>> 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.)
Ack - sorry Randy - it was a quick cp / paste from earlier in the thread.
>
> 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.

2014-06-05 23:06:26

by Richard Weinberger

[permalink] [raw]
Subject: Re: [PATCH v1 1/1] Add kernel parameter for kernel version

On Fri, Jun 6, 2014 at 12:56 AM, eric ernst <[email protected]> wrote:
>
> On 14-06-05 03:29 PM, Randy Dunlap wrote:
>>
>> On 06/05/2014 03:15 PM, eric ernst wrote:
>>>
>>> On 14-06-05 03:16 PM, Andrew Morton wrote:
>>>>
>>>> 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.)
>
> Ack - sorry Randy - it was a quick cp / paste from earlier in the thread.
>
>>
>> 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.


sandpuppy:/home/rw # echo "Windows" > /tmp/version
sandpuppy:/home/rw # mount --bind /tmp/version /proc/version
sandpuppy:/home/rw # cat /proc/version
Windows

--
Thanks,
//richard