]> git.lizzy.rs Git - rust.git/commitdiff
Remove F_SETFD command
authorChristian Poveda <christianpoveda@protonmail.com>
Fri, 11 Oct 2019 17:17:54 +0000 (12:17 -0500)
committerChristian Poveda <christianpoveda@protonmail.com>
Fri, 11 Oct 2019 17:20:06 +0000 (12:20 -0500)
src/shims/fs.rs

index a6a1eb947b0bbe0ad8622c10d9f3d0df3aceeee6..443a61c46e9aa23b9da599375fee5dad5516488c 100644 (file)
@@ -108,7 +108,7 @@ fn fcntl(
         &mut self,
         fd_op: OpTy<'tcx, Tag>,
         cmd_op: OpTy<'tcx, Tag>,
-        arg_op: Option<OpTy<'tcx, Tag>>,
+        _arg_op: Option<OpTy<'tcx, Tag>>,
     ) -> InterpResult<'tcx, i32> {
         let this = self.eval_context_mut();
 
@@ -118,29 +118,11 @@ fn fcntl(
 
         let fd = this.read_scalar(fd_op)?.to_i32()?;
         let cmd = this.read_scalar(cmd_op)?.to_i32()?;
-
-        if cmd == this.eval_libc_i32("F_SETFD")? {
-            // This does not affect the file itself. Certain flags might require changing the file
-            // or the way it is accessed somehow.
-            let flag = this.read_scalar(arg_op.unwrap())?.to_i32()?;
-            // The only usage of this in stdlib at the moment is to enable the `FD_CLOEXEC` flag.
-            let fd_cloexec = this.eval_libc_i32("FD_CLOEXEC")?;
-            if let Some(FileHandle { flag: old_flag, .. }) =
-                this.machine.file_handler.handles.get_mut(&fd)
-            {
-                // Check that the only difference between the old flag and the current flag is
-                // exactly the `FD_CLOEXEC` value.
-                if flag ^ *old_flag == fd_cloexec {
-                    *old_flag = flag;
-                } else {
-                    throw_unsup_format!("Unsupported arg {:#x} for `F_SETFD`", flag);
-                }
-            }
-            Ok(0)
-        } else if cmd == this.eval_libc_i32("F_GETFD")? {
+        // We only support getting the flags for a descriptor
+        if cmd == this.eval_libc_i32("F_GETFD")? {
             this.get_handle_and(fd, |handle| Ok(handle.flag))
         } else {
-            throw_unsup_format!("Unsupported command {:#x}", cmd);
+            throw_unsup_format!("The {:#x} command is not supported for `fcntl`)", cmd);
         }
     }