]> git.lizzy.rs Git - rust.git/commitdiff
Add FIXME's for `dup` and other syscalls to support stdin/out/err
authorSamrat Man Singh <samratmansingh@gmail.com>
Sat, 8 Aug 2020 09:38:29 +0000 (15:08 +0530)
committerSamrat Man Singh <samratmansingh@gmail.com>
Sat, 8 Aug 2020 09:38:29 +0000 (15:08 +0530)
src/shims/posix/fs.rs

index 13c7827f8879460af472b462623c8a1e85b5d749..ec6fb7c537356fb5a1fac79085019086cc12ef07 100644 (file)
@@ -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)