Re: get_fs() and set_fs() mm_segment_t

From: Bogdan Diaconescu (bogdand@develop4all.com)
Date: Wed Nov 07 2001 - 16:09:23 EST


Hi,
On x86 platforms Linux uses FS register to keep the data segment
register with which access user segment register. If a sys_call is made
and the kernel needs to copy data from user space then FS will have the
value USER_DS. Many kernel functions copy or return data from/to user
space. In order to use the same functions to copy/return data from/to
kernel space you need to do the followings:
mm_segment_t* old_fs;
old_fs = get_fs();
set_fs(KERNEL_DS);
/* call the kernel functions */
set_fs(old_fs);

-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html



This archive was generated by hypermail 2b29 : Wed Nov 07 2001 - 21:00:41 EST