delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/03/08/09:12:25

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <422DB283.70802@byu.net>
Date: Tue, 08 Mar 2005 07:11:15 -0700
From: Eric Blake <ebb9 AT byu DOT net>
User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: apparent bug: incorrect file position after write()
References: <200503060140 DOT j261et0N007162 AT montauk DOT byu DOT edu>
In-Reply-To: <200503060140.j261et0N007162@montauk.byu.edu>
X-IsSubscribed: yes

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Gary R. Van Sickle on 3/5/2005 6:39 PM:
> O_BINARY is POSIX.  Use it.  Do this if you have to:
> 
Where do you see that?
http://www.opengroup.org/onlinepubs/009695399/basedefs/fcntl.h.html lists
O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, O_APPEND, O_DSYNC, O_NONBLOCK,
O_RSYNC, O_SYNC, O_RDONLY, O_RDWR, and O_WRONLY; but POSIX does not define
O_BINARY or O_TEXT.


> #ifndef O_BINARY
> #define O_BINARY 0
> 
However, in spite of O_BINARY not being POSIX, this is a good workaround -
coreutils uses the same trick.

If you use the C standard I/O functions instead, POSIX does require the
existance of the "b" flag with no effect (but does not mention a "t"
flag).  On a Unix system with no text mounts, fopen("foo", "wb") and
fopen("foo", "w") are therefore identical.  In cygwin, "w" uses the
underlying mount for the mode, "wb" always opens in binary mode, and "wt"
always opens in text mode.  Therefore, for fopen, cygwin is POSIX
compliant (that is, using the 'b' flag has no change from omitting it)
only if you use binary mount points (yet another reason that text mode
mounts are not all that useful).

- --
Life is short - so eat dessert first!

Eric Blake             ebb9 AT byu DOT net

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCLbKD84KuGfSFAYARAszlAJ0aBEnqtu6eX4s+fk4JOIlkj/ug2gCfcDAx
KVlPiTA86Ae9ELXatWwumKI=
=Cw9z
-----END PGP SIGNATURE-----

--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019