debug: add markers in dup_into to trace EEXIST source

This commit is contained in:
2026-07-11 16:16:11 +03:00
parent f93ed40ed4
commit 00e7ffb7bc
+20 -3
View File
@@ -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<FileHandle> {
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