Subject: Re: _open problem using O_EXCL flag and -mno-cygwin
From: "Larry Hall (RFK Partners, Inc)" <[email-masked]>
To: [email-masked], <[email-masked]>
Cc: "david" <[email-masked]>
Date: Fri, 15 Dec 2000 10:59:00 -0500

Since this sounds like a question about how the Mingw version (-mno-cygwin)
of the compiler works, you should probably direct the question to that list
([email-masked]).

Good luck,

Larry Hall                              [email-masked]
RFK Partners, Inc.                      http://www.rfk.com
118 Washington Street                   (508) 893-9779 - RFK Office
Holliston, MA 01746                     (508) 893-9889 - FAX

At 04:16 AM 12/15/2000, David Ponce wrote:
>Hello,
>
>I am a NT Emacs 21 pretester and I successfully compiled it (with
>-mno-cygwin) using the latest (great!) cygwin 1.1.6 (I tried the
>20001213 snapshot too).  Emacs works well except a problem using the
>O_EXCL flag with the _open function. With this flag _open always
>return -1 with errno=22.
>
>Following is a simple test program that isolates the problem:
>
>------------------------
>#include <io.h>
>#include <stdio.h>
>#include <errno.h>
>#include <sys/stat.h>
>#include <fcntl.h>
>
>int fdesc;
>
>int main(void)
>{
>
>   fprintf(stderr, "O_BINARY=%i, _O_BINARY=%i\n", O_BINARY, _O_BINARY);
>
>   fprintf(stderr, "O_WRONLY=%i, _O_WRONLY=%i\n", O_WRONLY, _O_WRONLY);
>   fprintf(stderr, "O_CREAT=%i, _O_CREAT=%i\n",  O_CREAT, _O_CREAT);
>   fprintf(stderr, "O_EXCL=%i, _O_EXCL=%i\n",   O_EXCL, _O_EXCL);
>   fprintf(stderr, "O_TRUNC=%i, _O_TRUNC=%i\n",  O_TRUNC, _O_TRUNC);
>   fprintf(stderr, "O_NOINHERIT=%i, _O_NOINHERIT=%i\n",
>           O_NOINHERIT, _O_NOINHERIT);
>   fprintf(stderr, "S_IREAD=%i, _S_IREAD=%i\n",  S_IREAD, _S_IREAD);
>   fprintf(stderr, "S_IWRITE=%i, _S_IWRITE=%i\n", S_IWRITE, _S_IWRITE);
>
>   errno = 0;
>   fdesc = _open("testopen.tmp1",
>    O_BINARY | O_WRONLY | O_CREAT | O_TRUNC | O_EXCL | _O_NOINHERIT,
>    S_IREAD | S_IWRITE);
>   fprintf(stderr, "fdesc=%i\n", fdesc);
>   fprintf(stderr, "errno=%i\n", errno);
>
>   errno = 0;
>   fdesc = _open("testopen.tmp2",
>    O_BINARY | O_WRONLY | O_CREAT | O_TRUNC | _O_NOINHERIT,
>    S_IREAD | S_IWRITE);
>   fprintf(stderr, "fdesc=%i\n", fdesc);
>   fprintf(stderr, "errno=%i\n", errno);
>
>}
>------------------------
>
>And the transcription of the test case (the testopen.tmp files does not
>initially exist)
>
>------------------------
>C:\cygwin\tmp>gcc -mno-cygwin testopen.c
>
>C:\cygwin\tmp>a.exe
>O_BINARY=32768, _O_BINARY=32768
>O_WRONLY=1, _O_WRONLY=1
>O_CREAT=256, _O_CREAT=256
>O_EXCL=1024, _O_EXCL=1024
>O_TRUNC=512, _O_TRUNC=512
>O_NOINHERIT=128, _O_NOINHERIT=128
>S_IREAD=256,  _S_IREAD=256
>S_IWRITE=128,  _S_IWRITE=128
>fdesc=-1
>errno=22
>fdesc=3
>errno=0
>
>C:\cygwin\tmp>del testopen.tmp*
>
>C:\cygwin\tmp>gcc testopen.c
>
>C:\cygwin\tmp>a.exe
>O_BINARY=65536, _O_BINARY=65536
>O_WRONLY=1, _O_WRONLY=1
>O_CREAT=512, _O_CREAT=512
>O_EXCL=2048, _O_EXCL=2048
>O_TRUNC=1024, _O_TRUNC=1024
>O_NOINHERIT=262144, _O_NOINHERIT=262144
>S_IREAD=256,  _S_IREAD=256
>S_IWRITE=128,  _S_IWRITE=128
>fdesc=3
>errno=0
>fdesc=4
>errno=0
>------------------------
>
>When I compile the same program without -mno-cygwin it works well.
>
>So is the O_EXCL flag supported by the mingw version of _open. Or is
>it a bug?
>
>Thank you so much for any help.
>
>Sincerely,
>David
>
>--
>Want to unsubscribe from this list?
>Send a message to [email-masked]

--
Want to unsubscribe from this list?
Send a message to [email-masked]