@@ -108,7 +108,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
108108 & mut self ,
109109 fd_op : OpTy < ' tcx , Tag > ,
110110 cmd_op : OpTy < ' tcx , Tag > ,
111- arg_op : Option < OpTy < ' tcx , Tag > > ,
111+ _arg_op : Option < OpTy < ' tcx , Tag > > ,
112112 ) -> InterpResult < ' tcx , i32 > {
113113 let this = self . eval_context_mut ( ) ;
114114
@@ -118,29 +118,11 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
118118
119119 let fd = this. read_scalar ( fd_op) ?. to_i32 ( ) ?;
120120 let cmd = this. read_scalar ( cmd_op) ?. to_i32 ( ) ?;
121-
122- if cmd == this. eval_libc_i32 ( "F_SETFD" ) ? {
123- // This does not affect the file itself. Certain flags might require changing the file
124- // or the way it is accessed somehow.
125- let flag = this. read_scalar ( arg_op. unwrap ( ) ) ?. to_i32 ( ) ?;
126- // The only usage of this in stdlib at the moment is to enable the `FD_CLOEXEC` flag.
127- let fd_cloexec = this. eval_libc_i32 ( "FD_CLOEXEC" ) ?;
128- if let Some ( FileHandle { flag : old_flag, .. } ) =
129- this. machine . file_handler . handles . get_mut ( & fd)
130- {
131- // Check that the only difference between the old flag and the current flag is
132- // exactly the `FD_CLOEXEC` value.
133- if flag ^ * old_flag == fd_cloexec {
134- * old_flag = flag;
135- } else {
136- throw_unsup_format ! ( "Unsupported arg {:#x} for `F_SETFD`" , flag) ;
137- }
138- }
139- Ok ( 0 )
140- } else if cmd == this. eval_libc_i32 ( "F_GETFD" ) ? {
121+ // We only support getting the flags for a descriptor
122+ if cmd == this. eval_libc_i32 ( "F_GETFD" ) ? {
141123 this. get_handle_and ( fd, |handle| Ok ( handle. flag ) )
142124 } else {
143- throw_unsup_format ! ( "Unsupported command {:#x}" , cmd) ;
125+ throw_unsup_format ! ( "The {:#x} command is not supported for `fcntl`) " , cmd) ;
144126 }
145127 }
146128
0 commit comments