| Index: native_client_sdk/src/libraries/nacl_io/dir_node.cc
|
| diff --git a/native_client_sdk/src/libraries/nacl_io/dir_node.cc b/native_client_sdk/src/libraries/nacl_io/dir_node.cc
|
| index 0486198cc70b3ee25b0a85bd523c7925ac3cac8e..1b1fe15c9c74382799ca27707c449d9ef3de6cab 100644
|
| --- a/native_client_sdk/src/libraries/nacl_io/dir_node.cc
|
| +++ b/native_client_sdk/src/libraries/nacl_io/dir_node.cc
|
| @@ -7,6 +7,7 @@
|
| #include <errno.h>
|
| #include <string.h>
|
|
|
| +#include "nacl_io/log.h"
|
| #include "nacl_io/osdirent.h"
|
| #include "nacl_io/osstat.h"
|
| #include "sdk_util/auto_lock.h"
|
| @@ -40,10 +41,12 @@ Error DirNode::Read(const HandleAttr& attr,
|
| size_t count,
|
| int* out_bytes) {
|
| *out_bytes = 0;
|
| + LOG_TRACE("Can't read a directory.");
|
| return EISDIR;
|
| }
|
|
|
| Error DirNode::FTruncate(off_t size) {
|
| + LOG_TRACE("Can't truncate a directory.");
|
| return EISDIR;
|
| }
|
|
|
| @@ -52,6 +55,7 @@ Error DirNode::Write(const HandleAttr& attr,
|
| size_t count,
|
| int* out_bytes) {
|
| *out_bytes = 0;
|
| + LOG_TRACE("Can't write to a directory.");
|
| return EISDIR;
|
| }
|
|
|
| @@ -67,15 +71,23 @@ Error DirNode::GetDents(size_t offs,
|
| Error DirNode::AddChild(const std::string& name, const ScopedNode& node) {
|
| AUTO_LOCK(node_lock_);
|
|
|
| - if (name.empty())
|
| + if (name.empty()) {
|
| + LOG_ERROR("Can't add child with no name.");
|
| return ENOENT;
|
| + }
|
|
|
| - if (name.length() >= MEMBER_SIZE(dirent, d_name))
|
| + if (name.length() >= MEMBER_SIZE(dirent, d_name)) {
|
| + LOG_ERROR("Child name is too long: %d >= %d",
|
| + name.length(),
|
| + MEMBER_SIZE(dirent, d_name));
|
| return ENAMETOOLONG;
|
| + }
|
|
|
| NodeMap_t::iterator it = map_.find(name);
|
| - if (it != map_.end())
|
| + if (it != map_.end()) {
|
| + LOG_TRACE("Can't add child \"%s\", it already exists.", name);
|
| return EEXIST;
|
| + }
|
|
|
| node->Link();
|
| map_[name] = node;
|
|
|