Thanks for your reply. However, I had gone over both these articles.
As a matter of fact, I referred to code in simple udp server, to write some
of my own code. However, as I said, I need to use system calls to get a
socket fd to be used in sys_poll(). Otherwise, I guess I will have to call
something like tcp_poll or udp_poll.

About why system calls are not to be used in kernel space:
1. I did not find anything useful yet. May be my search terms are wrong.
2. One of the links that you have given, again makes a generic statement
"Generally speaking, trying to use any of the sys_*() functions from the
kernel itself is a bad idea" without giving any specific reasons. It,
however, gives reasons about why its a bad idea to read/write to files from
kernel space, to which I agree.

On Mon, Aug 3, 2009 at 1:43 AM, Pei Lin <[email protected]> wrote:

> it is not commended to use system call in the kernel space. It has no
> necessary to do so.
> u can research the maillist for why.
> i think the system call is the interface for user space applications to
> use.
> u wanna write the sock in the kernel, plz use the function the kernel
> provide.
> give u two articles for reference:
> http://kernelnewbies.org/Simple_UDP_Server
> http://kernelnewbies.org/FAQ/WhyWritingFilesFromKernelIsBad
>
> IMO, the functions designed had their own scope for using.
>
> BRs
> Lin
>
> 2009/8/3 Methos <[email protected]>:
> > hi,
> > I want to write a simple network client server inside kernel(2.6.22). I
> know
> > that this should not be done in kernel, however, this is a research
> project
> > and I just wanted to compare a few things. I was using sock_create() to
> > create a socket. This call returns an allocated struct socket upon
> > successful completion. However, now I want to use sys_poll() to poll the
> > socket to check if the data is available. Since I need fd for this, I was
> > thinking about recompiling kernel with exported sock_map_fd() (and
> > sock_poll()) and using that to get an fd.
> > My questions:
> > 1. I assume that usually when a socket is created from user level
> process,
> > sock_map_fd() will allocate an fd from table that is associated with that
> > user level process. However, in this case, my kernel thread is not
> > associated with any process. Would it be still safe to call
> sock_map_fd(),
> > get an fd and call sys_poll() on it?
> > 2. In the latest kernel (2.6.30), I see that most of the system calls are
> > defined using SYSCALL_DEFINEN() macro. What is the reason in doing so?
> Can
> > one still use system calls defined in this way inside the kernel?
> > In general, why system calls are hidden from kernel processes?
>

Reply via email to