shadow_rs/host/syscall/handler/
fileat.rs

1use linux_api::posix_types::kernel_mode_t;
2use shadow_shim_helper_rs::syscall_types::ForeignPtr;
3
4use crate::cshadow;
5use crate::host::syscall::handler::{SyscallContext, SyscallHandler};
6use crate::host::syscall::type_formatting::SyscallStringArg;
7use crate::host::syscall::types::SyscallResult;
8
9impl SyscallHandler {
10    log_syscall!(
11        openat,
12        /* rv */ std::ffi::c_int,
13        /* dirfd */ std::ffi::c_int,
14        /* pathname */ SyscallStringArg,
15        /* flags */ linux_api::fcntl::OFlag,
16        /* mode */ nix::sys::stat::Mode,
17    );
18    pub fn openat(
19        ctx: &mut SyscallContext,
20        _dir_fd: std::ffi::c_int,
21        _path: ForeignPtr<()>,
22        _flags: std::ffi::c_int,
23        _mode: kernel_mode_t,
24    ) -> SyscallResult {
25        Self::legacy_syscall(cshadow::syscallhandler_openat, ctx)
26    }
27
28    log_syscall!(
29        faccessat,
30        /* rv */ std::ffi::c_int,
31        /* dfd */ std::ffi::c_int,
32        /* filename */ SyscallStringArg,
33        /* mode */ std::ffi::c_int,
34    );
35    pub fn faccessat(ctx: &mut SyscallContext) -> SyscallResult {
36        Self::legacy_syscall(cshadow::syscallhandler_faccessat, ctx)
37    }
38
39    log_syscall!(
40        faccessat2,
41        /* rv */ std::ffi::c_int,
42        /* dfd */ std::ffi::c_int,
43        /* filename */ SyscallStringArg,
44        /* mode */ std::ffi::c_int,
45        /* flags */ std::ffi::c_int
46    );
47    pub fn faccessat2(ctx: &mut SyscallContext) -> SyscallResult {
48        Self::legacy_syscall(cshadow::syscallhandler_faccessat2, ctx)
49    }
50
51    log_syscall!(
52        fchmodat,
53        /* rv */ std::ffi::c_int,
54        /* dfd */ std::ffi::c_int,
55        /* filename */ SyscallStringArg,
56        /* mode */ linux_api::types::umode_t
57    );
58    pub fn fchmodat(ctx: &mut SyscallContext) -> SyscallResult {
59        Self::legacy_syscall(cshadow::syscallhandler_fchmodat, ctx)
60    }
61
62    log_syscall!(
63        fchmodat2,
64        /* rv */ std::ffi::c_int,
65        /* dfd */ std::ffi::c_int,
66        /* filename */ SyscallStringArg,
67        /* mode */ linux_api::types::umode_t,
68        /* flags */ std::ffi::c_uint
69    );
70    pub fn fchmodat2(ctx: &mut SyscallContext) -> SyscallResult {
71        Self::legacy_syscall(cshadow::syscallhandler_fchmodat2, ctx)
72    }
73
74    log_syscall!(
75        fchownat,
76        /* rv */ std::ffi::c_int,
77        /* dfd */ std::ffi::c_int,
78        /* filename */ SyscallStringArg,
79        /* user */ std::ffi::c_int,
80        /* group */ std::ffi::c_int,
81        /* flag */ std::ffi::c_int
82    );
83    pub fn fchownat(ctx: &mut SyscallContext) -> SyscallResult {
84        Self::legacy_syscall(cshadow::syscallhandler_fchownat, ctx)
85    }
86
87    log_syscall!(
88        futimesat,
89        /* rv */ std::ffi::c_int,
90        /* dfd */ std::ffi::c_int,
91        /* filename */ SyscallStringArg,
92        /* utimes */ *const linux_api::time::kernel_old_timeval
93    );
94    pub fn futimesat(ctx: &mut SyscallContext) -> SyscallResult {
95        Self::legacy_syscall(cshadow::syscallhandler_futimesat, ctx)
96    }
97
98    log_syscall!(
99        linkat,
100        /* rv */ std::ffi::c_int,
101        /* olddfd */ std::ffi::c_int,
102        /* oldname */ SyscallStringArg,
103        /* newdfd */ std::ffi::c_int,
104        /* newname */ SyscallStringArg,
105        /* flags */ std::ffi::c_int
106    );
107    pub fn linkat(ctx: &mut SyscallContext) -> SyscallResult {
108        Self::legacy_syscall(cshadow::syscallhandler_linkat, ctx)
109    }
110
111    log_syscall!(
112        mkdirat,
113        /* rv */ std::ffi::c_int,
114        /* dfd */ std::ffi::c_int,
115        /* pathname */ SyscallStringArg,
116        /* mode */ linux_api::types::umode_t
117    );
118    pub fn mkdirat(ctx: &mut SyscallContext) -> SyscallResult {
119        Self::legacy_syscall(cshadow::syscallhandler_mkdirat, ctx)
120    }
121
122    log_syscall!(
123        mknodat,
124        /* rv */ std::ffi::c_int,
125        /* dfd */ std::ffi::c_int,
126        /* pathname */ SyscallStringArg,
127        /* mode */ linux_api::types::umode_t,
128        /* dev */ std::ffi::c_uint
129    );
130    pub fn mknodat(ctx: &mut SyscallContext) -> SyscallResult {
131        Self::legacy_syscall(cshadow::syscallhandler_mknodat, ctx)
132    }
133
134    log_syscall!(
135        readlinkat,
136        /* rv */ std::ffi::c_int,
137        /* dirfd */ std::ffi::c_int,
138        /* pathname */ SyscallStringArg,
139        /* buf */ *const std::ffi::c_char,
140        /* bufsize */ std::ffi::c_int,
141    );
142    pub fn readlinkat(ctx: &mut SyscallContext) -> SyscallResult {
143        Self::legacy_syscall(cshadow::syscallhandler_readlinkat, ctx)
144    }
145
146    log_syscall!(
147        renameat,
148        /* rv */ std::ffi::c_int,
149        /* olddfd */ std::ffi::c_int,
150        /* oldname */ SyscallStringArg,
151        /* newdfd */ std::ffi::c_int,
152        /* newname */ SyscallStringArg
153    );
154    pub fn renameat(ctx: &mut SyscallContext) -> SyscallResult {
155        Self::legacy_syscall(cshadow::syscallhandler_renameat, ctx)
156    }
157
158    log_syscall!(
159        renameat2,
160        /* rv */ std::ffi::c_int,
161        /* olddfd */ std::ffi::c_int,
162        /* oldname */ SyscallStringArg,
163        /* newdfd */ std::ffi::c_int,
164        /* newname */ SyscallStringArg,
165        /* flags */ std::ffi::c_int
166    );
167    pub fn renameat2(ctx: &mut SyscallContext) -> SyscallResult {
168        Self::legacy_syscall(cshadow::syscallhandler_renameat2, ctx)
169    }
170
171    log_syscall!(
172        symlinkat,
173        /* rv */ std::ffi::c_int,
174        /* oldname */ SyscallStringArg,
175        /* newdfd */ std::ffi::c_int,
176        /* newname */ SyscallStringArg
177    );
178    pub fn symlinkat(ctx: &mut SyscallContext) -> SyscallResult {
179        Self::legacy_syscall(cshadow::syscallhandler_symlinkat, ctx)
180    }
181
182    log_syscall!(
183        unlinkat,
184        /* rv */ std::ffi::c_int,
185        /* dfd */ std::ffi::c_int,
186        /* pathname */ SyscallStringArg,
187        /* flag */ std::ffi::c_int
188    );
189    pub fn unlinkat(ctx: &mut SyscallContext) -> SyscallResult {
190        Self::legacy_syscall(cshadow::syscallhandler_unlinkat, ctx)
191    }
192
193    log_syscall!(
194        utimensat,
195        /* rv */ std::ffi::c_int,
196        /* dfd */ std::ffi::c_int,
197        /* filename */ SyscallStringArg,
198        /* utimes */ *const linux_api::time::kernel_timespec,
199        /* flags */ std::ffi::c_int
200    );
201    pub fn utimensat(ctx: &mut SyscallContext) -> SyscallResult {
202        Self::legacy_syscall(cshadow::syscallhandler_utimensat, ctx)
203    }
204}