linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: cranium2003 <cranium2003@yahoo.com>
To: kernel newbies <kernelnewbies@nl.linux.org>,
	kernerl mail <linux-kernel@vger.kernel.org>
Subject: strace on cat /proc/my_file gives results by calling read twice why?
Date: Fri, 4 Mar 2005 23:04:21 -0800 (PST)	[thread overview]
Message-ID: <20050305070421.12802.qmail@web41401.mail.yahoo.com> (raw)



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/

             reply	other threads:[~2005-03-05  7:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-03-05  7:04 cranium2003 [this message]
     [not found] <no.id>
2005-03-05  7:43 ` strace on cat /proc/my_file gives results by calling read twice why? Alan Curry

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050305070421.12802.qmail@web41401.mail.yahoo.com \
    --to=cranium2003@yahoo.com \
    --cc=kernelnewbies@nl.linux.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).