Subject: Re: kernel stack traceback
To: Bill Studenmund <>
From: Andrew Brown <>
List: tech-kern
Date: 03/19/1999 16:35:20
>> >So the fmode is O_RDWR | O_NONBLOCK | O_APPEND | O_CREAT | O_TRUNC.
>> >Why do you have O_APPEND & O_TRUNC set? If you have O_TRUNC set, wouldn't
>> >all writes naturally append?
>> No.
>Why not? Obviously if you use pwrite, or throw a seek in there, they won't
>append. But if you open with O_TRUNC, isn't the current file position set
>to the front of the file? Thus writes w/o a seek start from the current
>possition, and update that possition. ??

if you have only one writer, then


is the same as:


but if you add more writers, it's not.  each write() will only update
that single writer's file pointer, not append the data.  likewise, if
you are alternately seeking and writing in an attempt to write to the
end of the file, you're in a race condition where you can get messed
up by someone else doing the same thing.

O_TRUNC is presumably there to empty the file.  O_APPEND is there to
make sure that all writes go to the end of the file, regardless of any
seek()s and read()s (it is opened O_RDRW) that have been done.

|-----< "CODE WARRIOR" >-----|             * "ah!  i see you have the internet (Andrew Brown)                that goes *ping*!"       * "information is power -- share the wealth."