The HyperNews Linux KHG Discussion Pages
Next-in-Thread Next Message Previous Message Next Thread

Re:return values

Forum: The Linux Kernel Hackers' Guide
Re: Question Problem creating a new system call
Re: Question system call returns "Bad Address". Why?
Re: Question Re:return values (C.H.Gopinath)
Date: Mon, 22 Dec 1997 08:41:22 GMT
From: Sameer Shah <ssameer@novell.com>

You cannot do the string_length because you are trying
to access a location that resides in the user space.
When switching to kernel mode, the data segment register
is changed to a location inside the kernel. But to allow
for such operations the kernel maintains address of
user's data segment in some other register (FS).
To access any string or some indirection data, you
have to actually copy that inside the kernel and then
you can go on with the normal strcpy functions. There
are few functions, I don't exactly recall their names
but with names like copy_fs_to_kernel, copy_kernel_to_fs
which allow you to copy between user and kernel spaces.

Just look at the implementation of some system call where
entire structures are passed (through a pointer to the
structure) e.g. ioctl() and you may need to do something
similar.

Hope this helps,
Sameer

Next-in-Thread Next Message Previous Message Next Thread

to: "Re:return values"

Subscribe Membership Move/Remove Admin Mode Show Frames Help for HyperNews 1.9.4