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

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

Issue 9956156: Add mount sources for a MountNode (inode) (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 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
« no previous file with comments | « no previous file | native_client_sdk/src/libraries/nacl_mounts/mount_mem.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_MEM_H_ 5 #ifndef LIBRARIES_NACL_MOUNTS_MOUNT_MEM_H_
6 #define LIBRARIES_NACL_MOUNTS_MOUNT_MEM_H_ 6 #define LIBRARIES_NACL_MOUNTS_MOUNT_MEM_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 11
12 #include "mount.h" 12 #include "nacl_mounts/mount.h"
13 #include "util/macros.h"
14 #include "util/SlotAllocator.h"
15 13
16 struct dirent;
17 struct stat;
18 14
19 class MountMemNode; 15 class MountMem : public MountFactory<MountMem, Mount> {
20
21 // Mount serves as the base mounting class that will be used by
22 // the mount manager (class MountManager). The mount manager
23 // relies heavily on the GetNode method as a way of directing
24 // system calls that take a path as an argument. The methods
25 // of this class are pure virtual. BaseMount class contains
26 // stub implementations for these methods. Feel free to use
27 // BaseMount if your mount does not implement all of these
28 // operations.
29 class MountMem : public Mount {
30 protected: 16 protected:
31 MountMem(); 17 MountMem();
32 virtual ~MountMem();
33 18
34 // Init must be called by the factory before 19 virtual bool Init(int dev, StringMap_t& args);
35 void Init(); 20 virtual void Destroy();
36 21
37 int MountMem::AddDirEntry(MountNode* node, MountNode* node, const char *name); 22 // The protected functions are only used internally and will not
23 // acquire or release the mount's lock themselves. The caller is
24 // returned to use correct locking as needed.
25 virtual MountNode *AllocateData(int mode);
26 virtual MountNode *AllocatePath(int mode);
27 virtual void ReleaseNode(MountNode *node);
28
29 // Allocate or free an INODE number.
30 int AllocateINO();
31 void FreeINO(int ino);
32
33 // Find a Node specified node optionally failing if type does not match.
34 virtual MountNode* FindNode(const Path& path, int type = 0);
38 35
39 public: 36 public:
40 // System calls that can be overridden by a mount implementation 37 typedef std::vector<ino_t> INOList_t;
41 virtual int Creat(const std::string& path, int mode, struct stat *st);
42 virtual int Mkdir(const std::string& path, int mode, struct stat *st);
43 virtual int Unlink(const std::string& path);
44 38
45 virtual int Rmdir(int node); 39 virtual MountNode *Open(const Path& path, int mode);
46 virtual int Chmod(int node, int mode); 40 virtual int Close(MountNode* node);
47 virtual int Stat(int node, struct stat *buf); 41 virtual int Unlink(const Path& path);
48 virtual int Fsync(int node); 42 virtual int Mkdir(const Path& path, int perm);
43 virtual int Rmdir(const Path& path);
49 44
50 virtual int Getdents(int node, off_t offset, struct dirent *dirp, 45 private:
51 unsigned int count); 46 MountNode* root_;
47 INOList_t inos_;
48 size_t max_ino_;
52 49
53 virtual ssize_t Read(int node, off_t offset, 50 template <class M, class P> friend class MountFactory;
54 void *buf, size_t count);
55 virtual ssize_t Write(int node, off_t offset,
56 const void *buf, size_t count);
57 virtual int Isatty(int node);
58
59 private:
60 pthread_mutex_t lock_;
61 SlotAllocator<MountMemNode> inodes_;
62 DISALLOW_COPY_AND_ASSIGN(MountMem); 51 DISALLOW_COPY_AND_ASSIGN(MountMem);
63 }; 52 };
64 53
65 #endif // LIBRARIES_NACL_MOUNTS_MOUNT_MEM_H_ 54 #endif // LIBRARIES_NACL_MOUNTS_MOUNT_MEM_H_
66 55
OLDNEW
« no previous file with comments | « no previous file | native_client_sdk/src/libraries/nacl_mounts/mount_mem.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698