OLD | NEW |
| (Empty) |
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 | |
3 * found in the LICENSE file. | |
4 */ | |
5 #include "nacl_mounts/mount.h" | |
6 | |
7 #include <errno.h> | |
8 #include <fcntl.h> | |
9 #include <string> | |
10 | |
11 #include "nacl_mounts/mount_node.h" | |
12 #include "nacl_mounts/mount_node_dir.h" | |
13 #include "nacl_mounts/mount_node_mem.h" | |
14 #include "nacl_mounts/osstat.h" | |
15 #include "nacl_mounts/path.h" | |
16 #include "utils/auto_lock.h" | |
17 #include "utils/ref_object.h" | |
18 | |
19 #if defined(WIN32) | |
20 #include <windows.h> | |
21 #endif | |
22 | |
23 Mount::Mount() | |
24 : dev_(0) { | |
25 } | |
26 | |
27 Mount::~Mount() {} | |
28 | |
29 bool Mount::Init(int dev, StringMap_t& args, PepperInterface* ppapi) { | |
30 dev_ = dev; | |
31 ppapi_ = ppapi; | |
32 return true; | |
33 } | |
34 | |
35 void Mount::Destroy() {} | |
36 | |
37 void Mount::AcquireNode(MountNode* node) { | |
38 AutoLock lock(&lock_); | |
39 node->Acquire(); | |
40 } | |
41 | |
42 void Mount::ReleaseNode(MountNode* node) { | |
43 AutoLock lock(&lock_); | |
44 node->Release(); | |
45 } | |
46 | |
47 int Mount::OpenModeToPermission(int mode) { | |
48 int out; | |
49 switch (mode & 3) { | |
50 case O_RDONLY: out = S_IREAD; | |
51 case O_WRONLY: out = S_IWRITE; | |
52 case O_RDWR: out = S_IREAD | S_IWRITE; | |
53 } | |
54 return out; | |
55 } | |
56 | |
57 | |
58 void Mount::OnNodeCreated(MountNode* node) { | |
59 node->stat_.st_ino = inode_pool_.Acquire(); | |
60 node->stat_.st_dev = dev_; | |
61 } | |
62 | |
63 void Mount::OnNodeDestroyed(MountNode* node) { | |
64 if (node->stat_.st_ino) inode_pool_.Release(node->stat_.st_ino); | |
65 } | |
OLD | NEW |