summaryrefslogtreecommitdiff
path: root/src/w32.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2013-12-30 19:51:28 +0200
committerEli Zaretskii <eliz@gnu.org>2013-12-30 19:51:28 +0200
commit1b7259fce2719182e2b557682e40d02807784d1f (patch)
treecd1def24ee0db4b44e5261af4731f0ecea187d14 /src/w32.c
parent634425957a55b272b0e06a617c725766e1ae0ee9 (diff)
downloademacs-1b7259fce2719182e2b557682e40d02807784d1f.tar.gz
Fix bug #16299 with assertion violation in set-default-file-modes on Windows.
src/w32.c (sys_umask): New function. nt/inc/ms-w32.h (umask) [emacs]: Redirect to sys_umask.
Diffstat (limited to 'src/w32.c')
-rw-r--r--src/w32.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/w32.c b/src/w32.c
index dde74bfcdd9..3fdb673b63f 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -5265,6 +5265,35 @@ utime (const char *name, struct utimbuf *times)
return 0;
}
+/* Emacs expects us to support the traditional octal form of the mode
+ bits, which is not what msvcrt.dll wants. */
+
+#define WRITE_USER 00200
+
+int
+sys_umask (int mode)
+{
+ static int current_mask;
+ int retval, arg = 0;
+
+ /* The only bit we really support is the write bit. Files are
+ always readable on MS-Windows, and the execute bit does not exist
+ at all. */
+ /* FIXME: if the GROUP and OTHER bits are reset, we should use ACLs
+ to prevent access by other users on NTFS. */
+ if ((mode & WRITE_USER) != 0)
+ arg |= S_IWRITE;
+
+ retval = _umask (arg);
+ /* Merge into the return value the bits they've set the last time,
+ which msvcrt.dll ignores and never returns. Emacs insists on its
+ notion of mask being identical to what we return. */
+ retval |= (current_mask & ~WRITE_USER);
+ current_mask = mode;
+
+ return retval;
+}
+
/* Symlink-related functions. */
#ifndef SYMBOLIC_LINK_FLAG_DIRECTORY