Can I use kernel routines in user program? - Help

This is a discussion on Can I use kernel routines in user program? - Help ; Hi To find out how netlink sockets really work, I have written a small program. Now I can't compile it. Is it possible to use kernel routines in a user program? I have posted the code. Do I have to ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Can I use kernel routines in user program?

  1. Can I use kernel routines in user program?

    Hi

    To find out how netlink sockets really work, I have written a small
    program. Now I can't compile it. Is it possible to use kernel routines
    in a user program? I have posted the code. Do I have to compile it
    other than:

    gcc my_program.c

    //my_program.c
    #ifndef __KERNEL__
    #define __KERNEL__
    #endif

    #include
    #include

    int main() {
    struct sock *netlink = netlink_kernel_create(NETLINK_ROUTE,0);

    sock_release(netlink);

    printf("Netlink_route=%d",NETLINK_ROUTE);
    return 0;
    }
    //end of my_prgram.c

    The following errors appeared:
    : undefined reference to `netlink_kernel_create'
    : undefined reference to `sock_release'

    Thanks for your help
    Chris

  2. Re: Can I use kernel routines in user program?

    No, you can't use kernel routines in a user program. The program would have
    to be linked into the kernel, which means it couldn't be a user program.

    Your question is really about netlink sockets. Take a look at

    http://snafu.freedom.org/linux2.2/do...ink-HOWTO.html

    "Christoph Jossi" wrote in message
    news:df57ed82.0404190457.688269d8@posting.google.c om...
    > Hi
    >
    > To find out how netlink sockets really work, I have written a small
    > program. Now I can't compile it. Is it possible to use kernel routines
    > in a user program? I have posted the code. Do I have to compile it
    > other than:
    >
    > gcc my_program.c
    >
    > //my_program.c
    > #ifndef __KERNEL__
    > #define __KERNEL__
    > #endif
    >
    > #include
    > #include
    >
    > int main() {
    > struct sock *netlink = netlink_kernel_create(NETLINK_ROUTE,0);
    >
    > sock_release(netlink);
    >
    > printf("Netlink_route=%d",NETLINK_ROUTE);
    > return 0;
    > }
    > //end of my_prgram.c
    >
    > The following errors appeared:
    > : undefined reference to `netlink_kernel_create'
    > : undefined reference to `sock_release'
    >
    > Thanks for your help
    > Chris




+ Reply to Thread