OLD | NEW |
---|---|
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 <fcntl.h> | 8 #include <fcntl.h> |
9 #include <pthread.h> | 9 #include <pthread.h> |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... | |
22 | 22 |
23 KernelHandle::KernelHandle(const ScopedMount& mnt, const ScopedMountNode& node) | 23 KernelHandle::KernelHandle(const ScopedMount& mnt, const ScopedMountNode& node) |
24 : mount_(mnt), node_(node), offs_(0) {} | 24 : mount_(mnt), node_(node), offs_(0) {} |
25 | 25 |
26 KernelHandle::~KernelHandle() { | 26 KernelHandle::~KernelHandle() { |
27 // Force release order for cases where mount_ is not ref'd by mounting. | 27 // Force release order for cases where mount_ is not ref'd by mounting. |
28 node_.reset(NULL); | 28 node_.reset(NULL); |
29 mount_.reset(NULL); | 29 mount_.reset(NULL); |
30 } | 30 } |
31 | 31 |
32 // Returns the MountNodeSocket* if this node is a socket. | |
33 MountNodeSocket* KernelHandle::socket_node() { | |
34 if (node_.get() && node_->IsaSock()) | |
35 return reinterpret_cast<MountNodeSocket*>(node_.get()); | |
binji
2013/08/09 23:08:27
static_cast
| |
36 return NULL; | |
37 } | |
38 | |
32 Error KernelHandle::Init(int open_mode) { | 39 Error KernelHandle::Init(int open_mode) { |
33 if (open_mode & O_APPEND) { | 40 if (open_mode & O_APPEND) { |
34 Error error = node_->GetSize(&offs_); | 41 Error error = node_->GetSize(&offs_); |
35 if (error) | 42 if (error) |
36 return error; | 43 return error; |
37 } | 44 } |
38 | 45 |
39 return 0; | 46 return 0; |
40 } | 47 } |
41 | 48 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
99 | 106 |
100 Error KernelHandle::GetDents(struct dirent* pdir, size_t nbytes, int* cnt) { | 107 Error KernelHandle::GetDents(struct dirent* pdir, size_t nbytes, int* cnt) { |
101 AUTO_LOCK(offs_lock_); | 108 AUTO_LOCK(offs_lock_); |
102 Error error = node_->GetDents(offs_, pdir, nbytes, cnt); | 109 Error error = node_->GetDents(offs_, pdir, nbytes, cnt); |
103 if (0 == error) | 110 if (0 == error) |
104 offs_ += *cnt; | 111 offs_ += *cnt; |
105 return error; | 112 return error; |
106 } | 113 } |
107 | 114 |
108 } // namespace nacl_io | 115 } // namespace nacl_io |
OLD | NEW |