The socketcall System Call

In addition to the read and write operations of the file functions that enter the kernel by means of the system calls of the virtual filesystem where they are redirected to function pointers of the socket_file_ops structure, it is also necessary to carry out other tasks with sockets that cannot be forced into the file scheme. These include, for example, creating a socket and bind and listen calls.

For this purpose, Linux provides the socketcall system call, which is implemented in sys_socketcall and to which I have made frequent reference.

It is remarkable that there is just one system call for all 17 socket operations. This results in very different lists of arguments depending on the task in hand. The first parameter of the system call is therefore a numeric constant to select the desired call. Possible values are, for example, sys_socket, sys_bind, sys_accept, and sys_recv. The routines of the standard library use the same names but are all redirected internally to socketcall with the corresponding constant. The fact that there is only a single system call is primarily for historical reasons.

The task of sys_socketcall is not especially difficult — it simply acts as a dispatcher to forward the system call to other functions, each of which implements a "small" system call to which the parameters are passed:

Continue reading here: Netsocketc

Was this article helpful?

0 0