sim: fix function for emulating dup()
The function was using the host fd to obtain the fd object from the simulated process.
This commit is contained in:
parent
c3268f8820
commit
b26fef8466
|
@ -594,13 +594,14 @@ SyscallReturn
|
||||||
dupFunc(SyscallDesc *desc, int num, LiveProcess *process, ThreadContext *tc)
|
dupFunc(SyscallDesc *desc, int num, LiveProcess *process, ThreadContext *tc)
|
||||||
{
|
{
|
||||||
int index = 0;
|
int index = 0;
|
||||||
int fd = process->sim_fd(process->getSyscallArg(tc, index));
|
int tgt_fd = process->getSyscallArg(tc, index);
|
||||||
if (fd < 0)
|
int sim_fd = process->sim_fd(tgt_fd);
|
||||||
|
if (sim_fd < 0)
|
||||||
return -EBADF;
|
return -EBADF;
|
||||||
|
|
||||||
Process::FdMap *fdo = process->sim_fd_obj(fd);
|
Process::FdMap *fdo = process->sim_fd_obj(tgt_fd);
|
||||||
|
|
||||||
int result = dup(fd);
|
int result = dup(sim_fd);
|
||||||
return (result == -1) ? -errno :
|
return (result == -1) ? -errno :
|
||||||
process->alloc_fd(result, fdo->filename, fdo->flags, fdo->mode, false);
|
process->alloc_fd(result, fdo->filename, fdo->flags, fdo->mode, false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue