Index: native_client_sdk/src/libraries/nacl_io/mount.h |
diff --git a/native_client_sdk/src/libraries/nacl_io/mount.h b/native_client_sdk/src/libraries/nacl_io/mount.h |
index 622dae0207aa25f42eafacc5ddce37b640413339..7d2acd07a476361a1ce3fd44b1fcca5f60d0f959 100644 |
--- a/native_client_sdk/src/libraries/nacl_io/mount.h |
+++ b/native_client_sdk/src/libraries/nacl_io/mount.h |
@@ -8,6 +8,7 @@ |
#include <map> |
#include <string> |
+#include "nacl_io/error.h" |
#include "nacl_io/inode_pool.h" |
#include "nacl_io/mount_node.h" |
#include "nacl_io/path.h" |
@@ -19,7 +20,6 @@ class PepperInterface; |
typedef std::map<std::string, std::string> StringMap_t; |
- |
class Mount : public RefObject { |
protected: |
// The protected functions are only used internally and will not |
@@ -30,12 +30,15 @@ class Mount : public RefObject { |
// Init must be called by the factory before the mount is used. |
// This function must assign a root node, or replace FindNode. |
// |ppapi| can be NULL. If so, this mount cannot make any pepper calls. |
- virtual bool Init(int dev, StringMap_t& args, PepperInterface* ppapi); |
+ virtual Error Init(int dev, StringMap_t& args, PepperInterface* ppapi); |
virtual void Destroy(); |
public: |
template <class M> |
- static Mount* Create(int dev, StringMap_t& args, PepperInterface* ppapi); |
+ static Error Create(int dev, |
+ StringMap_t& args, |
+ PepperInterface* ppapi, |
+ Mount** out_mount); |
PepperInterface* ppapi() { return ppapi_; } |
@@ -45,23 +48,23 @@ class Mount : public RefObject { |
// Open a node at |path| with the specified open flags. The resulting |
// MountNode is created with a ref count of 1. |
- virtual MountNode *Open(const Path& path, int o_flags) = 0; |
+ virtual Error Open(const Path& path, int o_flags, MountNode** out_node) = 0; |
// OpenResource is only used to read files from the NaCl NMF file. No mount |
// except MountPassthrough should implement it. |
- virtual MountNode *OpenResource(const Path& path) { return NULL; } |
+ virtual Error OpenResource(const Path& path, MountNode** out_node); |
// Unlink, Mkdir, Rmdir will affect the both the RefCount |
// and the nlink number in the stat object. |
- virtual int Unlink(const Path& path) = 0; |
- virtual int Mkdir(const Path& path, int permissions) = 0; |
- virtual int Rmdir(const Path& path) = 0; |
- virtual int Remove(const Path& path) = 0; |
+ virtual Error Unlink(const Path& path) = 0; |
+ virtual Error Mkdir(const Path& path, int permissions) = 0; |
+ virtual Error Rmdir(const Path& path) = 0; |
+ virtual Error Remove(const Path& path) = 0; |
// Convert from R,W,R/W open flags to STAT permission flags |
static int OpenModeToPermission(int mode); |
- void OnNodeCreated(MountNode* node) ; |
+ void OnNodeCreated(MountNode* node); |
void OnNodeDestroyed(MountNode* node); |
protected: |
@@ -81,16 +84,22 @@ class Mount : public RefObject { |
DISALLOW_COPY_AND_ASSIGN(Mount); |
}; |
- |
-template <class M> |
/*static*/ |
-Mount* Mount::Create(int dev, StringMap_t& args, PepperInterface* ppapi) { |
+template <class M> |
+Error Mount::Create(int dev, |
+ StringMap_t& args, |
+ PepperInterface* ppapi, |
+ Mount** out_mount) { |
Mount* mnt = new M(); |
- if (mnt->Init(dev, args, ppapi) == false) { |
+ Error error = mnt->Init(dev, args, ppapi); |
noelallen1
2013/06/07 21:48:43
if (NULL == *out_mount)?
binji
2013/06/07 23:23:11
Added comment to Create declaration above.
|
+ if (error) { |
delete mnt; |
- return NULL; |
+ *out_mount = NULL; |
+ return error; |
} |
- return mnt; |
+ |
+ *out_mount = mnt; |
+ return 0; |
} |
#endif // LIBRARIES_NACL_IO_MOUNT_H_ |