From 00e7ffb7bc18d2175ca69379d2dc7b6d76f612a9 Mon Sep 17 00:00:00 2001 From: vasilito Date: Sat, 11 Jul 2026 16:16:11 +0300 Subject: [PATCH] debug: add markers in dup_into to trace EEXIST source --- src/syscall/fs.rs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/syscall/fs.rs b/src/syscall/fs.rs index 49b364b472..005b2494c3 100644 --- a/src/syscall/fs.rs +++ b/src/syscall/fs.rs @@ -311,15 +311,32 @@ pub fn dup(fd: FileHandle, buf: UserSliceRo, token: &mut CleanLockToken) -> Resu /// Duplicate a file descriptor, placing into a specific fd slot (upstream 0.9.0). pub fn dup_into( fd: FileHandle, - new_fd: FileHandle, + new_cd: FileHandle, buf: UserSliceRo, token: &mut CleanLockToken, ) -> Result { - let new_file = duplicate_file(fd, buf, false, token)?; + crate::info!("dup_into: fd={:#x} new_cd={:#x} buf_len={}", fd.get(), new_cd.get(), buf.len()); + let new_file = match duplicate_file(fd, buf, false, token) { + Ok(f) => f, + Err(e) => { + crate::info!("dup_into: duplicate_file failed: {}", e); + return Err(e); + } + }; + crate::info!("dup_into: duplicate_file ok, inserting at new_cd={:#x}", new_cd.get()); let current_lock = context::current(); let mut current = current_lock.read(token.token()); let (context, mut token) = current.token_split(); - context.insert_file(new_fd, new_file, &mut token).ok_or(Error::new(EEXIST)) + match context.insert_file(new_cd, new_file, &mut token) { + Some(h) => { + crate::info!("dup_into: insert ok, handle={:#x}", h.get()); + Ok(h) + } + None => { + crate::info!("dup_into: insert_file returned None (EEXIST)"); + Err(Error::new(EEXIST)) + } + } } /// Duplicate file descriptor, replacing another