]> git.lizzy.rs Git - rust.git/commitdiff
Handle differing sizes of mode_t
authorDavid Cook <divergentdave@gmail.com>
Sun, 26 Jan 2020 20:13:22 +0000 (14:13 -0600)
committerDavid Cook <divergentdave@gmail.com>
Sun, 23 Feb 2020 21:08:44 +0000 (15:08 -0600)
mode_t is a u32 on Linux and a u16 on macOS

src/shims/fs.rs

index a5acafdaaaf04a054136f4af9a2a63796b62c629..bedffe4b8ed13cbf1ad463db37e491546c8716e0 100644 (file)
@@ -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)