summaryrefslogtreecommitdiff
path: root/src/sim/syscall_emul.hh
diff options
context:
space:
mode:
authorSteve Reinhardt <steve.reinhardt@amd.com>2012-08-06 16:55:28 -0700
committerSteve Reinhardt <steve.reinhardt@amd.com>2012-08-06 16:55:28 -0700
commite232152db6d9cd511a75c41f47b00befe9b7719e (patch)
treeb11c3dba3852a46a4abdd0064142f4585e9ac9e9 /src/sim/syscall_emul.hh
parentb647b48bf4d980e26b4626e94f1207ad66fc324e (diff)
downloadgem5-e232152db6d9cd511a75c41f47b00befe9b7719e.tar.xz
syscall_emul: clean up open() code a bit.
Diffstat (limited to 'src/sim/syscall_emul.hh')
-rw-r--r--src/sim/syscall_emul.hh11
1 files changed, 8 insertions, 3 deletions
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.