Skip to content

Commit

Permalink
Merge pull request #1086 from stlankes/mio
Browse files Browse the repository at this point in the history
remove obsolete code
  • Loading branch information
stlankes authored Feb 29, 2024
2 parents 734dabb + 3e5f782 commit 44aed17
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 16 deletions.
7 changes: 0 additions & 7 deletions src/fd/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,6 @@ pub(crate) trait ObjectInterface: Sync + Send + core::fmt::Debug + DynClone {
fn ioctl(&self, _cmd: IoCtl, _value: bool) -> Result<(), IoError> {
Err(IoError::ENOSYS)
}

// close a file descriptor
fn close(&self) {}
}

pub(crate) fn open(
Expand All @@ -306,10 +303,6 @@ pub(crate) fn open(
}
}

pub(crate) fn close(fd: FileDescriptor) {
let _ = remove_object(fd).map(|v| v.close());
}

pub(crate) fn read(fd: FileDescriptor, buf: &mut [u8]) -> Result<usize, IoError> {
let obj = get_object(fd)?;

Expand Down
6 changes: 4 additions & 2 deletions src/fs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ use alloc::vec::Vec;
use hermit_sync::OnceCell;
use mem::MemDirectory;

use crate::fd::{insert_object, AccessPermission, IoError, ObjectInterface, OpenOption};
use crate::fd::{
insert_object, remove_object, AccessPermission, IoError, ObjectInterface, OpenOption,
};
use crate::io::Write;
use crate::time::{timespec, SystemTime};

Expand Down Expand Up @@ -488,6 +490,6 @@ impl crate::io::Write for File {

impl Drop for File {
fn drop(&mut self) {
fd::close(self.fd);
let _ = remove_object(self.fd);
}
}
8 changes: 1 addition & 7 deletions src/syscalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,13 +247,7 @@ pub extern "C" fn sys_open(name: *const u8, flags: i32, mode: u32) -> FileDescri

extern "C" fn __sys_close(fd: FileDescriptor) -> i32 {
let obj = remove_object(fd);
obj.map_or_else(
|e| -num::ToPrimitive::to_i32(&e).unwrap(),
|v| {
v.close();
0
},
)
obj.map_or_else(|e| -num::ToPrimitive::to_i32(&e).unwrap(), |_| 0)
}

#[no_mangle]
Expand Down

0 comments on commit 44aed17

Please sign in to comment.