LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   device driver (https://www.linuxquestions.org/questions/programming-9/device-driver-99411/)

rjc915 10-02-2003 10:00 AM

device driver
 
when i declare a file_operations structure i get many errors

here is the struct

struct file_operations test_fops = {
.read = test_read,
.write = test_write,
.open = test_open,
.release = test_release
};


some errors:

variable `test_fops` has initializer but incomplete type
unknown field read in initializer
unknown field write in initializer


i have include the <linux.fs.h> header file


any help would be great

thanks

crabboy 10-02-2003 10:29 AM

file_operations is a struct full of function pointers that map the read/write/... operations to different functions depening on the file system.

You should probably take a look at how the current file systems use the struct. Look in the linux kernel source under fs/ext2 for an example. The functions used in the struct in the ext2/file.c are declared in /usr/include/linux/ext2_fs.h

udayan 10-04-2003 04:45 AM

http://www.xml.com/ldd/chapter/book/ch03.html#t3

this place would be of some help..

udayan
:jawa:

jimveta 10-04-2003 05:02 AM

try:
Code:

struct file_operations test_fops = {
    test_lseek,
    test_read,
    test_write,
        ....
    /* you must initialize all the members; can use NULL as well */
};

or
Code:

struct file_operations test_fops;
bzero(&test_fops, sizeof (test_fops));  /* clear struct */
test_fops.read = test_read;
test_fops.write = test_write;
  ...


orgcandman 10-06-2003 11:43 AM

Hi,
For your device driver, it looks like you're not using GNU tagged initialization correctly. Try something like:

struct file_operations test_fops = {
read: test_read,
write: test_write,
open: test_open,
release: test_release
};

that seems to be the method of doing tagged initiliazion of a struct. ymmv.

Aaron


All times are GMT -5. The time now is 09:23 PM.