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

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

Issue 671513002: [NaCk SDK] nacl_io: Don't assume ~S_IFMT are the mode bits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix_umask
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
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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 182
183 Error Node::Fchmod(mode_t mode) { 183 Error Node::Fchmod(mode_t mode) {
184 return EINVAL; 184 return EINVAL;
185 } 185 }
186 186
187 int Node::GetLinks() { 187 int Node::GetLinks() {
188 return stat_.st_nlink; 188 return stat_.st_nlink;
189 } 189 }
190 190
191 int Node::GetMode() { 191 int Node::GetMode() {
192 return stat_.st_mode & ~S_IFMT; 192 return stat_.st_mode & S_MODEBITS;
193 } 193 }
194 194
195 Error Node::GetSize(off_t* out_size) { 195 Error Node::GetSize(off_t* out_size) {
196 *out_size = stat_.st_size; 196 *out_size = stat_.st_size;
197 return 0; 197 return 0;
198 } 198 }
199 199
200 int Node::GetType() { 200 int Node::GetType() {
201 return stat_.st_mode & S_IFMT; 201 return stat_.st_mode & S_IFMT;
202 } 202 }
203 203
204 void Node::SetType(int type) { 204 void Node::SetType(int type) {
205 assert((type & ~S_IFMT) == 0); 205 assert((type & ~S_IFMT) == 0);
206 stat_.st_mode &= ~S_IFMT; 206 stat_.st_mode &= ~S_IFMT;
207 stat_.st_mode |= type; 207 stat_.st_mode |= type;
208 } 208 }
209 209
210 void Node::SetMode(int mode) { 210 void Node::SetMode(int mode) {
211 assert((mode & S_IFMT) == 0); 211 assert((mode & ~S_MODEBITS) == 0);
212 stat_.st_mode &= S_IFMT; 212 stat_.st_mode &= ~S_MODEBITS;
213 stat_.st_mode |= mode; 213 stat_.st_mode |= mode;
214 } 214 }
215 215
216 bool Node::IsaDir() { 216 bool Node::IsaDir() {
217 return GetType() == S_IFDIR; 217 return GetType() == S_IFDIR;
218 } 218 }
219 219
220 bool Node::IsaFile() { 220 bool Node::IsaFile() {
221 return GetType() == S_IFREG; 221 return GetType() == S_IFREG;
222 } 222 }
(...skipping 25 matching lines...) Expand all
248 248
249 void Node::Link() { 249 void Node::Link() {
250 stat_.st_nlink++; 250 stat_.st_nlink++;
251 } 251 }
252 252
253 void Node::Unlink() { 253 void Node::Unlink() {
254 stat_.st_nlink--; 254 stat_.st_nlink--;
255 } 255 }
256 256
257 } // namespace nacl_io 257 } // namespace nacl_io
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/node.h ('k') | native_client_sdk/src/tests/nacl_io_test/fuse_fs_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698