lkml.org 
[lkml]   [2005]   [Aug]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: Environment variables inside the kernel?
From
Date
Douglas McNaught <doug@mcnaught.org> 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);
}

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

\
 
 \ /
  Last update: 2005-08-18 20:26    [W:0.106 / U:0.240 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site