diff --git a/src/shims/fs.rs b/src/shims/fs.rs index 15f5237e0b57..6dcdf5717c01 100644 --- a/src/shims/fs.rs +++ b/src/shims/fs.rs @@ -785,7 +785,7 @@ fn mkdir( this.check_no_isolation("mkdir")?; - let mode = if this.tcx.sess.target.target.target_os.to_lowercase() == "macos" { + let _mode = if this.tcx.sess.target.target.target_os.to_lowercase() == "macos" { this.read_scalar(mode_op)?.not_undef()?.to_u16()? as u32 } else { this.read_scalar(mode_op)?.to_u32()? @@ -794,13 +794,15 @@ fn mkdir( let path = this.read_os_str_from_c_str(this.read_scalar(path_op)?.not_undef()?)?; let mut builder = DirBuilder::new(); + + // If the host supports it, forward on the mode of the directory + // (i.e. permission bits and the sticky bit) #[cfg(target_family = "unix")] { use std::os::unix::fs::DirBuilderExt; - builder.mode(mode.into()); + 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) @@ -842,7 +844,7 @@ fn opendir(&mut self, name_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, Scalar