Re: how do you call userspace syscalls (e.g. sys_rename) from inside kernel

From: Luke Kenneth Casson Leighton
Date: Fri Oct 08 2004 - 11:12:06 EST


On Fri, Oct 08, 2004 at 05:18:40PM +0200, Brice Goglin wrote:
> > call sys_rename, sys_pread, sys_create, sys_mknod, sys_rmdir
> > etc. - everything that does file access.
>
> If you ever actually call sys_this or sys_that ... from
> the kernel, you'll have to do something like this to avoid
> copy_from/to_user to fail because the target buffer is not
> in kernel space:
>
> mm_segment_t old_fs;
> old_fs = get_fs();
> set_fs(KERNEL_DS);
> <do you stuff here>
> set_fs(old_fs);

that's it! that's what i was looking for. thank you.

l.
-
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/