From 974362ef6446c5ef044a29a5ce0bc2502fd9bea1 Mon Sep 17 00:00:00 2001 From: David Cook Date: Sun, 26 Jan 2020 14:13:22 -0600 Subject: [PATCH] Handle differing sizes of mode_t mode_t is a u32 on Linux and a u16 on macOS --- src/shims/fs.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/shims/fs.rs b/src/shims/fs.rs index a5acafdaaaf..bedffe4b8ed 100644 --- a/src/shims/fs.rs +++ b/src/shims/fs.rs @@ -775,7 +775,10 @@ fn mkdir( this.check_no_isolation("mkdir")?; + #[cfg(target_os = "linux")] let mode = this.read_scalar(mode_op)?.to_u32()?; + #[cfg(not(target_os = "linux"))] + let mode = this.read_scalar(mode_op)?.not_undef()?.to_u16()?; let path = this.read_os_str_from_c_str(this.read_scalar(path_op)?.not_undef()?)?; @@ -783,8 +786,10 @@ fn mkdir( #[cfg(target_family = "unix")] { use std::os::unix::fs::DirBuilderExt; - builder.mode(mode); + builder.mode(mode.into()); } + #[cfg(not(target_family = "unix"))] + let _mode = mode; let result = builder.create(path).map(|_| 0i32); this.try_unwrap_io_result(result) -- 2.44.0