954,234 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

debugfs_create_file doesn’t create file

Hello, I am trying to create a debugfs file using the debugfs_create_file(...). I have written a sample code for this.

static int __init mmapexample_module_init(void)
{
file1 = debugfs_create_file("mmap_example", 0644, NULL, NULL, &my_fops)\
;
printk(KERN_ALERT "Hello, World\n");
if(file1==NULL)
{
printk(KERN_ALERT "Error occured\n");
}
if(file1==-ENODEV)
{
printk(KERN_ALERT "ENODEV occured\n");
}
return 0;
}
When i ran insmod i could get the Hello, World message but no the error message. So i think the debugfs_create_file worked fine. However i couldn't find any file in /sys/kernel/debug. The folder is there but it is empty. Can anyone help me with this? Thank you...

Thanks, Bala

bala1486
Newbie Poster
4 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

I would try printing the value of file1, just to see what the function is returning.

gerard4143
Nearly a Posting Maven
2,272 posts since Jan 2008
Reputation Points: 512
Solved Threads: 387
 

I got it working... I need to mount the debugfs first and then call debugfs() call.

bala1486
Newbie Poster
4 posts since May 2010
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: