Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com Message-ID: <779F20BCCE5AD31186A50008C75D9979171704@SILLDN_MAIL1> From: "Fifer, Eric" To: "'Corinna Vinschen'" Cc: "'cygwin-developers AT sourceware DOT cygnus DOT com'" Subject: RE: Problem with open() and O_CREAT Date: Fri, 17 Mar 2000 14:21:41 -0000 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2448.0) Content-Type: text/plain; charset="iso-8859-1" "Corinna Vinschen" wrote: >[...] >your patch looks ok to me. Thank you! >[...] >But I wonder if we couldn't do without the request for the state >of `creation_distribution'. Shouldn't this be enough when asking >for GetLastError() == ERROR_ALREADY_EXISTS? I think so, because >O_CREAT implies CREATE_ALWAYS or OPEN_ALWAYS if O_EXCL isn't >used whereas O_EXCL results in a different behaviour, either. I agree. Although, I had to carefully reread MSDN and stare at the code. As you point out O_CREAT and O_EXCL result in CREATE_NEW and in this case if the file already exists, the CreateFile() will fail (instead of succeeding and setting ERROR_ALREADY_EXISTS as it does with CREATE_ALWAYS or OPEN_ALWAYS). Anyway, the simplified patch now becomes: diff -rup winsup.orig/cygwin/fhandler.cc winsup/cygwin/fhandler.cc --- winsup.orig/cygwin/fhandler.cc Fri Mar 17 04:55:11 2000 +++ winsup/cygwin/fhandler.cc Fri Mar 17 13:41:07 2000 @@ -340,7 +340,8 @@ fhandler_base::open (int flags, mode_t m goto done; } - if (flags & O_CREAT && get_device () == FH_DISK) + if (flags & O_CREAT && get_device () == FH_DISK && + GetLastError () != ERROR_ALREADY_EXISTS) set_file_attribute (has_acls (), get_win32_name (), mode); namehash_ = hash_path_name (0, get_win32_name ()); Thanks. Eric