Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Unified Diff: native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc

Issue 635113002: [NaCl SDK] nacl_io: Fix real_node when dealing with a windows terminal (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
diff --git a/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc b/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
index e04e4292d9a3f9e59fb6037e6f05f8256fc9387e..ca7a65feae20c1327b886f14db099bab11e8dcae 100644
--- a/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
+++ b/native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc
@@ -29,6 +29,7 @@
#include "nacl_io/log.h"
#include "nacl_io/memfs/mem_fs.h"
#include "nacl_io/node.h"
+#include "nacl_io/osinttypes.h"
#include "nacl_io/osmman.h"
#include "nacl_io/ossocket.h"
#include "nacl_io/osstat.h"
@@ -84,40 +85,46 @@ Error KernelProxy::Init(PepperInterface* ppapi) {
ScopedFilesystem root_fs;
rtn = MountInternal("", "/", "passthroughfs", 0, NULL, false, &root_fs);
if (rtn != 0)
- assert(false);
+ return rtn;
ScopedFilesystem fs;
rtn = MountInternal("", "/dev", "dev", 0, NULL, false, &fs);
if (rtn != 0)
- assert(false);
+ return rtn;
dev_fs_ = sdk_util::static_scoped_ref_cast<DevFs>(fs);
// Create the filesystem nodes for / and /dev afterward. They can't be
// created the normal way because the dev filesystem didn't exist yet.
rtn = CreateFsNode(root_fs);
if (rtn != 0)
- assert(false);
+ return rtn;
rtn = CreateFsNode(dev_fs_);
if (rtn != 0)
- assert(false);
+ return rtn;
// Open the first three in order to get STDIN, STDOUT, STDERR
int fd;
fd = open("/dev/stdin", O_RDONLY, 0);
+ if (fd < 0) {
+ LOG_ERROR("failed to open /dev/stdin: %s", strerror(errno));
+ return errno;
+ }
assert(fd == 0);
- if (fd < 0)
- rtn = errno;
fd = open("/dev/stdout", O_WRONLY, 0);
+ if (fd < 0) {
+ LOG_ERROR("failed to open /dev/stdout: %s", strerror(errno));
+ return errno;
+ }
assert(fd == 1);
- if (fd < 0)
- rtn = errno;
fd = open("/dev/stderr", O_WRONLY, 0);
+ if (fd < 0) {
+ LOG_ERROR("failed to open /dev/sterr: %s", strerror(errno));
+ return errno;
+ }
assert(fd == 2);
- if (fd < 0)
- rtn = errno;
#ifdef PROVIDES_SOCKET_API
host_resolver_.Init(ppapi_);
@@ -129,11 +136,11 @@ Error KernelProxy::Init(PepperInterface* ppapi) {
stream_fs_.reset(new StreamFs());
int result = stream_fs_->Init(args);
if (result != 0) {
- assert(false);
- rtn = result;
+ LOG_ERROR("initializing streamfs failed: %s", strerror(result));
+ return result;
}
- return rtn;
+ return 0;
}
bool KernelProxy::RegisterFsType(const char* fs_type,
@@ -1136,7 +1143,7 @@ int KernelProxy::sigaction(int signum,
if (action && action->sa_handler != SIG_DFL) {
// Trying to set this action to anything other than SIG_DFL
// is not yet supported.
- LOG_TRACE("sigaction on signal %d != SIG_DFL not supported.", sig);
+ LOG_TRACE("sigaction on signal %d != SIG_DFL not supported.", signum);
errno = EINVAL;
return -1;
}
@@ -1203,7 +1210,7 @@ int KernelProxy::select(int nfds,
if ((timeout->tv_sec < 0) || (timeout->tv_sec >= (INT_MAX / 1000)) ||
(timeout->tv_usec < 0) || (timeout->tv_usec >= 1000000) || (ms < 0) ||
(ms >= INT_MAX)) {
- LOG_TRACE("Invalid timeout: tv_sec=%d tv_usec=%d.",
+ LOG_TRACE("Invalid timeout: tv_sec=%" PRIi64 " tv_usec=%ld.",
timeout->tv_sec,
timeout->tv_usec);
errno = EINVAL;

Powered by Google App Engine
This is Rietveld 408576698