sim: implement getdents/getdents64 in user mode

Has been tested only for alpha.
Committed by: Nilay Vaish <nilay@cs.wisc.edu>
This commit is contained in:
Michael Adler
2014-10-20 16:44:53 -05:00
parent e72736aaf0
commit a3fe4c0662
8 changed files with 58 additions and 14 deletions

View File

@@ -31,6 +31,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <sys/syscall.h>
#include <cstdio>
#include <iostream>
@@ -867,6 +868,41 @@ cloneFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
}
}
SyscallReturn
getdentsFunc(SyscallDesc *desc, int num, LiveProcess *p,
ThreadContext *tc)
{
int index = 0;
int fd = p->sim_fd(p->getSyscallArg(tc, index));
Addr bufPtr = p->getSyscallArg(tc, index);
int nbytes = p->getSyscallArg(tc, index);
BufferArg bufArg(bufPtr, nbytes);
int bytes_read = syscall(SYS_getdents, fd, bufArg.bufferPtr(), nbytes);
if (bytes_read != -1)
bufArg.copyOut(tc->getMemProxy());
return bytes_read;
}
SyscallReturn
getdents64Func(SyscallDesc *desc, int num, LiveProcess *p,
ThreadContext *tc)
{
int index = 0;
int fd = p->sim_fd(p->getSyscallArg(tc, index));
Addr bufPtr = p->getSyscallArg(tc, index);
int nbytes = p->getSyscallArg(tc, index);
BufferArg bufArg(bufPtr, nbytes);
int bytes_read = syscall(SYS_getdents64, fd, bufArg.bufferPtr(), nbytes);
if (bytes_read != -1)
bufArg.copyOut(tc->getMemProxy());
return bytes_read;
}
SyscallReturn
accessFunc(SyscallDesc *desc, int callnum, LiveProcess *p, ThreadContext *tc,
int index)

View File

@@ -439,6 +439,14 @@ futexFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
}
/// Target getdents() handler.
SyscallReturn getdentsFunc(SyscallDesc *desc, int num,
LiveProcess *process, ThreadContext *tc);
/// Target getdents64() handler.
SyscallReturn getdents64Func(SyscallDesc *desc, int num,
LiveProcess *process, ThreadContext *tc);
/// Pseudo Funcs - These functions use a different return convension,
/// returning a second value in a register other than the normal return register