changeset db55c4b5136e in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=db55c4b5136e
description:
        syscall_emul: clean up open() code a bit.

diffstat:

 src/kern/linux/linux.cc     |   5 +++--
 src/kern/operatingsystem.cc |   5 +++--
 src/sim/syscall_emul.hh     |  11 ++++++++---
 3 files changed, 14 insertions(+), 7 deletions(-)

diffs (67 lines):

diff -r e9b713df4e1d -r db55c4b5136e src/kern/linux/linux.cc
--- a/src/kern/linux/linux.cc   Mon Aug 06 16:52:49 2012 -0700
+++ b/src/kern/linux/linux.cc   Mon Aug 06 16:55:28 2012 -0700
@@ -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 @@
         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 -r e9b713df4e1d -r db55c4b5136e src/kern/operatingsystem.cc
--- a/src/kern/operatingsystem.cc       Mon Aug 06 16:52:49 2012 -0700
+++ b/src/kern/operatingsystem.cc       Mon Aug 06 16:55:28 2012 -0700
@@ -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 -r e9b713df4e1d -r db55c4b5136e src/sim/syscall_emul.hh
--- a/src/sim/syscall_emul.hh   Mon Aug 06 16:52:49 2012 -0700
+++ b/src/sim/syscall_emul.hh   Mon Aug 06 16:55:28 2012 -0700
@@ -640,17 +640,22 @@
     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.
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to