LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 08-16-2004, 12:38 AM   #1
thirumalai
LQ Newbie
 
Registered: Aug 2004
Location: India
Posts: 6

Rep: Reputation: 0
Device Driver Program's file operations error


Hi all,

now i m trying to writea simple device driver program..
in my first sample program, i m getting the following error....



error: variable `fo' has initializer but incomplete type
error: storage size of `fo' isn't known

plz anyone help me to solve this pbm


this is the pgm
===========
#define MODULE
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/fs.h>


int dopen(struct inode * inode,struct file *file)
{
printk("dopen\n");
return 0;
}
struct file_operations fo={0,0,0,0,0,0,0,dopen,0,0};
int init_module() {
printk("init_module\n");
register_chrdev(251,"cde1",&fo);
return 0;
}
void cleanup_module() {
printk("cleanup_module\n");
unregister_chrdev(251,"cde1");
}


Last edited by thirumalai; 08-16-2004 at 12:41 AM.
 
Old 08-16-2004, 01:23 AM   #2
cppkid
Member
 
Registered: Jul 2004
Location: Pakistan
Distribution: Ubuntu
Posts: 185

Rep: Reputation: 30
Quote:
struct file_operations fo={0,0,0,0,0,0,0,dopen,0,0};
In this line of code you have declaired the 'fo' as structure file_operations. I don't know what is that structure file_operations. Is it a predefined structure or you defined it somewhere. But i have got a little experience about this error and it means that the structure file_operations is unkown. Check if you spelled it right or you have included the header file that gives the defination for this structure .... etc..

Wish you all the best.
 
Old 08-16-2004, 01:45 AM   #3
cppkid
Member
 
Registered: Jul 2004
Location: Pakistan
Distribution: Ubuntu
Posts: 185

Rep: Reputation: 30
sorry i searched for it and found the defination of this structure in linux/fs.h and you have include that file. Now from my point of view there can be one of two problems.

1. You are giving and extra aurgument to the structure, means check for the number of the memebers of the structure and the number of the members you have initialized, are they same. Also try to give some other aurgument instead of 0's, Any dummy augument just to check, Coz while searching it, I read somwhere on search results by google that maybe you have assigned NULL to all the members, this can cause this error too.

2. open the file linux/fs.h and check for that structure and see the member list and order again.

Wish you all the best
 
Old 08-16-2004, 01:48 AM   #4
thirumalai
LQ Newbie
 
Registered: Aug 2004
Location: India
Posts: 6

Original Poster
Rep: Reputation: 0
Thank u for ur inormation...

But that structure is available in the <linux/fs.h>

i checked the spelling also ... no pbm on that.....
 
Old 08-16-2004, 02:36 AM   #5
infamous41md
Member
 
Registered: Mar 2003
Posts: 804

Rep: Reputation: 30
you need to #define __KERNEL__ before including any headers, or else the many kernel structure and defines won't be included.

Last edited by infamous41md; 08-16-2004 at 02:37 AM.
 
Old 08-16-2004, 02:56 AM   #6
thirumalai
LQ Newbie
 
Registered: Aug 2004
Location: India
Posts: 6

Original Poster
Rep: Reputation: 0
Thanks a lot....

error is fixed after including the #define __KERNEL__ before including any header files....
 
  


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
FD Device Driver Error NeoKaiserSigma Linux - Laptop and Netbook 10 08-27-2004 08:16 AM
My driver for mouse gives irq no. error, device busy Jyo Linux - Newbie 1 08-24-2004 05:04 PM
use of proc file system in linux device driver amitchakote Linux - Software 0 06-20-2004 11:27 AM
file operations in BASH snorky Linux - Newbie 2 11-24-2003 07:07 PM
writing a config file for a device driver britneykiller Programming 0 03-08-2002 08:22 AM


All times are GMT -5. The time now is 08:18 AM.

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