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

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

Issue 12194030: Rename mount (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix whitespace Created 7 years, 10 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
(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 #ifndef LIBRARIES_NACL_MOUNTS_MOUNT_H_
6 #define LIBRARIES_NACL_MOUNTS_MOUNT_H_
7
8 #include <map>
9 #include <string>
10
11 #include "nacl_mounts/inode_pool.h"
12 #include "nacl_mounts/mount_node.h"
13 #include "nacl_mounts/path.h"
14 #include "utils/macros.h"
15 #include "utils/ref_object.h"
16
17 class MountNode;
18 class PepperInterface;
19
20 typedef std::map<std::string, std::string> StringMap_t;
21
22
23 class Mount : public RefObject {
24 protected:
25 // The protected functions are only used internally and will not
26 // acquire or release the mount's lock.
27 Mount();
28 virtual ~Mount();
29
30 // Init must be called by the factory before the mount is used.
31 // This function must assign a root node, or replace FindNode.
32 // |ppapi| can be NULL. If so, this mount cannot make any pepper calls.
33 virtual bool Init(int dev, StringMap_t& args, PepperInterface* ppapi);
34 virtual void Destroy();
35
36 public:
37 template <class M>
38 static Mount* Create(int dev, StringMap_t& args, PepperInterface* ppapi);
39
40 PepperInterface* ppapi() { return ppapi_; }
41
42 // All paths are expected to containing a leading "/"
43 void AcquireNode(MountNode* node);
44 void ReleaseNode(MountNode* node);
45
46 // Open a node at |path| with the specified open flags. The resulting
47 // MountNode is created with a ref count of 1.
48 virtual MountNode *Open(const Path& path, int o_flags) = 0;
49
50 // Unlink, Mkdir, Rmdir will affect the both the RefCount
51 // and the nlink number in the stat object.
52 virtual int Unlink(const Path& path) = 0;
53 virtual int Mkdir(const Path& path, int permissions) = 0;
54 virtual int Rmdir(const Path& path) = 0;
55 virtual int Remove(const Path& path) = 0;
56
57 // Convert from R,W,R/W open flags to STAT permission flags
58 static int OpenModeToPermission(int mode);
59
60 void OnNodeCreated(MountNode* node) ;
61 void OnNodeDestroyed(MountNode* node);
62
63 protected:
64 // Device number for the mount.
65 int dev_;
66 PepperInterface* ppapi_; // Weak reference.
67 INodePool inode_pool_;
68
69 private:
70 // May only be called by the KernelProxy when the Kernel's
71 // lock is held, so we make it private.
72 friend class KernelObject;
73 friend class KernelProxy;
74 void Acquire() { RefObject::Acquire(); }
75 bool Release() { return RefObject::Release(); }
76
77 DISALLOW_COPY_AND_ASSIGN(Mount);
78 };
79
80
81 template <class M>
82 /*static*/
83 Mount* Mount::Create(int dev, StringMap_t& args, PepperInterface* ppapi) {
84 Mount* mnt = new M();
85 if (mnt->Init(dev, args, ppapi) == false) {
86 delete mnt;
87 return NULL;
88 }
89 return mnt;
90 }
91
92 #endif // LIBRARIES_NACL_MOUNTS_MOUNT_H_
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