| Index: native_client_sdk/src/libraries/nacl_io/devfs/dev_fs.cc
|
| diff --git a/native_client_sdk/src/libraries/nacl_io/devfs/dev_fs.cc b/native_client_sdk/src/libraries/nacl_io/devfs/dev_fs.cc
|
| index 9b50c90f8055a82ab58b8a8740cc5fa5043b2987..efe805525cc5669a58f3b87d43a529e07a264a60 100644
|
| --- a/native_client_sdk/src/libraries/nacl_io/devfs/dev_fs.cc
|
| +++ b/native_client_sdk/src/libraries/nacl_io/devfs/dev_fs.cc
|
| @@ -189,16 +189,21 @@ Error ConsoleNode::Write(const HandleAttr& attr,
|
| int* out_bytes) {
|
| *out_bytes = 0;
|
|
|
| - ConsoleInterface* con_intr = filesystem_->ppapi()->GetConsoleInterface();
|
| - VarInterface* var_intr = filesystem_->ppapi()->GetVarInterface();
|
| + ConsoleInterface* con_iface = filesystem_->ppapi()->GetConsoleInterface();
|
| + VarInterface* var_iface = filesystem_->ppapi()->GetVarInterface();
|
|
|
| - if (!(var_intr && con_intr))
|
| + if (!(var_iface && con_iface)) {
|
| + LOG_ERROR("Got NULL interface(s): %s%s",
|
| + con_iface ? "" : "Console ",
|
| + var_iface ? "" : "Var");
|
| return ENOSYS;
|
| + }
|
|
|
| const char* var_data = static_cast<const char*>(buf);
|
| uint32_t len = static_cast<uint32_t>(count);
|
| - struct PP_Var val = var_intr->VarFromUtf8(var_data, len);
|
| - con_intr->Log(filesystem_->ppapi()->GetInstance(), level_, val);
|
| + struct PP_Var val = var_iface->VarFromUtf8(var_data, len);
|
| + con_iface->Log(filesystem_->ppapi()->GetInstance(), level_, val);
|
| + var_iface->Release(val);
|
|
|
| *out_bytes = count;
|
| return 0;
|
| @@ -241,8 +246,10 @@ Error UrandomNode::Read(const HandleAttr& attr,
|
| *out_bytes = 0;
|
|
|
| #if defined(__native_client__)
|
| - if (!interface_ok_)
|
| + if (!interface_ok_) {
|
| + LOG_ERROR("NACL_IRT_RANDOM_v0_1 interface not avaiable.");
|
| return EBADF;
|
| + }
|
|
|
| size_t nread;
|
| int error = (*random_interface_.get_random_bytes)(buf, count, &nread);
|
| @@ -295,8 +302,10 @@ Error DevFs::Access(const Path& path, int a_mode) {
|
| return error;
|
|
|
| // Don't allow execute access.
|
| - if (a_mode & X_OK)
|
| + if (a_mode & X_OK) {
|
| + LOG_TRACE("Executing devfs nodes is not allowed.");
|
| return EACCES;
|
| + }
|
|
|
| return 0;
|
| }
|
| @@ -305,38 +314,47 @@ Error DevFs::Open(const Path& path, int open_flags, ScopedNode* out_node) {
|
| out_node->reset(NULL);
|
| int error;
|
| if (path.Part(1) == "fs") {
|
| - if (path.Size() == 3)
|
| + if (path.Size() == 3) {
|
| error = fs_dir_->FindChild(path.Part(2), out_node);
|
| - else
|
| + } else {
|
| + LOG_TRACE("Bad devfs path: %s", path.Join().c_str());
|
| error = ENOENT;
|
| + }
|
| } else {
|
| error = root_->FindChild(path.Join(), out_node);
|
| }
|
|
|
| // Only return EACCES when trying to create a node that does not exist.
|
| - if ((error == ENOENT) && (open_flags & O_CREAT))
|
| + if ((error == ENOENT) && (open_flags & O_CREAT)) {
|
| + LOG_TRACE("Cannot create devfs node: %s", path.Join().c_str());
|
| return EACCES;
|
| + }
|
|
|
| return error;
|
| }
|
|
|
| Error DevFs::Unlink(const Path& path) {
|
| + LOG_ERROR("unlink not supported.");
|
| return EPERM;
|
| }
|
|
|
| Error DevFs::Mkdir(const Path& path, int permissions) {
|
| + LOG_ERROR("mkdir not supported.");
|
| return EPERM;
|
| }
|
|
|
| Error DevFs::Rmdir(const Path& path) {
|
| + LOG_ERROR("rmdir not supported.");
|
| return EPERM;
|
| }
|
|
|
| Error DevFs::Remove(const Path& path) {
|
| + LOG_ERROR("remove not supported.");
|
| return EPERM;
|
| }
|
|
|
| Error DevFs::Rename(const Path& path, const Path& newpath) {
|
| + LOG_ERROR("rename not supported.");
|
| return EPERM;
|
| }
|
|
|
|
|