Re: seq_file and exporting dynamically allocated data

From: viro
Date: Mon Nov 17 2003 - 04:56:14 EST


On Mon, Nov 17, 2003 at 09:42:09AM +0000, Tigran Aivazian wrote:
> Here are two files: simple.c kernel module and user.c user test program.
> If you (or anyone) believe it is possible to return more than a single
> page on a read(2) please change them accordingly and let me know.

> while (1) {
> len = read(fd, procs, MAXPROCS*PROCLEN);
> nproc = len/PROCLEN;

Broken userland code. You expect read() to return a multiple of PROCLEN,
for one thing. For another, you have (several lines below) a broken
loop termination logics.

EOF had been reached when read() returns 0. Until then read() returns
an arbitrary amount of bytes between 1 and 'size' argument. Since you
are using read(2) directly, use it correctly...
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/