Re: Linux kernel file offset pointer races

From: Amon Ott
Date: Sat Aug 07 2004 - 07:44:15 EST


On Freitag, 6. August 2004 14:56, Alan Cox wrote:
> On Mer, 2004-08-04 at 21:36, Pavel Kankovsky wrote:
> > IMHO, the proper fix is to serialize all operations modifying a shared
> > file pointer (file->f_pos): read(), readv(), write(), writev(),
> > lseek()/llseek(). As far as I can tell, this is required by POSIX:
>
> Not if you want to get any useful work done. No Unix does this. The
> situation with multiple parallel lseek/read/writes is somewhat undefined
> anyway since you don't know if the seek or the write occurred first in
> user space.

Would it not be useful to have per-process or per-thread offsets? Do
parallel processes really need to share the offset?

E.g., the struct file could (optionally) be copied on fork with
copy-on-write to avoid extra memory consumption.

Amon.
--
http://www.rsbac.org - GnuPG: 2048g/5DEAAA30 2002-10-22

Attachment: pgp00000.pgp
Description: signature