System Call in UML
Define the entry point
The first thing you need to do is modify the file unistd.h in include/asm/arch. In this file, you need to add a line providing an id for your system call. Locate the bunch of lines of the form:
#define __NR_somename NNN
You need to add a new line, replacing ``somename" with your system call's name. Next, you must add and entry refering to your call in the system calls table. To do this, modify sys_call_table.c file in arch/um/kernel and add a line:
[ __NR_somename ] = sys_somename,
In the same file, you must change the ``LAST_GENERIC_SYSCALL" so that your new system call's id is considered to be within the allowable range.
#define LAST_GENERIC_SYSCALL __NR_somename
Finally, add a declaration for your system call in the area where all the other system calls are defined, as shown on the following line:
extern syscall_handler_t sys_somename;
Having done all these, an attempt to compile the kernel should fail during linking, as the ``sys_somename" function must now be implemented.
Implementation code
First of all, create a header file somename.h for your system call and place it in arch/um/include as shown in listing 1.
Then, write out the implementation somename.c of your system call in arch/um/kernel as shown in listing 2.
Finally, modify the respective Makefile in arch/um/kernel and add somename.o to the list of build targets.
Listing 3 shows a program which uses the _syscall macro to create a stub for the system call. It then proceeds to call the stub function. When compiling, be sure to specify the -I option so that gcc will look at the modified version of unistd.h. In the example, the preprocessor looks for the file in asm/arch/unistd.h, so if the UML code is in directory /uml-code you should compile with -I/uml-code.
In this step, I have done something different as I do not have the source inside the UML system. I have written a forensic-user.h in /usr/include/sys of slackware.img that includes
0 Comments:
Post a Comment
<< Home