3333 * inheritable on Windows, so specify the flag to get default behavior back. */
3434#define STANDARD_OPEN_FLAGS (_O_BINARY | _O_NOINHERIT)
3535
36+ /* Allowable mode bits on Win32. Using mode bits that are not supported on
37+ * Win32 (eg S_IRWXU) is generally ignored, but Wine warns loudly about it
38+ * so we simply remove them.
39+ */
40+ #define WIN32_MODE_MASK (_S_IREAD | _S_IWRITE)
41+
3642/* GetFinalPathNameByHandleW signature */
3743typedef DWORD (WINAPI * PFGetFinalPathNameByHandleW )(HANDLE , LPWSTR , DWORD , DWORD );
3844
@@ -343,7 +349,7 @@ int p_open(const char *path, int flags, ...)
343349 va_end (arg_list );
344350 }
345351
346- return _wopen (buf , flags | STANDARD_OPEN_FLAGS , mode );
352+ return _wopen (buf , flags | STANDARD_OPEN_FLAGS , mode & WIN32_MODE_MASK );
347353}
348354
349355int p_creat (const char * path , mode_t mode )
@@ -353,7 +359,9 @@ int p_creat(const char *path, mode_t mode)
353359 if (git_win32_path_from_utf8 (buf , path ) < 0 )
354360 return -1 ;
355361
356- return _wopen (buf , _O_WRONLY | _O_CREAT | _O_TRUNC | STANDARD_OPEN_FLAGS , mode );
362+ return _wopen (buf ,
363+ _O_WRONLY | _O_CREAT | _O_TRUNC | STANDARD_OPEN_FLAGS ,
364+ mode & WIN32_MODE_MASK );
357365}
358366
359367int p_getcwd (char * buffer_out , size_t size )
@@ -607,7 +615,7 @@ int p_access(const char* path, mode_t mode)
607615 if (git_win32_path_from_utf8 (buf , path ) < 0 )
608616 return -1 ;
609617
610- return _waccess (buf , mode );
618+ return _waccess (buf , mode & WIN32_MODE_MASK );
611619}
612620
613621static int ensure_writable (wchar_t * fpath )
0 commit comments