mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <>
To: Florian Weimer <>
Cc: "Buchholz, Robert" <>,
	"" <>
Subject: Re: [musl] Bug: ftell() after fopen(..., "ab") returns 0 unless an explicit fseek() is used first
Date: Wed, 17 Aug 2022 20:31:10 -0400	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On Thu, Aug 11, 2022 at 01:36:33PM +0200, Florian Weimer wrote:
> * Robert Buchholz:
> > On my Alpine/MUSL setup this prints "0 6" while on Ubuntu 22.04 with
> > glibc it prints "3 6" - which I'm assuming is the expected output.
> Both behaviors are acceptable.  C11 (7.21.3p1) says this:
> | If a file can support positioning requests (such as a disk file, as
> | opposed to a terminal), then a file position indicator associated with
> | the stream is positioned at the start (character number zero) of the
> | file, unless the file is opened with append mode in which case it is
> | implementation-defined whether the file position indicator is initially
> | positioned at the beginning or the end of the file.
> musl is likely not the only libc with this type of behavior, given that
> it's explicitly allowed by the standard.

Indeed. We simply match the underlying fd behavior here because it's
the "default" behavior without incurring extra cost. Since
applications can't assume one behavior or the other, ones that care to
have the position start at the end have to do the fseeko to SEEK_END


      reply	other threads:[~2022-08-18  0:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-11 11:14 Buchholz, Robert
2022-08-11 11:36 ` Florian Weimer
2022-08-18  0:31   ` Rich Felker [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).