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

Unified Diff: native_client_sdk/src/libraries/nacl_io/mount_node.h

Issue 16232016: [NaCl SDK] nacl_io: big refactor to return error value (errno). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge master, fix windows Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: native_client_sdk/src/libraries/nacl_io/mount_node.h
diff --git a/native_client_sdk/src/libraries/nacl_io/mount_node.h b/native_client_sdk/src/libraries/nacl_io/mount_node.h
index 68375484ae78d8d17b6e7671c94f3b274b239c97..0acce66f805581540ba4000623d3277f88e7d0f8 100644
--- a/native_client_sdk/src/libraries/nacl_io/mount_node.h
+++ b/native_client_sdk/src/libraries/nacl_io/mount_node.h
@@ -7,6 +7,7 @@
#include <string>
+#include "nacl_io/error.h"
#include "nacl_io/osstat.h"
#include "sdk_util/ref_object.h"
@@ -14,6 +15,8 @@ struct dirent;
struct stat;
class Mount;
+// NOTE: The KernelProxy is the only class that should be setting errno. All
+// other classes should return Error (as defined by nacl_io/error.h).
class MountNode : public RefObject {
protected:
explicit MountNode(Mount* mount);
@@ -21,27 +24,46 @@ class MountNode : public RefObject {
protected:
// Initialize with node specific flags, in this case stat permissions.
- virtual bool Init(int flags);
+ virtual Error Init(int flags);
virtual void Destroy();
public:
// Normal OS operations on a node (file), can be called by the kernel
// directly so it must lock and unlock appropriately. These functions
// must not be called by the mount.
- virtual int FSync();
- virtual int FTruncate(off_t length);
- virtual int GetDents(size_t offs, struct dirent* pdir, size_t count);
- virtual int GetStat(struct stat* stat);
- virtual int Ioctl(int request, char* arg);
- virtual int Read(size_t offs, void* buf, size_t count);
- virtual int Write(size_t offs, const void* buf, size_t count);
- virtual void* MMap(void* addr, size_t length, int prot, int flags,
- size_t offset);
+ virtual Error FSync();
+ // It is expected that the derived MountNode will fill with 0 when growing
+ // the file.
+ virtual Error FTruncate(off_t length);
+ // Assume that |out_bytes| is non-NULL.
+ virtual Error GetDents(size_t offs,
+ struct dirent* pdir,
+ size_t count,
+ int* out_bytes);
+ // Assume that |stat| is non-NULL.
+ virtual Error GetStat(struct stat* stat);
+ // Assume that |arg| is non-NULL.
+ virtual Error Ioctl(int request, char* arg);
+ // Assume that |buf| and |out_bytes| are non-NULL.
+ virtual Error Read(size_t offs, void* buf, size_t count, int* out_bytes);
+ // Assume that |buf| and |out_bytes| are non-NULL.
+ virtual Error Write(size_t offs,
+ const void* buf,
+ size_t count,
+ int* out_bytes);
+ // Assume that |addr| and |out_addr| are non-NULL.
+ virtual Error MMap(void* addr,
+ size_t length,
+ int prot,
+ int flags,
+ size_t offset,
+ void** out_addr);
virtual int GetLinks();
virtual int GetMode();
virtual int GetType();
- virtual size_t GetSize();
+ // Assume that |out_size| is non-NULL.
+ virtual Error GetSize(size_t *out_size);
virtual bool IsaDir();
virtual bool IsaFile();
virtual bool IsaTTY();
@@ -51,18 +73,20 @@ class MountNode : public RefObject {
// must be held while these calls are made.
// Adds or removes a directory entry updating the link numbers and refcount
- virtual int AddChild(const std::string& name, MountNode *node);
- virtual int RemoveChild(const std::string& name);
+ // Assumes that |node| is non-NULL.
+ virtual Error AddChild(const std::string& name, MountNode* node);
+ virtual Error RemoveChild(const std::string& name);
// Find a child and return it without updating the refcount
- virtual MountNode* FindChild(const std::string& name);
+ // Assumes that |out_node| is non-NULL.
+ virtual Error FindChild(const std::string& name, MountNode** out_node);
virtual int ChildCount();
// Update the link count
virtual void Link();
virtual void Unlink();
-protected:
+ protected:
struct stat stat_;
Mount* mount_;
« no previous file with comments | « native_client_sdk/src/libraries/nacl_io/mount_mem.cc ('k') | native_client_sdk/src/libraries/nacl_io/mount_node.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698