X-Spam-Check-By: sourceware.org To: cygwin AT cygwin DOT com From: Eric Blake Subject: Re: [Spam?]Re: problem concating (>>) to a large file Date: Tue, 29 May 2007 16:11:40 +0000 (UTC) Lines: 33 Message-ID: References: <001201c79ea3$4d82bce0$8500a8c0 AT RUSNAK> <4656D47E DOT 5050906 AT byu DOT net> <001201c79f49$b57b3c90$8500a8c0 AT RUSNAK> <46582F2B DOT 2000300 AT byu DOT net> <000001c7a1d8$c2178e40$8500a8c0 AT RUSNAK> <20070529155024 DOT GE6003 AT calimero DOT vinschen DOT de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit User-Agent: Loom/3.14 (http://gmane.org/) X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Corinna Vinschen cygwin.com> writes: > > > > assert (0 == lseek (open("existing", O_WRONLY | O_APPEND), 0, SEEK_CUR)); > > Can you give me a pointer? http://www.opengroup.org/onlinepubs/009695399/functions/open.html "The file offset used to mark the current position within the file shall be set to the beginning of the file." This is stated prior to any mention of O_APPEND, and O_APPEND does not change that statement. And for O_APPEND|O_RDWR, it is a necessity. Later, in http://www.opengroup.org/onlinepubs/009695399/functions/write.html: "If the O_APPEND flag of the file status flags is set, the file offset shall be set to the end of the file prior to each write and no intervening file modification operation shall occur between changing the file offset and the write operation." so: int fd = open("existing", O_WRONLY | O_APPEND); assert (0 == lseek (fd, 0, SEEK_CUR); if (write (fd, " ", 1) > 0) { assert (0 != lseek (fd, 0, SEEK_CUR)); assert (lseek (fd, 0, SEEK_CUR) == lseek (fd, 0, SEEK_END)); } -- Eric Blake -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/