summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/kern/linux/linux.cc5
-rw-r--r--src/kern/operatingsystem.cc5
-rw-r--r--src/sim/syscall_emul.hh11
3 files changed, 14 insertions, 7 deletions
diff --git a/src/kern/linux/linux.cc b/src/kern/linux/linux.cc
index 62c25e2df..8214aeb97 100644
--- a/src/kern/linux/linux.cc
+++ b/src/kern/linux/linux.cc
@@ -38,7 +38,8 @@
#include "sim/system.hh"
int
-Linux::openSpecialFile(std::string path, LiveProcess *process, ThreadContext *tc)
+Linux::openSpecialFile(std::string path, LiveProcess *process,
+ ThreadContext *tc)
{
DPRINTF(SyscallVerbose, "Opening special file: %s\n", path.c_str());
if (path.compare(0, 13, "/proc/meminfo") == 0) {
@@ -51,7 +52,7 @@ Linux::openSpecialFile(std::string path, LiveProcess *process, ThreadContext *tc
return fd;
}
- warn("Attempting to open special file: %s. Ignorning. Simulation may"
+ warn("Attempting to open special file: %s. Ignoring. Simulation may"
" take un-expected code path or be non-deterministic until proper"
" handling is implemented.\n", path.c_str());
return -1;
diff --git a/src/kern/operatingsystem.cc b/src/kern/operatingsystem.cc
index 62fcdba7a..ce4092c4a 100644
--- a/src/kern/operatingsystem.cc
+++ b/src/kern/operatingsystem.cc
@@ -33,9 +33,10 @@
#include "kern/operatingsystem.hh"
int
-OperatingSystem::openSpecialFile(std::string path, LiveProcess *process, ThreadContext *tc)
+OperatingSystem::openSpecialFile(std::string path, LiveProcess *process,
+ ThreadContext *tc)
{
- warn("Attempting to open special file: %s. Ignorning. Simulation may"
+ warn("Attempting to open special file: %s. Ignoring. Simulation may"
" take un-expected code path or be non-deterministic until proper"
" handling is implemented.\n", path.c_str());
return -1;
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index b2786e572..b5a8e49d4 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -640,17 +640,22 @@ openFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
DPRINTF(SyscallVerbose, "opening file %s\n", path.c_str());
int fd;
+ int local_errno;
if (startswith(path, "/proc/") || startswith(path, "/system/") ||
startswith(path, "/platform/") || startswith(path, "/sys/")) {
- // It's a proc/sys entery and requires special handling
+ // It's a proc/sys entry and requires special handling
fd = OS::openSpecialFile(path, process, tc);
- return (fd == -1) ? -1 : process->alloc_fd(fd,path.c_str(),hostFlags,mode, false);
+ local_errno = ENOENT;
} else {
// open the file
fd = open(path.c_str(), hostFlags, mode);
- return (fd == -1) ? -errno : process->alloc_fd(fd,path.c_str(),hostFlags,mode, false);
+ local_errno = errno;
}
+ if (fd == -1)
+ return -local_errno;
+
+ return process->alloc_fd(fd, path.c_str(), hostFlags, mode, false);
}
/// Target sysinfo() handler.