From 045bcab1eb9a0d0efbed0ae6d2e3dd30270284e6 Mon Sep 17 00:00:00 2001 From: Samrat Man Singh Date: Sat, 8 Aug 2020 15:08:29 +0530 Subject: [PATCH] Add FIXME's for `dup` and other syscalls to support stdin/out/err --- src/shims/posix/fs.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/shims/posix/fs.rs b/src/shims/posix/fs.rs index 13c7827f887..ec6fb7c5373 100644 --- a/src/shims/posix/fs.rs +++ b/src/shims/posix/fs.rs @@ -485,6 +485,7 @@ fn fcntl( let fh = &mut this.machine.file_handler; let (file_result, writable) = match fh.handles.get(&fd) { Some(file_descriptor) => { + // FIXME: Support "dup" for all FDs(stdin, etc) let FileHandle { file, writable } = file_descriptor.as_file_handle()?; (file.try_clone(), *writable) }, @@ -499,6 +500,7 @@ fn fcntl( { let &[_, _] = check_arg_count(args)?; if let Some(file_descriptor) = this.machine.file_handler.handles.get(&fd) { + // FIXME: Support fullfsync for all FDs match file_descriptor.as_file_handle() { Ok(FileHandle { file, writable }) => { let io_result = maybe_sync_file(&file, *writable, File::sync_all); @@ -522,6 +524,7 @@ fn close(&mut self, fd_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> { let fd = this.read_scalar(fd_op)?.to_i32()?; if let Some(file_descriptor) = this.machine.file_handler.handles.remove(&fd) { + // FIXME: Support `close` for all FDs(stdin, etc) let FileHandle { file, writable } = file_descriptor.as_file_handle()?; // We sync the file if it was opened in a mode different than read-only. if *writable { @@ -1219,6 +1222,7 @@ fn ftruncate64( let fd = this.read_scalar(fd_op)?.to_i32()?; let length = this.read_scalar(length_op)?.to_i64()?; if let Some(file_descriptor) = this.machine.file_handler.handles.get_mut(&fd) { + // FIXME: Support ftruncate64 for all FDs let FileHandle { file, writable } = file_descriptor.as_file_handle()?; if *writable { if let Ok(length) = length.try_into() { @@ -1252,6 +1256,7 @@ fn fsync(&mut self, fd_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> { let fd = this.read_scalar(fd_op)?.to_i32()?; if let Some(file_descriptor) = this.machine.file_handler.handles.get(&fd) { + // FIXME: Support fsync for all FDs let FileHandle { file, writable } = file_descriptor.as_file_handle()?; let io_result = maybe_sync_file(&file, *writable, File::sync_all); this.try_unwrap_io_result(io_result) @@ -1267,6 +1272,7 @@ fn fdatasync(&mut self, fd_op: OpTy<'tcx, Tag>) -> InterpResult<'tcx, i32> { let fd = this.read_scalar(fd_op)?.to_i32()?; if let Some(file_descriptor) = this.machine.file_handler.handles.get(&fd) { + // FIXME: Support fdatasync for all FDs let FileHandle { file, writable } = file_descriptor.as_file_handle()?; let io_result = maybe_sync_file(&file, *writable, File::sync_data); this.try_unwrap_io_result(io_result) @@ -1306,6 +1312,7 @@ fn sync_file_range( } if let Some(file_descriptor) = this.machine.file_handler.handles.get(&fd) { + // FIXME: Support sync_data_range for all FDs let FileHandle { file, writable } = file_descriptor.as_file_handle()?; let io_result = maybe_sync_file(&file, *writable, File::sync_data); this.try_unwrap_io_result(io_result) -- 2.44.0