summaryrefslogtreecommitdiff
path: root/src/sim/syscall_emul.cc
diff options
context:
space:
mode:
authorNilay Vaish <nilay@cs.wisc.edu>2015-04-13 17:33:57 -0500
committerNilay Vaish <nilay@cs.wisc.edu>2015-04-13 17:33:57 -0500
commitb26fef8466ce0ddf4bd0695e09538117e16cf7d8 (patch)
tree56ab9023d2c4d47629f6fcc363a767fdba33fd23 /src/sim/syscall_emul.cc
parentc3268f882029c7501867540ccf04db054fdff084 (diff)
downloadgem5-b26fef8466ce0ddf4bd0695e09538117e16cf7d8.tar.xz
sim: fix function for emulating dup()
The function was using the host fd to obtain the fd object from the simulated process.
Diffstat (limited to 'src/sim/syscall_emul.cc')
-rw-r--r--src/sim/syscall_emul.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc
index bf7efe210..8f3d08cd7 100644
--- a/src/sim/syscall_emul.cc
+++ b/src/sim/syscall_emul.cc
@@ -594,13 +594,14 @@ SyscallReturn
dupFunc(SyscallDesc *desc, int num, LiveProcess *process, ThreadContext *tc)
{
int index = 0;
- int fd = process->sim_fd(process->getSyscallArg(tc, index));
- if (fd < 0)
+ int tgt_fd = process->getSyscallArg(tc, index);
+ int sim_fd = process->sim_fd(tgt_fd);
+ if (sim_fd < 0)
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 :
process->alloc_fd(result, fdo->filename, fdo->flags, fdo->mode, false);
}