summaryrefslogtreecommitdiff
path: root/src/sim
diff options
context:
space:
mode:
authorSteve Reinhardt <stever@eecs.umich.edu>2006-08-28 07:39:56 -0700
committerSteve Reinhardt <stever@eecs.umich.edu>2006-08-28 07:39:56 -0700
commitc5384366b6e5fa487e0a25db6c539b5a9d54ca7b (patch)
tree14f07ddcde4dae918d9177b74d05eee33983fa68 /src/sim
parentdc68512222596fdd81e62e685def20497f6e63d1 (diff)
downloadgem5-c5384366b6e5fa487e0a25db6c539b5a9d54ca7b.tar.xz
Add dup() support (from Antti Miettinen).
--HG-- extra : convert_revision : 72c834666afa3c353da026617ad5e7a762eb645f
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/syscall_emul.cc13
-rw-r--r--src/sim/syscall_emul.hh4
2 files changed, 17 insertions, 0 deletions
diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc
index e72890612..cf90d8f84 100644
--- a/src/sim/syscall_emul.cc
+++ b/src/sim/syscall_emul.cc
@@ -301,6 +301,19 @@ fchownFunc(SyscallDesc *desc, int num, Process *process, ThreadContext *tc)
SyscallReturn
+dupFunc(SyscallDesc *desc, int num, Process *process, ThreadContext *tc)
+{
+ int fd = process->sim_fd(tc->getSyscallArg(0));
+
+ if (fd < 0)
+ return -EBADF;
+
+ int result = dup(fd);
+ return (result == -1) ? -errno : process->alloc_fd(result);
+}
+
+
+SyscallReturn
fcntlFunc(SyscallDesc *desc, int num, Process *process,
ThreadContext *tc)
{
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index a3ff006ef..69ef31421 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -245,6 +245,10 @@ SyscallReturn chownFunc(SyscallDesc *desc, int num,
SyscallReturn fchownFunc(SyscallDesc *desc, int num,
Process *p, ThreadContext *tc);
+/// Target dup() handler.
+SyscallReturn dupFunc(SyscallDesc *desc, int num,
+ Process *process, ThreadContext *tc);
+
/// Target fnctl() handler.
SyscallReturn fcntlFunc(SyscallDesc *desc, int num,
Process *process, ThreadContext *tc);