diff --git a/src/syscall/fs.rs b/src/syscall/fs.rs index 98b152eaa6..ffc12d23f4 100644 --- a/src/syscall/fs.rs +++ b/src/syscall/fs.rs @@ -322,7 +322,25 @@ pub fn dup2( if buf.is_empty() { return Ok(new_fd); } - let new_file = duplicate_file(fd, buf, false, token)?; + let dbg_euid = { + let cur = context::current(); + let g = cur.read(token.token()); + g.euid + }; + let new_file = match duplicate_file(fd, buf, false, token) { + Ok(f) => { + warn!("DIAG dup2-self-buf euid={dbg_euid} fd={} duplicate_file=OK", fd.get()); + f + } + Err(e) => { + warn!( + "DIAG dup2-self-buf euid={dbg_euid} fd={} duplicate_file=ERR errno={}", + fd.get(), + e.errno + ); + return Err(e); + } + }; let old_file = { let current_lock = context::current(); let mut current = current_lock.read(token.token());