Chromium Code Reviews| Index: native_client_sdk/src/libraries/nacl_mounts/mount_mem.h |
| =================================================================== |
| --- native_client_sdk/src/libraries/nacl_mounts/mount_mem.h (revision 131457) |
| +++ native_client_sdk/src/libraries/nacl_mounts/mount_mem.h (working copy) |
| @@ -10,55 +10,42 @@ |
| #include <string> |
| #include "mount.h" |
| -#include "util/macros.h" |
| -#include "util/SlotAllocator.h" |
| -struct dirent; |
| -struct stat; |
| - |
| -class MountMemNode; |
| - |
| -// Mount serves as the base mounting class that will be used by |
| -// the mount manager (class MountManager). The mount manager |
| -// relies heavily on the GetNode method as a way of directing |
| -// system calls that take a path as an argument. The methods |
| -// of this class are pure virtual. BaseMount class contains |
| -// stub implementations for these methods. Feel free to use |
| -// BaseMount if your mount does not implement all of these |
| -// operations. |
| class MountMem : public Mount { |
| protected: |
| - MountMem(); |
| - virtual ~MountMem(); |
| + MountMem(int dev); |
|
binji
2012/04/16 22:43:05
explicit
noelallen1
2012/04/21 18:09:53
Done globally
|
| - // Init must be called by the factory before |
| - void Init(); |
| + virtual bool Init(const std::string& args); |
| + virtual void Destroy(); |
| - int MountMem::AddDirEntry(MountNode* node, MountNode* node, const char *name); |
| + // Allocata a node assigning it's first reference to the passed in |
|
binji
2012/04/16 22:43:05
Spelling: "Allocate" "its"
noelallen1
2012/04/21 18:09:53
Done.
|
| + // MountNodePtr_t object returnning true, or return false if the node |
| + // failes to initialize. |
| + virtual MountNode *AllocateData(int mode); |
| + virtual MountNode *AllocatePath(int mode); |
| + virtual void ReleaseNode(MountNode *node); |
| - public: |
| - // System calls that can be overridden by a mount implementation |
| - virtual int Creat(const std::string& path, int mode, struct stat *st); |
| - virtual int Mkdir(const std::string& path, int mode, struct stat *st); |
| - virtual int Unlink(const std::string& path); |
| + // Allocate or free an INODE number. |
| + int AllocateINO(); |
| + void FreeINO(int ino); |
| - virtual int Rmdir(int node); |
| - virtual int Chmod(int node, int mode); |
| - virtual int Stat(int node, struct stat *buf); |
| - virtual int Fsync(int node); |
| + // Find a Node specified node optionally failing if type does not match. |
| + virtual MountNode* FindNode(const Path& path, int type = 0); |
| - virtual int Getdents(int node, off_t offset, struct dirent *dirp, |
| - unsigned int count); |
| + public: |
| + typedef std::vector<ino_t> INOList_t; |
| - virtual ssize_t Read(int node, off_t offset, |
| - void *buf, size_t count); |
| - virtual ssize_t Write(int node, off_t offset, |
| - const void *buf, size_t count); |
| - virtual int Isatty(int node); |
| + virtual MountNode *Open(const Path& path, int mode); |
| + virtual int Close(MountNode* node); |
| + virtual int Unlink(const Path& path); |
| + virtual int Mkdir(const Path& path, int perm); |
| + virtual int Rmdir(const Path& path); |
| - private: |
| - pthread_mutex_t lock_; |
| - SlotAllocator<MountMemNode> inodes_; |
| +private: |
| + MountNode* root_; |
| + INOList_t inos_; |
| + size_t max_ino_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(MountMem); |
| }; |