Skip to content

Commit 6ab82f5

Browse files
committed
posix_fadvise is Linux-only; also validate arguments a bit
1 parent 9e39bfb commit 6ab82f5

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/shims/foreign_items/posix.rs

-4
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,6 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
115115
let result = this.lseek64(args[0], args[1], args[2])?;
116116
this.write_scalar(Scalar::from_int(result, dest.layout.size), dest)?;
117117
}
118-
"posix_fadvise" => {
119-
// fadvise is only informational, we can ignore it.
120-
this.write_null(dest)?;
121-
}
122118

123119
// Allocation
124120
"posix_memalign" => {

src/shims/foreign_items/posix/linux.rs

+9
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
3434
let result = this.linux_readdir64_r(args[0], args[1], args[2])?;
3535
this.write_scalar(Scalar::from_int(result, dest.layout.size), dest)?;
3636
}
37+
// Linux-only
38+
"posix_fadvise" => {
39+
let _fd = this.read_scalar(args[0])?.to_i32()?;
40+
let _offset = this.read_scalar(args[1])?.to_machine_isize(this)?;
41+
let _len = this.read_scalar(args[2])?.to_machine_isize(this)?;
42+
let _advice = this.read_scalar(args[3])?.to_i32()?;
43+
// fadvise is only informational, we can ignore it.
44+
this.write_null(dest)?;
45+
}
3746

3847
// Time related shims
3948
"clock_gettime" => {

0 commit comments

Comments
 (0)