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

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

Issue 16232016: [NaCl SDK] nacl_io: big refactor to return error value (errno). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge master, fix windows Created 7 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 (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.h" 5 #include "nacl_io/mount.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
11 #include "nacl_io/mount_node.h" 11 #include "nacl_io/mount_node.h"
12 #include "nacl_io/mount_node_dir.h" 12 #include "nacl_io/mount_node_dir.h"
13 #include "nacl_io/mount_node_mem.h" 13 #include "nacl_io/mount_node_mem.h"
14 #include "nacl_io/osstat.h" 14 #include "nacl_io/osstat.h"
15 #include "nacl_io/path.h" 15 #include "nacl_io/path.h"
16 #include "sdk_util/auto_lock.h" 16 #include "sdk_util/auto_lock.h"
17 #include "sdk_util/ref_object.h" 17 #include "sdk_util/ref_object.h"
18 18
19 #if defined(WIN32) 19 #if defined(WIN32)
20 #include <windows.h> 20 #include <windows.h>
21 #endif 21 #endif
22 22
23 Mount::Mount() 23 Mount::Mount() : dev_(0) {}
24 : dev_(0) {
25 }
26 24
27 Mount::~Mount() {} 25 Mount::~Mount() {}
28 26
29 bool Mount::Init(int dev, StringMap_t& args, PepperInterface* ppapi) { 27 Error Mount::Init(int dev, StringMap_t& args, PepperInterface* ppapi) {
30 dev_ = dev; 28 dev_ = dev;
31 ppapi_ = ppapi; 29 ppapi_ = ppapi;
32 return true; 30 return 0;
33 } 31 }
34 32
35 void Mount::Destroy() {} 33 void Mount::Destroy() {}
36 34
37 void Mount::AcquireNode(MountNode* node) { 35 void Mount::AcquireNode(MountNode* node) {
38 AutoLock lock(&lock_); 36 AutoLock lock(&lock_);
39 node->Acquire(); 37 node->Acquire();
40 } 38 }
41 39
42 void Mount::ReleaseNode(MountNode* node) { 40 void Mount::ReleaseNode(MountNode* node) {
43 AutoLock lock(&lock_); 41 AutoLock lock(&lock_);
44 node->Release(); 42 node->Release();
45 } 43 }
46 44
45 Error Mount::OpenResource(const Path& path, MountNode** out_node) {
46 *out_node = NULL;
47 return EINVAL;
48 }
49
47 int Mount::OpenModeToPermission(int mode) { 50 int Mount::OpenModeToPermission(int mode) {
48 int out; 51 int out;
49 switch (mode & 3) { 52 switch (mode & 3) {
50 case O_RDONLY: out = S_IREAD; 53 case O_RDONLY:
51 case O_WRONLY: out = S_IWRITE; 54 out = S_IREAD;
52 case O_RDWR: out = S_IREAD | S_IWRITE; 55 case O_WRONLY:
56 out = S_IWRITE;
57 case O_RDWR:
58 out = S_IREAD | S_IWRITE;
53 } 59 }
54 return out; 60 return out;
55 } 61 }
56 62
57
58 void Mount::OnNodeCreated(MountNode* node) { 63 void Mount::OnNodeCreated(MountNode* node) {
59 node->stat_.st_ino = inode_pool_.Acquire(); 64 node->stat_.st_ino = inode_pool_.Acquire();
60 node->stat_.st_dev = dev_; 65 node->stat_.st_dev = dev_;
61 } 66 }
62 67
63 void Mount::OnNodeDestroyed(MountNode* node) { 68 void Mount::OnNodeDestroyed(MountNode* node) {
64 if (node->stat_.st_ino) inode_pool_.Release(node->stat_.st_ino); 69 if (node->stat_.st_ino)
70 inode_pool_.Release(node->stat_.st_ino);
65 } 71 }
66
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/mount.h ('k') | native_client_sdk/src/libraries/nacl_io/mount_dev.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698