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..e16c0c7d173630bfa654d763632b7147079b6892 100644 |
--- a/native_client_sdk/src/libraries/nacl_io/dir_node.cc |
+++ b/native_client_sdk/src/libraries/nacl_io/dir_node.cc |
@@ -7,7 +7,9 @@ |
#include <errno.h> |
#include <string.h> |
+#include "nacl_io/log.h" |
#include "nacl_io/osdirent.h" |
+#include "nacl_io/osinttypes.h" |
#include "nacl_io/osstat.h" |
#include "sdk_util/auto_lock.h" |
#include "sdk_util/macros.h" |
@@ -40,10 +42,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 +56,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 +72,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: %" PRIuS " >= %" PRIuS, |
+ 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; |