Please note that LinuxExchange will be shutting down on December 31st, 2016. Visit this thread for additional information and to provide feedback.

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

asked 05 May '10, 00:03

bala1486's gravatar image

bala1486
3324
accept rate: 0%

edited 05 May '10, 01:11

Web31337's gravatar image

Web31337
317111

Please accept an answer so the question/answer can be finished. Or provide more details so we can help.

(20 Apr '11, 13:55) rfelsburg ♦



Hi,

Firstly, did you check the logs ? the dmesg ? Also, try

echo 8 > /proc/sys/kernel/printk 

so that you get all types of messages to go to the console.

Secondly, do you have your debugfs mounted properly ? I would do a mount | grep 'debugfs' to check.

I am not even a newbie in linux kernel programming but hope this helps you somehow :)

link

answered 05 May '10, 20:05

Knight%20Samar's gravatar image

Knight Samar
885
accept rate: 33%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×10
×2
×1
×1

Asked: 05 May '10, 00:03

Seen: 3,367 times

Last updated: 20 Apr '11, 13:55

powered by OSQA