Re: Environment variables inside the kernel?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Whoa!, I did not expect so many replies. Thank you for your answers.

The thing is that the Computer Architecture area of the University I
am studying at is developing a parallel filesystem. Currently it works
as a stand-alone program (this is why it uses resources like
environment variables), and I have been told to integrate it in the
Linux kernel.

I have to justify changes on this filesystem code (like avoiding the
use of environment variables) to my tutor. In this case I needed to
find why it is not possible to use environment variables in kernel
space.

I was looking for a reference documentation which give a definition of
environment variables that exclude their use inside the kernel, or,
simply, I expected to find a design decision to justify this. But I
think I have enough information with your answers, I will be able to
elaborate a satisfactory conclusion.

Excuse me if the topic was so obvious (it was not to me) and thank you again,

On 8/18/05, Linh Dang <[email protected]> wrote:
> Douglas McNaught <[email protected]> wrote:
> 
> >
> > If someone is insisting you use environment varaiables in kernel
> > code, challenge them to show you where they are implemented in the
> > kernel.  :)
> >
> > -Doug
> 
> They're in current process's vm. You just have to parse it yourself.
> 
> something along the (untested) lines:
> 
>         struct mm_struct *mm = current ? get_task_mm(current) : NULL;
> 
>         if (mm) {
>                 unsigned env_len = mm->env_end - mm->env_start;
>                 char* env = kmalloc(env_len, GFP_KERNEL);
>                 access_process_vm(current, mm->env_start, env,
>                                            env_len, 0);
> 
>                 /* env is now a big buffer containing null-terminated
>                    strings representing evironment variables */
> 
>                 mmput(mm);
>         }

-- 
Guillermo
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]
  Powered by Linux