Merge pull request #1896 from mrmiywj/add_umask_support

Add umask support
This commit is contained in:
Jeong YunWon
2020-05-03 23:10:24 +09:00
committed by GitHub

View File

@@ -1302,6 +1302,18 @@ fn os_urandom(size: usize, vm: &VirtualMachine) -> PyResult<Vec<u8>> {
}
}
#[cfg(target_os = "linux")]
type ModeT = u32;
#[cfg(target_os = "macos")]
type ModeT = u16;
#[cfg(any(target_os = "macos", target_os = "linux"))]
fn os_umask(mask: ModeT, _vm: &VirtualMachine) -> PyResult<ModeT> {
let ret_mask = unsafe { libc::umask(mask) };
Ok(ret_mask)
}
#[pystruct_sequence(name = "os.uname_result")]
#[derive(Debug)]
#[cfg(unix)]
@@ -1510,6 +1522,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);