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

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

Issue 303223007: [NaCl SDK] nacl_io: Run clang-format over nacl_io sources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/node.h" 5 #include "nacl_io/node.h"
6 6
7 #include <assert.h> 7 #include <assert.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <poll.h> 10 #include <poll.h>
(...skipping 21 matching lines...) Expand all
32 stat_.st_mode = S_IRALL | S_IWALL; 32 stat_.st_mode = S_IRALL | S_IWALL;
33 33
34 // Filesystem should normally never be NULL, but may be null in tests. 34 // Filesystem should normally never be NULL, but may be null in tests.
35 // If NULL, at least set the inode to a valid (nonzero) value. 35 // If NULL, at least set the inode to a valid (nonzero) value.
36 if (filesystem_) 36 if (filesystem_)
37 filesystem_->OnNodeCreated(this); 37 filesystem_->OnNodeCreated(this);
38 else 38 else
39 stat_.st_ino = 1; 39 stat_.st_ino = 1;
40 } 40 }
41 41
42 Node::~Node() {} 42 Node::~Node() {
43 }
43 44
44 Error Node::Init(int open_flags) { return 0; } 45 Error Node::Init(int open_flags) {
46 return 0;
47 }
45 48
46 void Node::Destroy() { 49 void Node::Destroy() {
47 if (filesystem_) { 50 if (filesystem_) {
48 filesystem_->OnNodeDestroyed(this); 51 filesystem_->OnNodeDestroyed(this);
49 } 52 }
50 } 53 }
51 54
52 EventEmitter* Node::GetEventEmitter() { return NULL; } 55 EventEmitter* Node::GetEventEmitter() {
56 return NULL;
57 }
53 58
54 uint32_t Node::GetEventStatus() { 59 uint32_t Node::GetEventStatus() {
55 if (GetEventEmitter()) 60 if (GetEventEmitter())
56 return GetEventEmitter()->GetEventStatus(); 61 return GetEventEmitter()->GetEventStatus();
57 62
58 return POLLIN | POLLOUT; 63 return POLLIN | POLLOUT;
59 } 64 }
60 65
61 bool Node::CanOpen(int open_flags) { 66 bool Node::CanOpen(int open_flags) {
62 switch (open_flags & 3) { 67 switch (open_flags & 3) {
63 case O_RDONLY: 68 case O_RDONLY:
64 return (stat_.st_mode & S_IRALL) != 0; 69 return (stat_.st_mode & S_IRALL) != 0;
65 case O_WRONLY: 70 case O_WRONLY:
66 return (stat_.st_mode & S_IWALL) != 0; 71 return (stat_.st_mode & S_IWALL) != 0;
67 case O_RDWR: 72 case O_RDWR:
68 return (stat_.st_mode & S_IRALL) != 0 && (stat_.st_mode & S_IWALL) != 0; 73 return (stat_.st_mode & S_IRALL) != 0 && (stat_.st_mode & S_IWALL) != 0;
69 } 74 }
70 75
71 return false; 76 return false;
72 } 77 }
73 78
74 Error Node::FSync() { return 0; } 79 Error Node::FSync() {
80 return 0;
81 }
75 82
76 Error Node::FTruncate(off_t length) { return EINVAL; } 83 Error Node::FTruncate(off_t length) {
84 return EINVAL;
85 }
77 86
78 Error Node::GetDents(size_t offs, 87 Error Node::GetDents(size_t offs,
79 struct dirent* pdir, 88 struct dirent* pdir,
80 size_t count, 89 size_t count,
81 int* out_bytes) { 90 int* out_bytes) {
82 *out_bytes = 0; 91 *out_bytes = 0;
83 return ENOTDIR; 92 return ENOTDIR;
84 } 93 }
85 94
86 Error Node::GetStat(struct stat* pstat) { 95 Error Node::GetStat(struct stat* pstat) {
87 AUTO_LOCK(node_lock_); 96 AUTO_LOCK(node_lock_);
88 memcpy(pstat, &stat_, sizeof(stat_)); 97 memcpy(pstat, &stat_, sizeof(stat_));
89 return 0; 98 return 0;
90 } 99 }
91 100
92 Error Node::Ioctl(int request, ...) { 101 Error Node::Ioctl(int request, ...) {
93 va_list ap; 102 va_list ap;
94 va_start(ap, request); 103 va_start(ap, request);
95 Error rtn = VIoctl(request, ap); 104 Error rtn = VIoctl(request, ap);
96 va_end(ap); 105 va_end(ap);
97 return rtn; 106 return rtn;
98 } 107 }
99 108
100 Error Node::VIoctl(int request, va_list args) { return EINVAL; } 109 Error Node::VIoctl(int request, va_list args) {
110 return EINVAL;
111 }
101 112
102 Error Node::Read(const HandleAttr& attr, 113 Error Node::Read(const HandleAttr& attr,
103 void* buf, 114 void* buf,
104 size_t count, 115 size_t count,
105 int* out_bytes) { 116 int* out_bytes) {
106 *out_bytes = 0; 117 *out_bytes = 0;
107 return EINVAL; 118 return EINVAL;
108 } 119 }
109 120
110 Error Node::Write(const HandleAttr& attr, 121 Error Node::Write(const HandleAttr& attr,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 Error read_error = Read(data, new_addr, length, &bytes_read); 157 Error read_error = Read(data, new_addr, length, &bytes_read);
147 if (read_error) { 158 if (read_error) {
148 _real_munmap(new_addr, length); 159 _real_munmap(new_addr, length);
149 return read_error; 160 return read_error;
150 } 161 }
151 162
152 *out_addr = new_addr; 163 *out_addr = new_addr;
153 return 0; 164 return 0;
154 } 165 }
155 166
156 Error Node::Tcflush(int queue_selector) { return EINVAL; } 167 Error Node::Tcflush(int queue_selector) {
168 return EINVAL;
169 }
157 170
158 Error Node::Tcgetattr(struct termios* termios_p) { return EINVAL; } 171 Error Node::Tcgetattr(struct termios* termios_p) {
172 return EINVAL;
173 }
159 174
160 Error Node::Tcsetattr(int optional_actions, const struct termios* termios_p) { 175 Error Node::Tcsetattr(int optional_actions, const struct termios* termios_p) {
161 return EINVAL; 176 return EINVAL;
162 } 177 }
163 178
164 int Node::GetLinks() { return stat_.st_nlink; } 179 int Node::GetLinks() {
180 return stat_.st_nlink;
181 }
165 182
166 int Node::GetMode() { return stat_.st_mode & ~S_IFMT; } 183 int Node::GetMode() {
184 return stat_.st_mode & ~S_IFMT;
185 }
167 186
168 Error Node::GetSize(off_t* out_size) { 187 Error Node::GetSize(off_t* out_size) {
169 *out_size = stat_.st_size; 188 *out_size = stat_.st_size;
170 return 0; 189 return 0;
171 } 190 }
172 191
173 int Node::GetType() { return stat_.st_mode & S_IFMT; } 192 int Node::GetType() {
193 return stat_.st_mode & S_IFMT;
194 }
174 195
175 void Node::SetType(int type) { 196 void Node::SetType(int type) {
176 assert((type & ~S_IFMT) == 0); 197 assert((type & ~S_IFMT) == 0);
177 stat_.st_mode &= ~S_IFMT; 198 stat_.st_mode &= ~S_IFMT;
178 stat_.st_mode |= type; 199 stat_.st_mode |= type;
179 } 200 }
180 201
181 bool Node::IsaDir() { return (stat_.st_mode & S_IFDIR) != 0; } 202 bool Node::IsaDir() {
203 return (stat_.st_mode & S_IFDIR) != 0;
204 }
182 205
183 bool Node::IsaFile() { return (stat_.st_mode & S_IFREG) != 0; } 206 bool Node::IsaFile() {
207 return (stat_.st_mode & S_IFREG) != 0;
208 }
184 209
185 bool Node::IsaSock() { return (stat_.st_mode & S_IFSOCK) != 0; } 210 bool Node::IsaSock() {
211 return (stat_.st_mode & S_IFSOCK) != 0;
212 }
186 213
187 Error Node::Isatty() { 214 Error Node::Isatty() {
188 return ENOTTY; 215 return ENOTTY;
189 } 216 }
190 217
191 Error Node::AddChild(const std::string& name, const ScopedNode& node) { 218 Error Node::AddChild(const std::string& name, const ScopedNode& node) {
192 return ENOTDIR; 219 return ENOTDIR;
193 } 220 }
194 221
195 Error Node::RemoveChild(const std::string& name) { return ENOTDIR; } 222 Error Node::RemoveChild(const std::string& name) {
223 return ENOTDIR;
224 }
196 225
197 Error Node::FindChild(const std::string& name, ScopedNode* out_node) { 226 Error Node::FindChild(const std::string& name, ScopedNode* out_node) {
198 out_node->reset(NULL); 227 out_node->reset(NULL);
199 return ENOTDIR; 228 return ENOTDIR;
200 } 229 }
201 230
202 int Node::ChildCount() { return 0; } 231 int Node::ChildCount() {
232 return 0;
233 }
203 234
204 void Node::Link() { stat_.st_nlink++; } 235 void Node::Link() {
236 stat_.st_nlink++;
237 }
205 238
206 void Node::Unlink() { stat_.st_nlink--; } 239 void Node::Unlink() {
240 stat_.st_nlink--;
241 }
207 242
208 } // namespace nacl_io 243 } // namespace nacl_io
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/nacl_io.cc ('k') | native_client_sdk/src/libraries/nacl_io/ostermios.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698