Search code examples
ckernelfreebsdbsd

Conflict error when trying to compile a syscall .c file in freebsd


i am trying to add a new syscall to freebsd 8. i am using freebsd on VMplayer .when i trying to compile the module i give this error :

enter image description here

my code is(i also have a Makefile file) :

#include <sys/param.h>
#include <sys/types.h>
#include <sys/proc.h>
#include <sys/module.h>
#include <sys/sysent.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/sysproto.h>
struct user_datas{

};

static char* rot13func(struct thread* td , void* args)
{
    struct user_datas* upp=args;
    char* myarray=(upp->input);
    return myarray;
}

static struct sysent rot13func_sysent={
    1,
    rot13func
};

static int offset=NO_SYSCALL;


static int load (struct module *module , int cmd, void *arg)
{
    int error=0;
    switch(cmd){
       case MOD_LOAD:
          break;
       case MOD_UNLOAD:
          break;
       default:
          error=EOPNOTSUPP;
          break;
    }
    return(error);
}

SYSCALL_MODULE(rot13func, &offset , & rot13func_sysent , load, NULL);

Solution

  • It looks like your Makefile is incorrect and uses wrong include paths. Try using one from the /usr/share/examples/kld/syscall/module/ example, which looks like:

    # Makefile for building the sample syscall module
    # $FreeBSD: src/share/examples/kld/syscall/module/Makefile,v 1.2 2001/09/18 12:03:42 ru Exp $
    
    KMOD=   syscall
    SRCS=   syscall.c
    
    .include <bsd.kmod.mk>
    

    It will do appropriate steps to set up proper module build environment for you.