Re: Environment variables inside the kernel?

From: Alan Cox
Date: Thu Aug 18 2005 - 17:45:05 EST


On Iau, 2005-08-18 at 14:23 -0400, Linh Dang wrote:
> 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);


That is the environment passed to the application, not the environment
it is running with. Only the application knows where that is, and once
you do things like putenv() it becomes rather relevant.

Essentially environment is user space business and you can't get at it
from the kernel.

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