@@ -15,7 +15,7 @@ use shims::time::system_time_to_duration;
1515#[ derive( Debug ) ]
1616pub struct FileHandle {
1717 file : File ,
18- read_only : bool ,
18+ writable : bool ,
1919}
2020
2121pub struct FileHandler {
@@ -57,13 +57,13 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
5757 if ( o_rdonly | o_wronly | o_rdwr) & !0b11 != 0 {
5858 throw_unsup_format ! ( "Access mode flags on this platform are unsupported" ) ;
5959 }
60- let mut read_only = false ;
60+ let mut writable = true ;
6161
6262 // Now we check the access mode
6363 let access_mode = flag & 0b11 ;
6464
6565 if access_mode == o_rdonly {
66- read_only = true ;
66+ writable = false ;
6767 options. read ( true ) ;
6868 } else if access_mode == o_wronly {
6969 options. write ( true ) ;
@@ -109,7 +109,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
109109 let fd = options. open ( & path) . map ( |file| {
110110 let mut fh = & mut this. machine . file_handler ;
111111 fh. low += 1 ;
112- fh. handles . insert ( fh. low , FileHandle { file, read_only } ) . unwrap_none ( ) ;
112+ fh. handles . insert ( fh. low , FileHandle { file, writable } ) . unwrap_none ( ) ;
113113 fh. low
114114 } ) ;
115115
@@ -153,7 +153,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
153153
154154 if let Some ( handle) = this. machine . file_handler . handles . remove ( & fd) {
155155 // We sync the file if it was opened in a mode different than read-only.
156- if ! handle. read_only {
156+ if handle. writable {
157157 // `File::sync_all` does the checks that are done when closing a file. We do this to
158158 // to handle possible errors correctly.
159159 let result = this. try_unwrap_io_result ( handle. file . sync_all ( ) . map ( |_| 0i32 ) ) ;
@@ -164,7 +164,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
164164 } else {
165165 // We drop the file, this closes it but ignores any errors produced when closing
166166 // it. This is done because `File::sync_call` cannot be done over files like
167- // `/dev/urandom`. Check
167+ // `/dev/urandom` which are read-only . Check
168168 // https://github.com/rust-lang/miri/issues/999#issuecomment-568920439 for a deeper
169169 // discussion.
170170 drop ( handle) ;
0 commit comments