2014-11-05 08:03:12

by santosh nayak

[permalink] [raw]
Subject: How to access Linux Kernel environment Variables ?

Hi all,

Is there any system call in Linux which serve the purpose of "kenv()"
of FreeBSD ?


In FreeBSD:
-----------------
Kernel environment variables are saved at "/boot/loader.conf" and
those variables can be accessed using "kenv()" system call in C
program.
----------------


Is there any similar functionality available in Linux kernel ?


Thanks
Santosh


2014-11-05 09:22:09

by Richard Weinberger

[permalink] [raw]
Subject: Re: How to access Linux Kernel environment Variables ?

On Wed, Nov 5, 2014 at 9:03 AM, santosh prasad nayak
<[email protected]> wrote:
> Hi all,
>
> Is there any system call in Linux which serve the purpose of "kenv()"
> of FreeBSD ?
>
>
> In FreeBSD:
> -----------------
> Kernel environment variables are saved at "/boot/loader.conf" and
> those variables can be accessed using "kenv()" system call in C
> program.
> ----------------
>
>
> Is there any similar functionality available in Linux kernel ?

/proc/cmdline?

--
Thanks,
//richard

2014-11-05 10:56:38

by santosh nayak

[permalink] [raw]
Subject: Re: How to access Linux Kernel environment Variables ?

Thanks Richard for your response.

Is there any system call in Linux which can access and set variables
in /proc/cmdline ? (Similar to kenv() in FreeBSD which can access and
set variables in /boot/loader.conf).

I would like to use that system call in linux C code, the way I am
using kenv() in freeBSD environment.

Regards
Santosh

On Wed, Nov 5, 2014 at 2:44 PM, Richard Weinberger
<[email protected]> wrote:
> On Wed, Nov 5, 2014 at 9:03 AM, santosh prasad nayak
> <[email protected]> wrote:
>> Hi all,
>>
>> Is there any system call in Linux which serve the purpose of "kenv()"
>> of FreeBSD ?
>>
>>
>> In FreeBSD:
>> -----------------
>> Kernel environment variables are saved at "/boot/loader.conf" and
>> those variables can be accessed using "kenv()" system call in C
>> program.
>> ----------------
>>
>>
>> Is there any similar functionality available in Linux kernel ?
>
> /proc/cmdline?
>
> --
> Thanks,
> //richard

2014-11-05 11:18:47

by Richard Weinberger

[permalink] [raw]
Subject: Re: How to access Linux Kernel environment Variables ?

Am 05.11.2014 um 11:56 schrieb santosh nayak:
> Thanks Richard for your response.
>
> Is there any system call in Linux which can access and set variables
> in /proc/cmdline ? (Similar to kenv() in FreeBSD which can access and
> set variables in /boot/loader.conf).

No.

> I would like to use that system call in linux C code, the way I am
> using kenv() in freeBSD environment.

Create a wrapper function which behaves like kenv().
Should be doable in a few lines of code.

Thanks,
//richard