Mail Archives: djgpp/2009/03/26/02:45:41
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f
|
X-Recipient: | djgpp AT delorie DOT com
|
Date: | Thu, 26 Mar 2009 08:18:41 +0100
|
From: | "Juan Manuel Guerrero" <juan DOT guerrero AT gmx DOT de>
|
Message-ID: | <20090326071841.73950@gmx.net>
|
MIME-Version: | 1.0
|
Subject: | Dificulty using open() with O_EXCL on Windows 2000
|
To: | djgpp AT delorie DOT com
|
X-Authenticated: | #27081556
|
X-Flags: | 0001
|
X-Mailer: | WWW-Mail 6100 (Global Message Exchange)
|
X-Priority: | 3
|
X-Provags-ID: | V01U2FsdGVkX1/Cb4gqJPnCK/feZGopqgv9ZULoi8qGJLwzHU0Xgb
|
| X8mCufeQolOybNcSV92rxI9GqzAVKnq8ljOg==
|
X-GMX-UID: | YxXzfN9vbmwoViZJ9TZLzfJPUzc4chFx
|
X-FuHaFi: | 0.49
|
While I was porting Perl 5.8.9 I have noticed that the port is not able
to create temporary files on Win2K. On MSDOS 6.0 and WinXP everything
works fine.
This issue has already been reported some time ago by a user. See
<http://www.delorie.com/archives/browse.cgi?p=djgpp/2008/04/17/02:16:35>
Perl calls open() from libc with the O_EXCL mode among others and this makes it fail. The same mode seems to work on WinXP and MSDOS.
Please note that the file to be created certainly does not exist so
there should be no reason to fail.
The following code snippet allows to reproduce the difficulty:
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <dos.h>
#include <errno.h>
int main(void)
{
char path[] = "c:/tmp/foobar.txt";
int fd, mode, permissions;
unsigned short os_trueversion = _get_dos_version(1);
printf("os_major=%d os_minor=%d os_trueversion=0x%x os_flavor=%s\n", _osmajor, _osminor, os_trueversion, _os_flavor);
errno = 0;
mode = O_NOFOLLOW|O_EXCL|O_CREAT|O_NOINHERIT|O_BINARY|O_RDWR;
permissions = S_IWUSR|S_IRUSR;
fd = open(path, mode, permissions);
printf("path=%s mode=0x%x permissions=0%o fd=%i errno=%i\n", path, mode, permissions, fd, errno);
return 0;
}
On WinXP it produces the following output:
os_major=5 os_minor=0 os_trueversion=0x532 os_flavor=MS-DOS
path=c:/tmp/foobar.txt mode=0x8386 permissions=0600 fd=6 errno=22
and on Win2K the following one:
os_major=5 os_minor=0 os_trueversion=0x532 os_flavor=MS-DOS
path=c:/tmp/foobar.txt mode=0x8386 permissions=0600 fd=-1 errno=22
and on MSDOS 6.2 the following one:
os_major=6 os_minor=20 os_trueversion=0x614 os_flavor=MS-DOS
path=c:/tmp/foobar.txt mode=0x8386 permissions=0600 fd=5 errno=22
The mode and permissions are the ones used by the perl function that
tries to create the temporary file.
Is this behaviour to be expected or am I missing something?
If this is a bug it will appears everytime O_EXCL is used on Win2K.
Is there a way to certainly detect Win2K at runtime? If there is no
way to identify Win2K, then O_EXCL must be removed from the mode list.
Regards,
Juan M. Guerrero
--
Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger01
- Raw text -