syscall_emul.cc (13883:f44e21d3aaa7) syscall_emul.cc (13933:b4382461066d)
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 43 unchanged lines hidden (view full) ---

52#include "sim/sim_exit.hh"
53#include "sim/syscall_debug_macros.hh"
54#include "sim/syscall_desc.hh"
55#include "sim/system.hh"
56
57using namespace std;
58using namespace TheISA;
59
1/*
2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;

--- 43 unchanged lines hidden (view full) ---

52#include "sim/sim_exit.hh"
53#include "sim/syscall_debug_macros.hh"
54#include "sim/syscall_desc.hh"
55#include "sim/system.hh"
56
57using namespace std;
58using namespace TheISA;
59
60void
61warnUnsupportedOS(std::string syscall_name)
62{
63 warn("Cannot invoke %s on host operating system.", syscall_name);
64}
65
60SyscallReturn
61unimplementedFunc(SyscallDesc *desc, int callnum, Process *process,
62 ThreadContext *tc)
63{
64 fatal("syscall %s (#%d) unimplemented.", desc->name(), callnum);
65
66 return 1;
67}

--- 963 unchanged lines hidden (view full) ---

1031 ThreadContext *tc)
1032{
1033 return process->egid();
1034}
1035
1036SyscallReturn
1037fallocateFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
1038{
66SyscallReturn
67unimplementedFunc(SyscallDesc *desc, int callnum, Process *process,
68 ThreadContext *tc)
69{
70 fatal("syscall %s (#%d) unimplemented.", desc->name(), callnum);
71
72 return 1;
73}

--- 963 unchanged lines hidden (view full) ---

1037 ThreadContext *tc)
1038{
1039 return process->egid();
1040}
1041
1042SyscallReturn
1043fallocateFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc)
1044{
1039#if NO_FALLOCATE
1040 warn("Host OS cannot support calls to fallocate. Ignoring syscall");
1041#else
1045#if __linux__
1042 int index = 0;
1043 int tgt_fd = p->getSyscallArg(tc, index);
1044 int mode = p->getSyscallArg(tc, index);
1045 off_t offset = p->getSyscallArg(tc, index);
1046 off_t len = p->getSyscallArg(tc, index);
1047
1048 auto ffdp = std::dynamic_pointer_cast<FileFDEntry>((*p->fds)[tgt_fd]);
1049 if (!ffdp)
1050 return -EBADF;
1051 int sim_fd = ffdp->getSimFD();
1052
1053 int result = fallocate(sim_fd, mode, offset, len);
1054 if (result < 0)
1055 return -errno;
1046 int index = 0;
1047 int tgt_fd = p->getSyscallArg(tc, index);
1048 int mode = p->getSyscallArg(tc, index);
1049 off_t offset = p->getSyscallArg(tc, index);
1050 off_t len = p->getSyscallArg(tc, index);
1051
1052 auto ffdp = std::dynamic_pointer_cast<FileFDEntry>((*p->fds)[tgt_fd]);
1053 if (!ffdp)
1054 return -EBADF;
1055 int sim_fd = ffdp->getSimFD();
1056
1057 int result = fallocate(sim_fd, mode, offset, len);
1058 if (result < 0)
1059 return -errno;
1056#endif
1057 return 0;
1060 return 0;
1061#else
1062 warnUnsupportedOS("fallocate");
1063 return -1;
1064#endif
1058}
1059
1060SyscallReturn
1061accessFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc,
1062 int index)
1063{
1064 string path;
1065 if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index)))

--- 671 unchanged lines hidden ---
1065}
1066
1067SyscallReturn
1068accessFunc(SyscallDesc *desc, int callnum, Process *p, ThreadContext *tc,
1069 int index)
1070{
1071 string path;
1072 if (!tc->getMemProxy().tryReadString(path, p->getSyscallArg(tc, index)))

--- 671 unchanged lines hidden ---