lkml.org 
[lkml]   [1999]   [Oct]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Behaviour of lseek and fseek with append mode.
On Fri, 22 Oct 1999, C Hanish Menon wrote:

>
> Hi everyone
>
> I am writing a application which requires to add new things to the end of a
> existing file. So I open the file in append mode. But once the file is opened
> in append mode when ever I write any data it always writes to the end of
> the file and not where the FILE_POINTER is positioned using LSEEK.
>
> Is this right shouldn't it be working like this i.e:
>
[SNIPPED]

man 2 open

O_APPEND
The file is opened in append mode. Initially, and
before each write, the file-pointer is positioned
at the end of the file, as if with lseek.

Things don't often mean what they seem to say. You can lseek for
various reads in a file opened for append. However, the explicit
definitition requires that any writes occur at the end of the file.

You need to open the file as O_RDWR if you want to do random read/writes.
As a feature, this allows you to make sparse files as well.

Cheers,
Dick Johnson

Penguin : Linux version 2.3.13 on an i686 machine (400.59 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:54    [W:0.817 / U:0.000 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site