Let's assume we opened a file using fopen()
and from the file-pointer received, fetch the file-descriptor using fileno()
. Then we do lots (>10^8) of random read()
s of relativly small chunks, between a size of 4Bytes to 10KBytes from this file:
Is it expected behaviour such a read()
might return less bytes then requested, without setting errno
, if the file-system is an
ext3
NFS
OCFS2
combination of 2 and 3 (
OCFS2
viaNFS
)
?
My readings gave me the conclusion it should not be possible for 1. (if the file has not O_NONBLOCK
set, if ever possible for ext3
to have it set) but for the other three (2., 3., 4.) I'm uncertain.
(Btw: Could I assume having O_NONBLOCK
not set to be the default in any case?)
This questions arose because I observed read()
s returning less bytes then requested without errno
set in case 4.
The problem to drill this down by testing is that such behaviour happens in <1/1000000000 cases ... - which is still too often :-}
Update: The average file size is between some TBytes and around 1GByte.