Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Linux - Kernel This forum is for all discussion relating to the Linux kernel.


  Search this Thread
Old 04-17-2009, 12:48 PM   #1
LQ Newbie
Registered: Jan 2008
Location: india
Distribution: Fedora
Posts: 17

Rep: Reputation: 0
read_proc help

i have written a module. it will create a proc entry, in that proc entry i have mapped the below read function like.


unsigned char init_status=0xff; // Declared Globally inside module

int st_read(char *buf,char **start,off_t offset,int count,int *eof,void *data)
printk(KERN_ALERT "Read Called \n");
if(offset > 0)
*eof = 1;
return 0;

return sprintf(buf,"%x\n",init_status);

now if i use cat to read the contents of that proc file then i m getting
Read Called
Read Called
Read Called

i want to read the init_status variable as ff only. but i dont know why the st_read function called thrice and printing ffffff.

I m confused please help me in this regards
Old 04-30-2009, 11:49 AM   #2
LQ Newbie
Registered: Apr 2009
Posts: 1

Rep: Reputation: 0
You need to set [*eof=1;] before returning (outside of the [offset > 0] case).


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 > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 01:53 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration