# Adding a System call



## julai (Jun 29, 2012)

Hello, I am completely new to FREEBSD FreeBSD and kernel programming.

As part of my O/S course, I need to add a system call to a kernel which takes UID and signum as its arguments and sends it to all processes under that UID.

I have no clue on how to proceed, can someone please help? I tried looking at the existing kernel code but I have no clue on what's happening!


----------



## doena (Jun 29, 2012)

Hello,
Your starting point may be the following two kernel-files:

```
sys/kern/syscalls.master
sys/kern/syscalls.c
sys/kern/kern_prot.c
sys/kern/init_sysent.c
```
Maybe start with looking how a particular other syscall is implemented in there and do analogue things.

Regards,
Doena


----------



## DutchDaemon (Jun 29, 2012)

Show your work, we are not here to solve your homework. Let us see what you have so far.


----------



## fluca1978 (Jun 29, 2012)

julai said:
			
		

> As part of my O/S course, I need to add a system call to a kernel which takes UID and signum as its arguments and sends it to all processes under that UID.
> 
> I have no clue on how to proceed, can someone please help? I tried looking at the existing kernel code but I have no clue on what's happening!



*T*ry reading this.


----------



## julai (Jun 30, 2012)

Thanks a lot guys.


----------



## julai (Jul 6, 2012)

killpg1 system call is showing error when im building using make...its asking to define prototype..am I missing any header files? I included signal.h sys/types.h


----------



## caesius (Jul 6, 2012)

Posting the exact error will get more replies.


```
#include <sys/systm.h>
```

Do you have this?


----------



## julai (Jul 6, 2012)

caesius said:
			
		

> Posting the exact error will get more replies.
> 
> 
> ```
> ...



I included it...but still the error persists 

Here is the exact error

cc1: warnings being treated as errors
../../../local/uidkill.c: In function 'sys_uidkill':
../../../local/uidkill.c:96: warning: implicit declaration of function 'kill'
../../../local/uidkill.c:96: warning: nested extern declaration of 'kill' [-Wnested-externs]


----------



## rajl (Jul 9, 2012)

I assume that uidkill.c is a file that you coded yourself.

My guess is that you are experiencing a C function prototype error.  This is not a BSD error, but a programmer error for violating C's language rules.  In C, you have to declare functions before they are called.  This is done one of two ways:

1) You list all function prototypes at the top of the file; or
2) You code your functions in full before they are called by subsequent functions in the file.

Based on your *very* limited information, this is my guess.  We are not mind readers, so they more information you give us, the better anyone can help.


----------

