Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


Search this Thread
Old 01-03-2006, 12:17 PM   #1
LQ Newbie
Registered: Aug 2005
Posts: 13

Rep: Reputation: 0
Question Character device driver

I have written a character device driver. In the ioctl function , i want to use a function called ext2_get_inode() which has been defined in the file /usr/src/linux-2.6.11/fs/ext2/inode.c. I am not able to use this function in my device driver.
Following is the code for my device driver :


static int major;
struct task_struct *o;
struct files_struct *o1;
struct file *f;
struct dentry *d;
struct inode *i;
struct ext2_inode *e;
struct buffer_head *bh1;
unsigned long t;
unsigned int fd,t1;
int my_open(struct inode *,struct file *);
int my_release(struct inode *,struct file *);
int my_ioctl(struct inode *,struct file *,unsigned int cmd,unsigned long arg);
struct file_operations my_fops = {
.open = my_open,
.release = my_release,
.ioctl = my_ioctl
int main(void);
int init_module(void);
void cleanup_module(void);
int init_module(void)
int major=register_chrdev(0,"fchar",&my_fops);
printk(KERN_ALERT "\ndevice registered. The major number is %d. ",major);

printk(KERN_ALERT "device failed to registered");
return -1;
return 0;

void cleanup_module(void)
printk(KERN_ALERT "device failed to unregistered");
printk(KERN_ALERT "\ncleaned");


int my_open(struct inode *inode,struct file *filep)
printk(KERN_ALERT "yahooooooooooooooooooooooo");
return 0;

int my_release(struct inode *inode,struct file *filep)
printk(KERN_ALERT "byeeeeeeeeeeeeeeeeeeee");
return 0;
int my_ioctl(struct inode *inode,struct file *file,unsigned int cmd,unsigned long arg)
printk(KERN_ALERT "\nThe reserved number is %d.",t1);
It is giving me a lot of warnings of function undefined when i use the make command.
But if i use insmod, it is giving me a lot of errors for the same files.
Can anyone help me as to how to use this function in that particular file???
Thank you.


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 carthyc Linux - Newbie 1 07-07-2005 07:23 AM
Character Device kernel(2.4.18) - module problem shibdas Programming 2 11-11-2004 03:52 AM
How to change character device file name? taphos Linux - General 2 03-28-2004 08:12 AM
device driver yanw Linux - Hardware 1 01-23-2003 09:00 AM

All times are GMT -5. The time now is 05:01 AM.

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