Hello, I am a beginner in FreeBSD. I installed FreeBSD-11.0-RELEASE-amd64 on VM. I want to add first new system call that it is for calculating sum of two values.
I read a sample in https://www.nostarch.com/rootkits.htm.
But my function has errors!
myfile.c
Errors:
I read a sample in https://www.nostarch.com/rootkits.htm.
Code:
struct sc_example_args {
char *str;
};
static int
sc_example(struct thread *td, void *syscall_args)
{
struct sc_example_args *uap;
uap = (struct sc_example_args *)syscall_args;
printf("%s\n", uap->str);
return(0);
}
Notice that the system call’s arguments are declared within a structure
(sc_example_args). Also, notice that these arguments are accessed within the
system call function by first declaring a struct sc_example_args pointer (uap)
and then assigning the coerced void pointer (syscall_args) to that pointer.
myfile.c
Code:
#include <sys/sysproto.h>
#include <sys/param.h>
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/module.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/sysent.h>
#ifndef _SYS_SYSPROTO_H_
struct myargs {
unsigned int k0;
unsigned int k1;
};
#endif
int func (struct thread *td, void *args)
{
struct myargs *uap;
unsigned int a,b,c;
uap = (struct myargs *)args;
a = uap->k0;
b = uap->k1;
c = a + b;
printf("%u + %u = %u\n",a,b,c);
return (0);
}
Errors:
Code:
note: forward declaration of 'struct myargs'
struct myargs *uap;
error: incomplete definition of type 'struct myargs'
a = uap->k0;