| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_IO_FILESYSTEM_H_ | 5 #ifndef LIBRARIES_NACL_IO_FILESYSTEM_H_ |
| 6 #define LIBRARIES_NACL_IO_FILESYSTEM_H_ | 6 #define LIBRARIES_NACL_IO_FILESYSTEM_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 Filesystem(); | 51 Filesystem(); |
| 52 virtual ~Filesystem(); | 52 virtual ~Filesystem(); |
| 53 | 53 |
| 54 // Init must be called by the factory before the filesystem is used. | 54 // Init must be called by the factory before the filesystem is used. |
| 55 // |ppapi| can be NULL. If so, this filesystem cannot make any pepper calls. | 55 // |ppapi| can be NULL. If so, this filesystem cannot make any pepper calls. |
| 56 virtual Error Init(const FsInitArgs& args); | 56 virtual Error Init(const FsInitArgs& args); |
| 57 virtual void Destroy(); | 57 virtual void Destroy(); |
| 58 | 58 |
| 59 public: | 59 public: |
| 60 PepperInterface* ppapi() { return ppapi_; } | 60 PepperInterface* ppapi() { return ppapi_; } |
| 61 int dev() { return dev_; } |
| 61 | 62 |
| 62 // All paths in functions below are expected to containing a leading "/". | 63 // All paths in functions below are expected to containing a leading "/". |
| 63 | 64 |
| 64 // Test whether a file or directory at a given path can be accessed. | 65 // Test whether a file or directory at a given path can be accessed. |
| 65 // Returns 0 on success, or an appropriate errno value on failure. | 66 // Returns 0 on success, or an appropriate errno value on failure. |
| 66 virtual Error Access(const Path& path, int a_mode) = 0; | 67 virtual Error Access(const Path& path, int a_mode) = 0; |
| 67 | 68 |
| 68 // Open a node at |path| with the specified open flags. The resulting | 69 // Open a node at |path| with the specified open flags. The resulting |
| 69 // Node is created with a ref count of 1. | 70 // Node is created with a ref count of 1. |
| 70 // Assumes that |out_node| is non-NULL. | 71 // Assumes that |out_node| is non-NULL. |
| 71 virtual Error Open(const Path& path, | 72 virtual Error Open(const Path& path, |
| 72 int open_flags, | 73 int open_flags, |
| 73 ScopedNode* out_node) = 0; | 74 ScopedNode* out_node) = 0; |
| 74 | 75 |
| 75 // OpenResource is only used to read files from the NaCl NMF file. No | 76 // OpenResource is only used to read files from the NaCl NMF file. No |
| 76 // filesystem except PassthroughFs should implement it. | 77 // filesystem except PassthroughFs should implement it. |
| 77 // Assumes that |out_node| is non-NULL. | 78 // Assumes that |out_node| is non-NULL. |
| 78 virtual Error OpenResource(const Path& path, ScopedNode* out_node); | 79 virtual Error OpenResource(const Path& path, ScopedNode* out_node); |
| 79 | 80 |
| 80 // Unlink, Mkdir, Rmdir will affect the both the RefCount | 81 // Unlink, Mkdir, Rmdir will affect the both the RefCount |
| 81 // and the nlink number in the stat object. | 82 // and the nlink number in the stat object. |
| 82 virtual Error Unlink(const Path& path) = 0; | 83 virtual Error Unlink(const Path& path) = 0; |
| 83 virtual Error Mkdir(const Path& path, int permissions) = 0; | 84 virtual Error Mkdir(const Path& path, int permissions) = 0; |
| 84 virtual Error Rmdir(const Path& path) = 0; | 85 virtual Error Rmdir(const Path& path) = 0; |
| 85 virtual Error Remove(const Path& path) = 0; | 86 virtual Error Remove(const Path& path) = 0; |
| 86 virtual Error Rename(const Path& path, const Path& newpath) = 0; | 87 virtual Error Rename(const Path& path, const Path& newpath) = 0; |
| 88 virtual Error Filesystem_VIoctl(int request, va_list args); |
| 87 | 89 |
| 88 // Assumes that |node| is non-NULL. | 90 // Assumes that |node| is non-NULL. |
| 89 void OnNodeCreated(Node* node); | 91 void OnNodeCreated(Node* node); |
| 90 | 92 |
| 91 // Assumes that |node| is non-NULL. | 93 // Assumes that |node| is non-NULL. |
| 92 void OnNodeDestroyed(Node* node); | 94 void OnNodeDestroyed(Node* node); |
| 93 | 95 |
| 94 protected: | 96 protected: |
| 95 // Device number for the filesystem. | 97 // Device number for the filesystem. |
| 96 int dev_; | 98 int dev_; |
| 97 PepperInterface* ppapi_; // Weak reference. | 99 PepperInterface* ppapi_; // Weak reference. |
| 98 INodePool inode_pool_; | 100 INodePool inode_pool_; |
| 99 | 101 |
| 100 private: | 102 private: |
| 101 // May only be called by the KernelProxy when the Kernel's | 103 // May only be called by the KernelProxy when the Kernel's |
| 102 // lock is held, so we make it private. | 104 // lock is held, so we make it private. |
| 103 friend class KernelObject; | 105 friend class KernelObject; |
| 104 friend class KernelProxy; | 106 friend class KernelProxy; |
| 105 DISALLOW_COPY_AND_ASSIGN(Filesystem); | 107 DISALLOW_COPY_AND_ASSIGN(Filesystem); |
| 106 }; | 108 }; |
| 107 | 109 |
| 108 } // namespace nacl_io | 110 } // namespace nacl_io |
| 109 | 111 |
| 110 #endif // LIBRARIES_NACL_IO_FILESYSTEM_H_ | 112 #endif // LIBRARIES_NACL_IO_FILESYSTEM_H_ |
| OLD | NEW |