Skip to content

Commit 1677946

Browse files
committed
Auto merge of #1838 - atsmtat:fs-isolation, r=RalfJung
Fix use of deprecated `check_no_isolation` in posix fs shims Update posix fs shims to use new API `reject_in_isolation`, which allows rejection with error code instead of always forcing abort. Error code chosen for each op is the most appropriate one from the list in corresponding syscall's manual. Updated helper APIs to not use quotes (\`) around input name while preparing the message. This allows callers to pass multi-word string like -- "\`read\` from stdin". Cc #1034
2 parents e2872a3 + 20d0f2e commit 1677946

File tree

6 files changed

+260
-66
lines changed

6 files changed

+260
-66
lines changed

src/diagnostics.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
328328
CreatedAlloc(AllocId(id)) => format!("created allocation with id {}", id),
329329
FreedAlloc(AllocId(id)) => format!("freed allocation with id {}", id),
330330
RejectedIsolatedOp(ref op) =>
331-
format!("`{}` was made to return an error due to isolation", op),
331+
format!("{} was made to return an error due to isolation", op),
332332
};
333333

334334
let (title, diag_level) = match e {

src/helpers.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
409409
RejectOpWith::WarningWithoutBacktrace => {
410410
this.tcx
411411
.sess
412-
.warn(&format!("`{}` was made to return an error due to isolation", op_name));
412+
.warn(&format!("{} was made to return an error due to isolation", op_name));
413413
Ok(())
414414
}
415415
RejectOpWith::Warning => {

src/shims/env.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
322322
let size = this.read_scalar(&size_op)?.to_machine_usize(&*this.tcx)?;
323323

324324
if let IsolatedOp::Reject(reject_with) = this.machine.isolated_op {
325-
this.reject_in_isolation("getcwd", reject_with)?;
325+
this.reject_in_isolation("`getcwd`", reject_with)?;
326326
this.set_last_error_from_io_error(ErrorKind::PermissionDenied)?;
327327
return Ok(Pointer::null());
328328
}
@@ -355,7 +355,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
355355
let buf = this.read_pointer(buf_op)?;
356356

357357
if let IsolatedOp::Reject(reject_with) = this.machine.isolated_op {
358-
this.reject_in_isolation("GetCurrentDirectoryW", reject_with)?;
358+
this.reject_in_isolation("`GetCurrentDirectoryW`", reject_with)?;
359359
this.set_last_error_from_io_error(ErrorKind::PermissionDenied)?;
360360
return Ok(0);
361361
}
@@ -380,7 +380,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
380380
let path = this.read_path_from_c_str(this.read_pointer(path_op)?)?;
381381

382382
if let IsolatedOp::Reject(reject_with) = this.machine.isolated_op {
383-
this.reject_in_isolation("chdir", reject_with)?;
383+
this.reject_in_isolation("`chdir`", reject_with)?;
384384
this.set_last_error_from_io_error(ErrorKind::PermissionDenied)?;
385385

386386
return Ok(-1);
@@ -408,7 +408,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
408408
let path = this.read_path_from_wide_str(this.read_pointer(path_op)?)?;
409409

410410
if let IsolatedOp::Reject(reject_with) = this.machine.isolated_op {
411-
this.reject_in_isolation("SetCurrentDirectoryW", reject_with)?;
411+
this.reject_in_isolation("`SetCurrentDirectoryW`", reject_with)?;
412412
this.set_last_error_from_io_error(ErrorKind::PermissionDenied)?;
413413

414414
return Ok(0);

0 commit comments

Comments
 (0)