sys_read broken for various /proc files

Miguel de Icaza (miguel@nuclecu.unam.mx)
Mon, 11 Jan 1999 20:19:18 -0600


The Linux kernel when requested to read n bytes from a file from /proc
will ignore the request and stuff as many bytes as it feels like
stuffing.

I include a tests program:

#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>

static char buffer [8];

main ()
{
int fd;

printf ("Before: [%s]\n", buffer);

fd = open ("/proc/locks", O_RDONLY);
if (fd == -1){
printf ("Can not open /proc/locks");
exit (1);
}
read (fd, buffer, 1);
read (fd, buffer, 1);
read (fd, buffer, 1);
read (fd, buffer, 1);
read (fd, buffer, 1);
read (fd, buffer, 1);
read (fd, buffer, 1);

printf ("Read: [%s]\n", buffer);
}

miguel.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/