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

Side by Side Diff: native_client_sdk/src/libraries/nacl_io/kernel_handle.cc

Issue 660353003: [NaCl SDK] nacl_io: Fix utime() on directories. (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 unified diff | Download patch
« no previous file with comments | « no previous file | native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "nacl_io/kernel_handle.h" 5 #include "nacl_io/kernel_handle.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <pthread.h> 8 #include <pthread.h>
9 9
10 #include "nacl_io/filesystem.h" 10 #include "nacl_io/filesystem.h"
(...skipping 26 matching lines...) Expand all
37 return NULL; 37 return NULL;
38 } 38 }
39 39
40 Error KernelHandle::Init(int open_flags) { 40 Error KernelHandle::Init(int open_flags) {
41 handle_attr_.flags = open_flags; 41 handle_attr_.flags = open_flags;
42 42
43 if ((open_flags & O_CREAT) == 0 && !node_->CanOpen(open_flags)) { 43 if ((open_flags & O_CREAT) == 0 && !node_->CanOpen(open_flags)) {
44 return EACCES; 44 return EACCES;
45 } 45 }
46 46
47 // Directories can only be opened read-only.
48 if ((open_flags & 3) != O_RDONLY && node_->IsaDir()) {
49 return EISDIR;
50 }
51
47 if (open_flags & O_APPEND) { 52 if (open_flags & O_APPEND) {
48 Error error = node_->GetSize(&handle_attr_.offs); 53 Error error = node_->GetSize(&handle_attr_.offs);
49 if (error) 54 if (error)
50 return error; 55 return error;
51 } 56 }
52 57
53 return 0; 58 return 0;
54 } 59 }
55 60
56 Error KernelHandle::Seek(off_t offset, int whence, off_t* out_offset) { 61 Error KernelHandle::Seek(off_t offset, int whence, off_t* out_offset) {
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 return ENOTSOCK; 233 return ENOTSOCK;
229 if (OpenMode() == O_RDONLY) 234 if (OpenMode() == O_RDONLY)
230 return EACCES; 235 return EACCES;
231 236
232 AUTO_LOCK(handle_lock_); 237 AUTO_LOCK(handle_lock_);
233 return sock->SendTo(handle_attr_, buf, len, flags, dest_addr, addrlen, 238 return sock->SendTo(handle_attr_, buf, len, flags, dest_addr, addrlen,
234 out_len); 239 out_len);
235 } 240 }
236 241
237 } // namespace nacl_io 242 } // namespace nacl_io
OLDNEW
« no previous file with comments | « no previous file | native_client_sdk/src/libraries/nacl_io/kernel_proxy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698