fix: import upstream relibc fdtbl sync fix

This commit is contained in:
Red Bear OS
2026-07-14 22:26:47 +09:00
parent a0b7e0ab64
commit f46e2a31a7
2 changed files with 16 additions and 3 deletions
+11 -3
View File
@@ -1010,7 +1010,6 @@ impl FdTbl {
let mut fdtbl = Self::new();
let files_reader_fd = filetable_fd.as_raw_fd();
let _ = filetable_fd.lseek(0, syscall::flag::SEEK_SET);
fdtbl.set_fd(filetable_fd);
fdtbl.resize(Self::DEFAULT_CAPACITY);
let mut reader = crate::proc::FileBufReader::from_fd(files_reader_fd);
@@ -1019,6 +1018,8 @@ impl FdTbl {
// Manually mark the filetable_fd itself as occupied in userspace FILETABLE
fdtbl.override_at(files_reader_fd, files_reader_fd)?;
fdtbl.set_fd(filetable_fd);
Ok(fdtbl)
}
@@ -1110,7 +1111,7 @@ impl FdTbl {
fn sync_size(fd: Option<&FdGuardUpper>, new_size: usize, tag: usize) -> Result<()> {
if let Some(fd) = fd {
fd.call_wo(
let res = fd.call_wo(
&[],
CallFlags::empty(),
&[
@@ -1118,7 +1119,14 @@ impl FdTbl {
tag as u64,
new_size as u64,
],
)?;
);
if let Err(err) = res {
if err.errno == EINVAL {
// Ignore EINVAL, because it means the kernel table is already larger than new_size.
} else {
return Err(err);
}
}
}
Ok(())
}
+5
View File
@@ -198,6 +198,11 @@ pub unsafe extern "C" fn relibc_start_v1(
)
};
#[cfg(target_os = "redox")]
{
redox_rt::TLS_ACTIVATED.store(true, core::sync::atomic::Ordering::Relaxed);
}
// Set up the right allocator...
// if any memory rust based memory allocation happen before this step .. we are doomed.
alloc_init();