@@ -31,6 +31,7 @@ pub trait FileDescription: std::fmt::Debug + Any {
3131 _self_ref : & FileDescriptionRef ,
3232 _communicate_allowed : bool ,
3333 _bytes : & mut [ u8 ] ,
34+ _ptr : Pointer ,
3435 _ecx : & mut MiriInterpCx < ' tcx > ,
3536 ) -> InterpResult < ' tcx , io:: Result < usize > > {
3637 throw_unsup_format ! ( "cannot read from {}" , self . name( ) ) ;
@@ -126,6 +127,7 @@ impl FileDescription for io::Stdin {
126127 _self_ref : & FileDescriptionRef ,
127128 communicate_allowed : bool ,
128129 bytes : & mut [ u8 ] ,
130+ _ptr : Pointer ,
129131 _ecx : & mut MiriInterpCx < ' tcx > ,
130132 ) -> InterpResult < ' tcx , io:: Result < usize > > {
131133 if !communicate_allowed {
@@ -563,9 +565,11 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
563565 // We want to read at most `count` bytes. We are sure that `count` is not negative
564566 // because it was a target's `usize`. Also we are sure that its smaller than
565567 // `usize::MAX` because it is bounded by the host's `isize`.
568+
569+ // TODO: shouldn't pass vec, just pass pointer and write it.
566570 let mut bytes = vec ! [ 0 ; usize :: try_from( count) . unwrap( ) ] ;
567571 let result = match offset {
568- None => fd. read ( & fd, communicate, & mut bytes, this) ,
572+ None => fd. read ( & fd, communicate, & mut bytes, buf , this) ,
569573 Some ( offset) => {
570574 let Ok ( offset) = u64:: try_from ( offset) else {
571575 let einval = this. eval_libc ( "EINVAL" ) ;
@@ -578,10 +582,15 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
578582
579583 // `File::read` never returns a value larger than `count`, so this cannot fail.
580584 match result?. map ( |c| i64:: try_from ( c) . unwrap ( ) ) {
585+ // TODO: get the byte out the result, then write the ptr.
586+ // try to pass this the write_ptr inside write
587+ // Pass the pointer inside the write function.
581588 Ok ( read_bytes) => {
582589 // If reading to `bytes` did not fail, we write those bytes to the buffer.
583590 // Crucially, if fewer than `bytes.len()` bytes were read, only write
584591 // that much into the output buffer!
592+
593+ // TODO: write to pointer here.
585594 this. write_bytes_ptr (
586595 buf,
587596 bytes[ ..usize:: try_from ( read_bytes) . unwrap ( ) ] . iter ( ) . copied ( ) ,
0 commit comments