Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / native_client_sdk / src / libraries / nacl_io / kernel_handle.cc
index 5c5bcc1..4f88bbf 100644 (file)
@@ -40,10 +40,15 @@ SocketNode* KernelHandle::socket_node() {
 Error KernelHandle::Init(int open_flags) {
   handle_attr_.flags = open_flags;
 
-  if (!node_->CanOpen(open_flags)) {
+  if ((open_flags & O_CREAT) == 0 && !node_->CanOpen(open_flags)) {
     return EACCES;
   }
 
+  // Directories can only be opened read-only.
+  if ((open_flags & 3) != O_RDONLY && node_->IsaDir()) {
+    return EISDIR;
+  }
+
   if (open_flags & O_APPEND) {
     Error error = node_->GetSize(&handle_attr_.offs);
     if (error)