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

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

Issue 13106002: [NaCl SDK] A bunch of spelling fixes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix presubmit Created 7 years, 8 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 (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/mount_mem.h" 5 #include "nacl_io/mount_mem.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <string> 9 #include <string>
10 10
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 MountNode* node = FindNode(path); 108 MountNode* node = FindNode(path);
109 109
110 if (NULL == node) { 110 if (NULL == node) {
111 // Now first find the parent directory to see if we can add it 111 // Now first find the parent directory to see if we can add it
112 MountNode* parent = FindNode(path.Parent(), S_IFDIR); 112 MountNode* parent = FindNode(path.Parent(), S_IFDIR);
113 if (NULL == parent) return NULL; 113 if (NULL == parent) return NULL;
114 114
115 // If the node does not exist and we can't create it, fail 115 // If the node does not exist and we can't create it, fail
116 if ((mode & O_CREAT) == 0) return NULL; 116 if ((mode & O_CREAT) == 0) return NULL;
117 117
118 // Otherwise, create it with a single refernece 118 // Otherwise, create it with a single reference
119 mode = OpenModeToPermission(mode); 119 mode = OpenModeToPermission(mode);
120 node = AllocateData(mode); 120 node = AllocateData(mode);
121 if (NULL == node) return NULL; 121 if (NULL == node) return NULL;
122 122
123 if (parent->AddChild(path.Basename(), node) == -1) { 123 if (parent->AddChild(path.Basename(), node) == -1) {
124 // Or if it fails, release it 124 // Or if it fails, release it
125 node->Release(); 125 node->Release();
126 return NULL; 126 return NULL;
127 } 127 }
128 return node; 128 return node;
129 } 129 }
130 130
131 // If we were expected to create it exclusively, fail 131 // If we were expected to create it exclusively, fail
132 if (mode & O_EXCL) { 132 if (mode & O_EXCL) {
133 errno = EEXIST; 133 errno = EEXIST;
134 return NULL; 134 return NULL;
135 } 135 }
136 136
137 // Verify we got the requested permisions. 137 // Verify we got the requested permissions.
138 int req_mode = OpenModeToPermission(mode); 138 int req_mode = OpenModeToPermission(mode);
139 int obj_mode = node->GetMode() & OpenModeToPermission(O_RDWR); 139 int obj_mode = node->GetMode() & OpenModeToPermission(O_RDWR);
140 if ((obj_mode & req_mode) != req_mode) { 140 if ((obj_mode & req_mode) != req_mode) {
141 errno = EACCES; 141 errno = EACCES;
142 return NULL; 142 return NULL;
143 } 143 }
144 144
145 // We opened it, so ref count it before passing it back. 145 // We opened it, so ref count it before passing it back.
146 node->Acquire(); 146 node->Acquire();
147 return node; 147 return node;
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 if (file_only && child->IsaDir()) { 242 if (file_only && child->IsaDir()) {
243 errno = EISDIR; 243 errno = EISDIR;
244 return -1; 244 return -1;
245 } 245 }
246 if (remove_dir && child->ChildCount() > 0) { 246 if (remove_dir && child->ChildCount() > 0) {
247 errno = ENOTEMPTY; 247 errno = ENOTEMPTY;
248 return -1; 248 return -1;
249 } 249 }
250 return parent->RemoveChild(path.Basename()); 250 return parent->RemoveChild(path.Basename());
251 } 251 }
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/kernel_object.cc ('k') | native_client_sdk/src/libraries/nacl_io/path.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698