how to read the process environment in a module

Stelian Pop (stelian@captimark.fr)
Wed, 27 Jan 1999 18:01:20 +0100 (CET)


I need to read the process environment in a module.

In the 2.0 kernels, I used (successfully):

unsigned long i;
char c;

printk("Environment: ");
for (i=current->mm->env_start; i<current->mm->env_end; i++) {
c=get_fs_byte(i);
printk("%c", c);
}
printk("\n");

I tried to make this work for the 2.2.0 kernel:

unsigned long i;
char c;

printk("Environment:");
for (i=current->mm->env_start; i<current->mm->env_end; i++) {
get_user(c, (char *)i);
printk("%c", c);
}
printk("\n");

but I get only a (small) part of the environment, starting and ending at a
random position...

What is the correct way to do this?

PS1. I looked at drivers/block/floppy.c and I found the same method, used
when the floppy module parameters are passed by the environment. Anyone
use this method with succes?

PS2. In fs/proc/array.c a different, much more complex, method is used,
but I was unable to do the same in a _module_ (seems to work only when
compiled into the kernel).

Thanks.

---
Stelian Pop <spop@captimark.fr>| Too many things happened today  
Captimark                      | Too many words I don't wanna say
Paris, France                  | I wanna be cool but the heat's coming up
                               | I'm ready to kill 'cause enough is enough
PGP key available on request   |              (Accept - "Up To The Limit")

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