* Implement open operation

* Comment out the code for dup2
This commit is contained in:
R Aadarsh
2026-05-27 20:22:16 +05:30
parent 0810991d7d
commit 4df38b6f0d
4 changed files with 42 additions and 24 deletions
+19 -10
View File
@@ -1273,7 +1273,16 @@ impl Pal for Sys {
path,
flag,
mode,
} => todo!(),
} => {
let src_fd =
Sys::open(unsafe { CStr::from_ptr(path) }, flag, mode)? as usize;
syscall::sendfd(
new_file_table.as_raw_fd(),
src_fd,
0,
u64::try_from(fd).map_err(|_| Errno(EBADFD))?,
)?;
}
crate::header::spawn::Operation::Close(fd) => {
new_file_table.call_wo(
&(fd as usize).to_ne_bytes(),
@@ -1284,15 +1293,15 @@ impl Pal for Sys {
crate::header::spawn::Operation::Chdir(_) => todo!(),
crate::header::spawn::Operation::FChdir(_) => todo!(),
crate::header::spawn::Operation::Dup2(old, new) => {
new_file_table.call_wo(
[(old as usize).to_ne_bytes(), (new as usize).to_ne_bytes()]
.into_iter()
.flatten()
.collect::<Vec<u8>>()
.as_slice(),
syscall::CallFlags::empty(),
&[syscall::flag::FileTableVerb::Dup2 as u64],
)?;
// new_file_table.call_wo(
// [(old as usize).to_ne_bytes(), (new as usize).to_ne_bytes()]
// .into_iter()
// .flatten()
// .collect::<Vec<u8>>()
// .as_slice(),
// syscall::CallFlags::empty(),
// &[syscall::flag::FileTableVerb::Dup2 as u64],
// )?;
}
}
}