shadow_rs/host/syscall/handler/
stat.rs1use shadow_shim_helper_rs::syscall_types::ForeignPtr;
2
3use crate::cshadow;
4use crate::host::syscall::handler::{SyscallContext, SyscallHandler};
5use crate::host::syscall::type_formatting::SyscallStringArg;
6use crate::host::syscall::types::{SyscallError, SyscallResult};
7
8impl SyscallHandler {
9 log_syscall!(
10 statx,
11 std::ffi::c_int,
12 std::ffi::c_int,
13 SyscallStringArg,
14 std::ffi::c_int,
15 *const std::ffi::c_void,
16 );
17 pub fn statx(ctx: &mut SyscallContext) -> SyscallResult {
18 Self::legacy_syscall(cshadow::syscallhandler_statx, ctx)
19 }
20
21 log_syscall!(
22 fstat,
23 std::ffi::c_int,
24 std::ffi::c_uint,
25 *const linux_api::stat::stat,
26 );
27 pub fn fstat(
28 ctx: &mut SyscallContext,
29 fd: std::ffi::c_uint,
30 statbuf_ptr: ForeignPtr<linux_api::stat::stat>,
31 ) -> Result<(), SyscallError> {
32 let desc_table = ctx.objs.thread.descriptor_table_borrow(ctx.objs.host);
33 let file = Self::get_descriptor(&desc_table, fd)?.file();
34 let stat = file.stat()?;
35
36 ctx.objs
37 .process
38 .memory_borrow_mut()
39 .write(statbuf_ptr, &stat)?;
40
41 Ok(())
42 }
43
44 log_syscall!(fstatfs, std::ffi::c_int);
45 pub fn fstatfs(ctx: &mut SyscallContext) -> SyscallResult {
46 Self::legacy_syscall(cshadow::syscallhandler_fstatfs, ctx)
47 }
48
49 log_syscall!(
50 newfstatat,
51 std::ffi::c_int,
52 std::ffi::c_int,
53 SyscallStringArg,
54 *const linux_api::stat::stat,
55 std::ffi::c_int,
56 );
57 pub fn newfstatat(ctx: &mut SyscallContext) -> SyscallResult {
58 Self::legacy_syscall(cshadow::syscallhandler_newfstatat, ctx)
59 }
60}