]> git.lizzy.rs Git - rust.git/blobdiff - src/shims/foreign_items.rs
add `statx` shim for linux
[rust.git] / src / shims / foreign_items.rs
index 316cc686ad77d301e7dd751fdbddef88f4bbc185..3989f7f48a0b931e0fa1451024a279eb3ff34032 100644 (file)
@@ -303,14 +303,25 @@ fn emulate_foreign_item(
                     .expect("Failed to get libc::SYS_getrandom")
                     .to_machine_usize(this)?;
 
-                // `libc::syscall(NR_GETRANDOM, buf.as_mut_ptr(), buf.len(), GRND_NONBLOCK)`
-                // is called if a `HashMap` is created the regular way (e.g. HashMap<K, V>).
+                let sys_statx = this
+                    .eval_path_scalar(&["libc", "SYS_statx"])?
+                    .expect("Failed to get libc::SYS_statx")
+                    .to_machine_usize(this)?;
+
                 match this.read_scalar(args[0])?.to_machine_usize(this)? {
+                    // `libc::syscall(NR_GETRANDOM, buf.as_mut_ptr(), buf.len(), GRND_NONBLOCK)`
+                    // is called if a `HashMap` is created the regular way (e.g. HashMap<K, V>).
                     id if id == sys_getrandom => {
                         // The first argument is the syscall id,
                         // so skip over it.
                         linux_getrandom(this, &args[1..], dest)?;
                     }
+                    id if id == sys_statx => {
+                        // The first argument is the syscall id,
+                        // so skip over it.
+                        let result = this.statx(args[1], args[2], args[3], args[4], args[5])?;
+                        this.write_scalar(Scalar::from_int(result, dest.layout.size), dest)?;
+                    }
                     id => throw_unsup_format!("miri does not support syscall ID {}", id),
                 }
             }