Subject: Re: HSM implementation proposal
To: Jim Wise <jimw@numenor.turner.com>
From: Greg Hudson <ghudson@mit.edu>
List: tech-kern
Date: 12/08/1997 14:33:41
> Read has _never_ been guaranteed to return exactly the requested
> number of bytes -- if it were, what would happen if you requested
> more bytes than remained in the file?

I quoth from read(2):

     Upon successful completion, read() and readv() return the number of bytes
     actually read and placed in the buffer.  The system guarantees to read
     the number of bytes requested if the descriptor references a normal file
     that has that many bytes left before the end-of-file, but in no other
     case.

It's not at all uncommon to rely on that assumption.  A lot of
programs fstat() a file and then read in st_size bytes with no
surrounding while loop.

(That doesn't mean I like the guarantee, though.  In my opinion,
"normal" files should look more like sockets.  But it's probably too
late to fix.)