Commit 4dd40fa3 authored by Jeremy Soller's avatar Jeremy Soller

Implement fgetfl, fsetfl for null

parent 2214442a
......@@ -711,21 +711,32 @@ where
}
fn fcntl(&mut self, fd: usize, cmd: usize, arg: usize) -> SyscallResult<Option<usize>> {
let file = self.files
.get_mut(&fd)
.ok_or_else(|| SyscallError::new(syscall::EBADF))?;
if let SchemeFile::Socket(ref mut socket_file) = *file {
if let Some(ref mut null) = self.nulls.get_mut(&fd) {
match cmd {
syscall::F_GETFL => Ok(Some(socket_file.flags)),
syscall::F_GETFL => Ok(Some(null.flags)),
syscall::F_SETFL => {
socket_file.flags = arg & !syscall::O_ACCMODE;
null.flags = arg & !syscall::O_ACCMODE;
Ok(Some(0))
}
_ => Err(SyscallError::new(syscall::EINVAL)),
}
} else {
Err(SyscallError::new(syscall::EBADF))
let file = self.files
.get_mut(&fd)
.ok_or_else(|| SyscallError::new(syscall::EBADF))?;
if let SchemeFile::Socket(ref mut socket_file) = *file {
match cmd {
syscall::F_GETFL => Ok(Some(socket_file.flags)),
syscall::F_SETFL => {
socket_file.flags = arg & !syscall::O_ACCMODE;
Ok(Some(0))
}
_ => Err(SyscallError::new(syscall::EINVAL)),
}
} else {
Err(SyscallError::new(syscall::EBADF))
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment