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

Side by Side Diff: native_client_sdk/src/libraries/nacl_mounts/mount.h

Issue 10829027: [NaCl SDK] Add nacl_mounts to NaCl SDK build. Experimental for now. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync again Created 8 years, 4 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 #ifndef LIBRARIES_NACL_MOUNTS_MOUNT_H_ 5 #ifndef LIBRARIES_NACL_MOUNTS_MOUNT_H_
6 #define LIBRARIES_NACL_MOUNTS_MOUNT_H_ 6 #define LIBRARIES_NACL_MOUNTS_MOUNT_H_
7 7
8 #include <stdint.h>
9 #include <map> 8 #include <map>
10 #include <string> 9 #include <string>
11 10
12 #include "macros.h"
13 #include "ref_object.h"
14
15 #include "nacl_mounts/mount_node.h" 11 #include "nacl_mounts/mount_node.h"
16 #include "nacl_mounts/path.h" 12 #include "nacl_mounts/path.h"
17 13 #include "utils/macros.h"
18 struct dirent; 14 #include "utils/ref_object.h"
19 struct stat;
20 15
21 class MountNode; 16 class MountNode;
22 class MountManager; 17 class MountManager;
23 18
24 typedef std::map<std::string, std::string> StringMap_t; 19 typedef std::map<std::string, std::string> StringMap_t;
25 20
26 template<class C, class P> class MountFactory : public P {
27 protected:
28 MountFactory()
29 : P() {}
30
31 static Mount* Create(int dev, StringMap_t& args) {
32 Mount* mnt = new C();
33 if (mnt->Init(dev, args) == false) {
34 delete mnt;
35 return NULL;
36 }
37 return mnt;
38 }
39
40 friend class KernelProxy;
41 };
42
43
44 21
45 // Mount serves as the base mounting class that will be used by 22 // Mount serves as the base mounting class that will be used by
46 // the mount manager (class MountManager). The mount manager 23 // the mount manager (class MountManager). The mount manager
47 // relies heavily on the GetNode method as a way of directing 24 // relies heavily on the GetNode method as a way of directing
48 // system calls that take a path as an argument. The methods 25 // system calls that take a path as an argument. The methods
49 // of this class are pure virtual. BaseMount class contains 26 // of this class are pure virtual. BaseMount class contains
50 // stub implementations for these methods. Feel free to use 27 // stub implementations for these methods. Feel free to use
51 // BaseMount if your mount does not implement all of these 28 // BaseMount if your mount does not implement all of these
52 // operations. 29 // operations.
53 class Mount : public RefObject { 30 class Mount : public RefObject {
(...skipping 28 matching lines...) Expand all
82 virtual int Rmdir(const Path& path) = 0; 59 virtual int Rmdir(const Path& path) = 0;
83 60
84 // Convert from R,W,R/W open flags to STAT permission flags 61 // Convert from R,W,R/W open flags to STAT permission flags
85 static int OpenModeToPermission(int mode); 62 static int OpenModeToPermission(int mode);
86 63
87 protected: 64 protected:
88 // Device number for the mount. 65 // Device number for the mount.
89 int dev_; 66 int dev_;
90 67
91 private: 68 private:
92 // May only be called by the KernelProxy when the Kernel's 69 // May only be called by the KernelProxy when the Kernel's
93 // lock is held, so we make it private. 70 // lock is held, so we make it private.
94 friend class KernelObject; 71 friend class KernelObject;
95 friend class KernelProxy; 72 friend class KernelProxy;
96 void Acquire() { RefObject::Acquire(); } 73 void Acquire() { RefObject::Acquire(); }
97 bool Release() { return RefObject::Release(); } 74 void Release() { RefObject::Release(); }
98 75
99 template <class M, class P> friend class MountFactory; 76 template <class M, class P> friend class MountFactory;
100 DISALLOW_COPY_AND_ASSIGN(Mount); 77 DISALLOW_COPY_AND_ASSIGN(Mount);
101 }; 78 };
102 79
103 80
81 template<class C, class P> class MountFactory : public P {
82 protected:
83 MountFactory()
84 : P() {}
85
86 static Mount* Create(int dev, StringMap_t& args) {
87 Mount* mnt = new C();
88 if (mnt->Init(dev, args) == false) {
89 delete mnt;
90 return NULL;
91 }
92 return mnt;
93 }
94
95 friend class KernelProxy;
96 };
97
104 #endif // LIBRARIES_NACL_MOUNTS_MOUNT_H_ 98 #endif // LIBRARIES_NACL_MOUNTS_MOUNT_H_
105
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/nacl_mounts/library.dsc ('k') | native_client_sdk/src/libraries/nacl_mounts/mount.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698