On 6/20/07, Timo Sirainen <[EMAIL PROTECTED]> wrote:
On Wed, 2007-06-20 at 17:52 +0300, Timo Sirainen wrote: > Sometimes read() returns only 4096 bytes. I'm locking the file, so I > don't think this should ever happen, right?
man 2 read read() is always allowed to return less than you asked for. You need to go back and ask for the rest. That's why people wrap read() and write() in loops, and use those wrapped versions instead.
read() sometimes returns 4096 bytes but with the "1111" already included in the data.
Uhm, do you mean 'without the 1111'? 4096 with the 1111 sounds perfectly fine. (Though 4096 without the 1111 is also perfectly fine.)
Is there a way to avoid this without locking the file while reading? The "1111" tries to act as a kind of a lock.
I think you've misunderstood how read and write work. pread and pwrite are no different in this respect -- they just allow an atomic seek+read/write. Ray - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/