aboutsummaryrefslogtreecommitdiff
path: root/win32
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2019-01-07 07:54:40 +0000
committerRon Yorston <rmy@pobox.com>2019-01-07 07:54:40 +0000
commita85653040477ec4e8a722de3af5afd04ee66bd59 (patch)
tree22c36324fd4cf68764f0df846321bc5a12a611fb /win32
parent1fec4ebbdb930f6b8989be2e10c0f673803ac830 (diff)
downloadbusybox-w32-a85653040477ec4e8a722de3af5afd04ee66bd59.tar.gz
busybox-w32-a85653040477ec4e8a722de3af5afd04ee66bd59.tar.bz2
busybox-w32-a85653040477ec4e8a722de3af5afd04ee66bd59.zip
win32: implement umask(2)
umask() in the Microsoft C runtime takes different arguments to umask(2). Implement a fake umask(2) that remembers the mask and calls the Microsoft umask() with an appropriate value. Since the mask won't be inherited by children use an environment variable to pass any value set by the shell built-in umask.
Diffstat (limited to 'win32')
-rw-r--r--win32/mingw.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/win32/mingw.c b/win32/mingw.c
index 8d1da5199..c72a306ac 100644
--- a/win32/mingw.c
+++ b/win32/mingw.c
@@ -318,6 +318,20 @@ static inline int get_file_attr(const char *fname, WIN32_FILE_ATTRIBUTE_DATA *fd
318 } 318 }
319} 319}
320 320
321#undef umask
322mode_t mingw_umask(mode_t new_mode)
323{
324 static mode_t old_mode = DEFAULT_UMASK;
325 mode_t tmp_mode;
326
327 tmp_mode = old_mode;
328 old_mode = new_mode;
329
330 umask((new_mode & S_IWUSR) ? _S_IWRITE : 0);
331
332 return tmp_mode;
333}
334
321/* 335/*
322 * Examine a file's contents to determine if it can be executed. This 336 * Examine a file's contents to determine if it can be executed. This
323 * should be a last resort: in most cases it's much more efficient to 337 * should be a last resort: in most cases it's much more efficient to