Re: O_NONBLOCK on files

Eric W. Biederman (ebiederm@xmission.com)
19 Sep 2001 01:05:06 -0600


Simon Kirby <sim@netnation.com> writes:

> I've always wondered why it's not possible to do this:
>
> fd = open("an_actual_file",O_RDONLY);
> fcntl(fd,F_SETFL,O_NONBLOCK);
> r = read(fd,buf,4096);
>
> And actually have read return -1 and errno == EWOULDBLOCK/EAGAIN if the
> block requested is not already cached.
>
> Wouldn't this be the ideal interface for daemons of all types that want
> to stay single-threaded and still offer useful performance when the
> working set doesn't fit in cache? It works with sockets, so why not
> with files?

Besides the SUS or the POSIX specs...
What would cause the data to be read in if read just checks the caches?
With sockets the other side is clearing pushing or pulling the data. With
files there is no other side...

This is resolveable just not currently implemented.

Eric

-
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/