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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
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_IO_MOUNT_NODE_H_ 5 #ifndef LIBRARIES_NACL_IO_MOUNT_NODE_H_
6 #define LIBRARIES_NACL_IO_MOUNT_NODE_H_ 6 #define LIBRARIES_NACL_IO_MOUNT_NODE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "nacl_io/error.h"
10 #include "nacl_io/osstat.h" 11 #include "nacl_io/osstat.h"
11 #include "sdk_util/ref_object.h" 12 #include "sdk_util/ref_object.h"
12 13
13 struct dirent; 14 struct dirent;
14 struct stat; 15 struct stat;
15 class Mount; 16 class Mount;
16 17
18 // NOTE: The KernelProxy is the only class that should be setting errno. All
19 // other classes should return Error (as defined by nacl_io/error.h).
17 class MountNode : public RefObject { 20 class MountNode : public RefObject {
18 protected: 21 protected:
19 explicit MountNode(Mount* mount); 22 explicit MountNode(Mount* mount);
20 virtual ~MountNode(); 23 virtual ~MountNode();
21 24
22 protected: 25 protected:
23 // Initialize with node specific flags, in this case stat permissions. 26 // Initialize with node specific flags, in this case stat permissions.
24 virtual bool Init(int flags); 27 virtual Error Init(int flags);
25 virtual void Destroy(); 28 virtual void Destroy();
26 29
27 public: 30 public:
28 // Normal OS operations on a node (file), can be called by the kernel 31 // Normal OS operations on a node (file), can be called by the kernel
29 // directly so it must lock and unlock appropriately. These functions 32 // directly so it must lock and unlock appropriately. These functions
30 // must not be called by the mount. 33 // must not be called by the mount.
31 virtual int FSync(); 34 virtual Error FSync();
32 virtual int FTruncate(off_t length); 35 // It is expected that the derived MountNode will fill with 0 when growing
33 virtual int GetDents(size_t offs, struct dirent* pdir, size_t count); 36 // the file.
34 virtual int GetStat(struct stat* stat); 37 virtual Error FTruncate(off_t length);
35 virtual int Ioctl(int request, char* arg); 38 // Assume that |out_bytes| is non-NULL.
36 virtual int Read(size_t offs, void* buf, size_t count); 39 virtual Error GetDents(size_t offs,
37 virtual int Write(size_t offs, const void* buf, size_t count); 40 struct dirent* pdir,
38 virtual void* MMap(void* addr, size_t length, int prot, int flags, 41 size_t count,
39 size_t offset); 42 int* out_bytes);
43 // Assume that |stat| is non-NULL.
44 virtual Error GetStat(struct stat* stat);
45 // Assume that |arg| is non-NULL.
46 virtual Error Ioctl(int request, char* arg);
47 // Assume that |buf| and |out_bytes| are non-NULL.
48 virtual Error Read(size_t offs, void* buf, size_t count, int* out_bytes);
49 // Assume that |buf| and |out_bytes| are non-NULL.
50 virtual Error Write(size_t offs,
51 const void* buf,
52 size_t count,
53 int* out_bytes);
54 // Assume that |addr| and |out_addr| are non-NULL.
55 virtual Error MMap(void* addr,
56 size_t length,
57 int prot,
58 int flags,
59 size_t offset,
60 void** out_addr);
40 61
41 virtual int GetLinks(); 62 virtual int GetLinks();
42 virtual int GetMode(); 63 virtual int GetMode();
43 virtual int GetType(); 64 virtual int GetType();
44 virtual size_t GetSize(); 65 // Assume that |out_size| is non-NULL.
66 virtual Error GetSize(size_t *out_size);
45 virtual bool IsaDir(); 67 virtual bool IsaDir();
46 virtual bool IsaFile(); 68 virtual bool IsaFile();
47 virtual bool IsaTTY(); 69 virtual bool IsaTTY();
48 70
49 protected: 71 protected:
50 // Directory operations on the node are done by the Mount. The mount's lock 72 // Directory operations on the node are done by the Mount. The mount's lock
51 // must be held while these calls are made. 73 // must be held while these calls are made.
52 74
53 // Adds or removes a directory entry updating the link numbers and refcount 75 // Adds or removes a directory entry updating the link numbers and refcount
54 virtual int AddChild(const std::string& name, MountNode *node); 76 // Assumes that |node| is non-NULL.
55 virtual int RemoveChild(const std::string& name); 77 virtual Error AddChild(const std::string& name, MountNode* node);
78 virtual Error RemoveChild(const std::string& name);
56 79
57 // Find a child and return it without updating the refcount 80 // Find a child and return it without updating the refcount
58 virtual MountNode* FindChild(const std::string& name); 81 // Assumes that |out_node| is non-NULL.
82 virtual Error FindChild(const std::string& name, MountNode** out_node);
59 virtual int ChildCount(); 83 virtual int ChildCount();
60 84
61 // Update the link count 85 // Update the link count
62 virtual void Link(); 86 virtual void Link();
63 virtual void Unlink(); 87 virtual void Unlink();
64 88
65 protected: 89 protected:
66 struct stat stat_; 90 struct stat stat_;
67 Mount* mount_; 91 Mount* mount_;
68 92
69 friend class Mount; 93 friend class Mount;
70 friend class MountDev; 94 friend class MountDev;
71 friend class MountHtml5Fs; 95 friend class MountHtml5Fs;
72 friend class MountHttp; 96 friend class MountHttp;
73 friend class MountMem; 97 friend class MountMem;
74 friend class MountNodeDir; 98 friend class MountNodeDir;
75 }; 99 };
76 100
77 #endif // LIBRARIES_NACL_IO_MOUNT_NODE_H_ 101 #endif // LIBRARIES_NACL_IO_MOUNT_NODE_H_
OLDNEW
« 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