Re: unwanted double reads in /proc routines



Bernhard Holzmayer wrote:
Hi all,

can anyone please help me to shed some light onto this strange behavior.
Here are the facts:
device driver (kernel 2.6.8) using /proc entries to communicate.
This is the offending procedure:

static int pss__read_enable(char *buf, char **start, off_t offset, int len,
int *eof, void * unused)
{
char * dest = buf;
*eof = 1;
*dest++ = (enable==off) ? '0':'1';
*dest ='\0';
printk( KERN_DEBUG "here we are\n");
return 2;
}

So there is nothing special, it should just respond with a result like "1".

Now, I see the printk() message twice (!!) for every read which I issue like
"cat /proc/.../state"
The response is ok.

If I leave out the line *eof=1; there are even three (!) lines from printk.

Who does understand this?


Did you trace to see how many read() calls cat is doing?

--

Tauno Voipio
tauno voipio (at) iki fi
.



Relevant Pages

  • unwanted double reads in /proc routines
    ... device driver (kernel 2.6.8) using /proc entries to communicate. ... I see the printk() message twice for every read which I issue like ...
    (comp.os.linux.development.system)
  • printk messges in log file
    ... Upon inspecting /var/log/messages I am getting masses of entries such as ... kernel: printk: 58 messages suppressed. ... can I dissable the message suppression to see what the messages are? ...
    (Ubuntu)
  • [RFC] New kernel-message logging API
    ... Backwards compatibility with printk(), syslog, etc. ... way the whole kernel can be converted to a new interface in one go. ... const char *format; ...
    (Linux-Kernel)
  • Re: Documentation of kernel messages (Summary)
    ... suggested solutions for documentation / translation of kernel messages ... the messages should _be_ documentation. ... Use printk format string as message identifier ...
    (Linux-Kernel)
  • Re: noisy edac
    ... > into the kernel. ... > offer the user two options: either printk() or be silent. ... looking in the logs it allows all of the errors to be detected and harvested. ...
    (Linux-Kernel)