summaryrefslogtreecommitdiff
path: root/sim/syscall_emul.cc
diff options
context:
space:
mode:
authorAli Saidi <saidi@eecs.umich.edu>2006-02-19 00:47:45 -0500
committerAli Saidi <saidi@eecs.umich.edu>2006-02-19 00:47:45 -0500
commit14f2cdb1a14e9e6896939c210cdacef289d9c263 (patch)
treecdf7705980fb776a518d40e4fa3869fc0bead2cf /sim/syscall_emul.cc
parenta611b8100379e28728c1084801413954c973e734 (diff)
parent00d58aeb4dc0569bc3d1273d90867148e6500ad9 (diff)
downloadgem5-14f2cdb1a14e9e6896939c210cdacef289d9c263.tar.xz
Merge zizzer:/bk/m5
into pb15.local:/Users/ali/work/m5.head --HG-- extra : convert_revision : 774e4afbb0f9c3ae62843138b6d7195ea184ff92
Diffstat (limited to 'sim/syscall_emul.cc')
-rw-r--r--sim/syscall_emul.cc46
1 files changed, 46 insertions, 0 deletions
diff --git a/sim/syscall_emul.cc b/sim/syscall_emul.cc
index 0fac43fc5..0bfb9ddf5 100644
--- a/sim/syscall_emul.cc
+++ b/sim/syscall_emul.cc
@@ -26,6 +26,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include <fcntl.h>
#include <unistd.h>
#include <string>
@@ -278,3 +279,48 @@ fchownFunc(SyscallDesc *desc, int num, Process *process, ExecContext *xc)
int result = fchown(fd, hostOwner, hostGroup);
return (result == -1) ? -errno : result;
}
+
+
+SyscallReturn
+fcntlFunc(SyscallDesc *desc, int num, Process *process,
+ ExecContext *xc)
+{
+ int fd = xc->getSyscallArg(0);
+
+ if (fd < 0 || process->sim_fd(fd) < 0)
+ return -EBADF;
+
+ int cmd = xc->getSyscallArg(1);
+ switch (cmd) {
+ case 0: // F_DUPFD
+ // if we really wanted to support this, we'd need to do it
+ // in the target fd space.
+ warn("fcntl(%d, F_DUPFD) not supported, error returned\n", fd);
+ return -EMFILE;
+
+ case 1: // F_GETFD (get close-on-exec flag)
+ case 2: // F_SETFD (set close-on-exec flag)
+ return 0;
+
+ case 3: // F_GETFL (get file flags)
+ case 4: // F_SETFL (set file flags)
+ // not sure if this is totally valid, but we'll pass it through
+ // to the underlying OS
+ warn("fcntl(%d, %d) passed through to host\n", fd, cmd);
+ return fcntl(process->sim_fd(fd), cmd);
+ // return 0;
+
+ case 7: // F_GETLK (get lock)
+ case 8: // F_SETLK (set lock)
+ case 9: // F_SETLKW (set lock and wait)
+ // don't mess with file locking... just act like it's OK
+ warn("File lock call (fcntl(%d, %d)) ignored.\n", fd, cmd);
+ return 0;
+
+ default:
+ warn("Unknown fcntl command %d\n", cmd);
+ return 0;
+ }
+}
+
+