mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-25 17:33:28 +04:00
Add EAGAIN for nonblocking io and poll for file in read_at()
This commit is contained in:
parent
22946c699d
commit
dcfb02c514
4
kernel/Cargo.lock
generated
4
kernel/Cargo.lock
generated
@ -409,7 +409,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "rcore-fs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/rcore-os/rcore-fs#585eb6197aa687320618ee8c3c550a4e32aa9d15"
|
||||
source = "git+https://github.com/rcore-os/rcore-fs#ee0d0b31a1cea4c905100cef501a3bc522ded00d"
|
||||
dependencies = [
|
||||
"spin 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
@ -417,7 +417,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "rcore-fs-sfs"
|
||||
version = "0.1.0"
|
||||
source = "git+https://github.com/rcore-os/rcore-fs#585eb6197aa687320618ee8c3c550a4e32aa9d15"
|
||||
source = "git+https://github.com/rcore-os/rcore-fs#ee0d0b31a1cea4c905100cef501a3bc522ded00d"
|
||||
dependencies = [
|
||||
"bitvec 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
@ -175,9 +175,7 @@ pub fn init_driver(dev: &PCIDevice) {
|
||||
assert!(len as usize <= PAGE_SIZE);
|
||||
let vaddr = phys_to_virt(addr as usize);
|
||||
if let Some(driver) = ahci::init(irq, vaddr, len as usize) {
|
||||
PCI_DRIVERS
|
||||
.lock()
|
||||
.insert(dev.loc, driver);
|
||||
PCI_DRIVERS.lock().insert(dev.loc, driver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,21 +50,23 @@ impl FileHandle {
|
||||
return Err(FsError::InvalidParam); // FIXME: => EBADF
|
||||
}
|
||||
let mut len: usize = 0;
|
||||
/*
|
||||
if !self.options.nonblock {
|
||||
// block
|
||||
loop {
|
||||
len = self.inode.read_at(offset, buf)?;
|
||||
if len > 0 {
|
||||
break;
|
||||
match self.inode.read_at(offset, buf) {
|
||||
Ok(read_len) => {
|
||||
len = read_len;
|
||||
break;
|
||||
}
|
||||
Err(FsError::Again) => {}
|
||||
Err(err) => {
|
||||
return Err(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
len = self.inode.read_at(offset, buf)?;
|
||||
}
|
||||
*/
|
||||
// TODO: handle block/nonblock correctly
|
||||
len = self.inode.read_at(offset, buf)?;
|
||||
Ok(len)
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ impl FileLike {
|
||||
}
|
||||
pub fn ioctl(&mut self, request: usize, arg1: usize, arg2: usize, arg3: usize) -> SysResult {
|
||||
match request {
|
||||
// TODO: place flags & path in FileLike in stead of FileHandle/Socket
|
||||
// TODO: place flags & path in FileLike instead of FileHandle/Socket
|
||||
FIOCLEX => Ok(0),
|
||||
FIONBIO => Ok(0),
|
||||
_ => {
|
||||
|
@ -72,6 +72,7 @@ impl INode for Pseudo {
|
||||
nlinks: 0,
|
||||
uid: 0,
|
||||
gid: 0,
|
||||
rdev: 0,
|
||||
})
|
||||
}
|
||||
impl_inode!();
|
||||
|
@ -95,7 +95,7 @@ impl INode for Stdin {
|
||||
buf[0] = self.pop() as u8;
|
||||
Ok(1)
|
||||
} else {
|
||||
Ok(0)
|
||||
Err(FsError::Again)
|
||||
}
|
||||
}
|
||||
fn write_at(&self, _offset: usize, _buf: &[u8]) -> Result<usize> {
|
||||
|
@ -64,6 +64,7 @@ impl INode for Vga {
|
||||
nlinks: 0,
|
||||
uid: 0,
|
||||
gid: 0,
|
||||
rdev: 0,
|
||||
})
|
||||
}
|
||||
fn io_control(&self, cmd: u32, data: usize) -> Result<()> {
|
||||
|
@ -948,6 +948,9 @@ impl From<FsError> for SysError {
|
||||
FsError::DirNotEmpty => SysError::ENOTEMPTY,
|
||||
FsError::WrongFs => SysError::EINVAL,
|
||||
FsError::DeviceError => SysError::EIO,
|
||||
FsError::IOCTLError => SysError::EINVAL,
|
||||
FsError::NoDevice => SysError::EINVAL,
|
||||
FsError::Again => SysError::EAGAIN,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
2
user
2
user
@ -1 +1 @@
|
||||
Subproject commit bf02e72b85784af3555c7abe6b985aefc215023e
|
||||
Subproject commit 4f90dd042bacdb7eee61ae35ab60b9e17bc70cf7
|
Loading…
Reference in New Issue
Block a user