diff --git a/vm/src/stdlib/os.rs b/vm/src/stdlib/os.rs index 3c6f97cd9..0d43138a8 100644 --- a/vm/src/stdlib/os.rs +++ b/vm/src/stdlib/os.rs @@ -1280,6 +1280,18 @@ fn os_urandom(size: usize, vm: &VirtualMachine) -> PyResult> { } } +#[cfg(target_os = "linux")] +type MODE_t = u32; + +#[cfg(target_os = "macos")] +type MODE_t = u16; + +#[cfg(any(target_os = "macos", target_os = "linux"))] +fn os_umask(mask: MODE_t, _vm: &VirtualMachine) -> PyResult { + let ret_mask = unsafe { libc::umask(mask) }; + Ok(ret_mask) +} + #[pystruct_sequence(name = "os.uname_result")] #[derive(Debug)] #[cfg(unix)] @@ -1488,6 +1500,7 @@ pub fn make_module(vm: &VirtualMachine) -> PyObjectRef { SupportFunc::new(vm, "chmod", os_chmod, Some(false), Some(false), Some(false)), #[cfg(not(target_os = "redox"))] SupportFunc::new(vm, "chroot", os_chroot, Some(false), None, None), + SupportFunc::new(vm, "umask", os_umask, Some(false), Some(false), Some(false)), ]); let supports_fd = PySet::default().into_ref(vm); let supports_dir_fd = PySet::default().into_ref(vm);