Reading device info from inside proc module

6 views
Skip to first unread message

Izzet Vural

unread,
Dec 13, 2013, 6:32:52 AM12/13/13
to gnulinu...@googlegroups.com
I want to read graphic card info in proc module.I created a proc module and loaded it to kernel.What I want is to show graphic card info when I call the proc from terminal. Such as " cat /proc/myprocname" I know that my code is wrong below.But it will help you to understand what I want.
#include <linux/init.h>        
#include <linux/module.h>  
#include <linux/proc_fs.h>       // proc filesystem

/* 
read proc function
*/
int read_proc(char *buf, char **start, off_t offset,
int count, int *eof, void *data){

   // !! **that's it.I want to read graphic card info in this function.**
   // !! this is wrong.but I want to do like this

   FILE *fd = popen("lspci | grep VGA", "r");
char buffer[16];
if (fread (buffer, 1, sizeof (buffer), fd) > 0) // if there is some result the     module must be loaded
printk (KERN_INFO buffer);
else
printf ("module is not loaded\n");
return 1;
}
/*
Module loading...
*/

static int baslat(void){

//  Registering..

create_proc_read_entry( "proc01",  // file name
              0,           //  (protection mode): default 
              NULL,        //  (parent dir): none
              read_proc,   // callback
              NULL);       //
 return 0;
}
/*
Module removing..
*  /

static void bitir(void){
// module register removing..
remove_proc_entry( "proc01",   // file name 
             NULL);        // (parent directory)
}
module_init(baslat);
module_exit(bitir);





Reply all
Reply to author
Forward
0 new messages