lkml.org 
[lkml]   [2005]   [Mar]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
Subjectstrace on cat /proc/my_file gives results by calling read twice why?


hello,
I have a /proc file kernel module with its proc
read function as
static char mybuf[1024];
ssize_t my_file_read(struct file *filp, char *buf,
size_t count, loff_t *ppos)
{
printk("Reading a from a /proc file....\n");
static int b_read = 0;

int len = strlen(mybuf);

if (len == 0 || b_read) {
b_read = 0;
return 0;
}

if (len > count - 1)
len = count - 1;

copy_to_user(buf, mybuf, len);
put_user(0, &buf[len]);
++len;
b_read = 1;
return len;
}

when i strace cat /proc/my_file i found message
printing twice
Reading a from a /proc file....
Reading a from a /proc file....
Why that happening?
Also i check by writing to it as cat >
/proc/my_file
and got single result for write function call not
twice as for read.

regards,
cranium




__________________________________
Celebrate Yahoo!'s 10th Birthday!
Yahoo! Netrospective: 100 Moments of the Web
http://birthday.yahoo.com/netrospective/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:10    [W:0.178 / U:0.024 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site