Re: Question: how to communicate with kernel module.

From: Damir Cosic (damir@fatpipeinc.com)
Date: Tue Mar 21 2000 - 14:37:37 EST


ÄåªáµÓ¤l wrote:
>
> Dear all:
> I wrote two programs to test how to communicate with the kernel module.
> The first one is a user program (user.c) , it opens file(rw_test) in the
> /proc, and
> write test data to the rw_test file, then read these data from it.
> Another one is a kernel module(module.c), it register a /proc
> file(rw_test).And
> manipulate read and write opertions.
> I execute the following commands:
> gcc -o user user.c
> gcc -c module.c -D__KERNEL__ -DMODULE -Wall -O
> insmod module.o
> ./user
> but the user program print error(can't open the /proc/rw_test file)
> why??
> I feel so sad.

You probably have problems with access privileges.

> static int module_permission(struct inode *inode, int op)
> {
> if (op == 4 || (op == 2 && current->euid == 0))
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This means that only process with superuser effective uid can write to
this file. So you have to either change this line or to run your user
program as root.
> return 0;
>
> return -EACCES;
> }

Also, use perror() in order to find out what kind of error you are
getting.

Hope this helps.

Damir

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Thu Mar 23 2000 - 21:00:34 EST