From 252dd88138103396219da5092f1cdb017df0450c Mon Sep 17 00:00:00 2001 From: Pierre Humblet Date: Sat, 14 Aug 2004 03:01:21 +0000 Subject: [PATCH] 2004-08-14 Pierre Humblet * fhandler.cc (fhandler_base::open_9x): Set file attributes for new files. --- winsup/cygwin/ChangeLog | 5 +++++ winsup/cygwin/fhandler.cc | 11 ++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 7bb900928..9f9881b0b 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2004-08-14 Pierre Humblet + + * fhandler.cc (fhandler_base::open_9x): Set file attributes + for new files. + 2004-08-11 Christopher Faylor * net.cc (cygwin_gethostbyname): Show failing host name on error. diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index 57a3c4712..5c5095f59 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -480,9 +480,14 @@ fhandler_base::open_9x (int flags, mode_t mode) } #endif - /* If mode has no write bits set, we set the R/O attribute. */ - if (!(mode & (S_IWUSR | S_IWGRP | S_IWOTH))) - file_attributes |= FILE_ATTRIBUTE_READONLY; + if (flags & O_CREAT && get_device () == FH_FS) + { + /* If mode has no write bits set, we set the R/O attribute. */ + if (!(mode & (S_IWUSR | S_IWGRP | S_IWOTH))) + file_attributes |= FILE_ATTRIBUTE_READONLY; + /* The file attributes are needed for later use in, e.g. fchmod. */ + pc.file_attributes (file_attributes & FILE_ATTRIBUTE_VALID_SET_FLAGS); + } x = CreateFile (get_win32_name (), access, shared, &sa, creation_distribution, file_attributes, 0); -- 2.43.5