0

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

Edited by mike_2000_17: Fixed formatting

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by bala1486
0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.