LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 10-02-2003, 10:00 AM   #1
rjc915
LQ Newbie
 
Registered: Sep 2003
Posts: 6

Rep: Reputation: 0
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
 
Old 10-02-2003, 10:29 AM   #2
crabboy
Moderator
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 120Reputation: 120
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
 
Old 10-04-2003, 04:45 AM   #3
udayan
Member
 
Registered: Apr 2002
Location: India
Distribution: Linux Redhat 7.0
Posts: 62

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

this place would be of some help..

udayan
 
Old 10-04-2003, 05:02 AM   #4
jimveta
Member
 
Registered: Oct 2003
Location: los angeles
Posts: 32

Rep: Reputation: 15
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;
   ...

Last edited by jimveta; 10-04-2003 at 05:10 AM.
 
Old 10-06-2003, 11:43 AM   #5
orgcandman
Member
 
Registered: May 2002
Location: dracut MA
Distribution: Ubuntu; PNE-LE; LFS (no book)
Posts: 594

Rep: Reputation: 102Reputation: 102
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
device driver jful99 Programming 6 10-09-2005 12:34 AM
Device driver from 2.4 to 2.6 setu_garg Programming 1 09-16-2005 11:27 AM
device driver carthyc Linux - Newbie 1 07-07-2005 07:23 AM
Device Driver deveshs Programming 1 04-26-2005 11:53 PM
device driver yanw Linux - Hardware 1 01-23-2003 09:00 AM


All times are GMT -5. The time now is 02:39 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration