This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: apparent bug: incorrect file position after write()


-----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@byu.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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]