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

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: 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 "utils/ref_object.h" 12 #include "utils/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
17 class MountNode : public RefObject { 18 class MountNode : public RefObject {
18 protected: 19 protected:
19 explicit MountNode(Mount* mount); 20 explicit MountNode(Mount* mount);
20 virtual ~MountNode(); 21 virtual ~MountNode();
21 22
22 protected: 23 protected:
23 // Initialize with node specific flags, in this case stat permissions. 24 // Initialize with node specific flags, in this case stat permissions.
24 virtual bool Init(int flags); 25 virtual Error Init(int flags);
25 virtual void Destroy(); 26 virtual void Destroy();
26 27
27 public: 28 public:
28 // Normal OS operations on a node (file), can be called by the kernel 29 // Normal OS operations on a node (file), can be called by the kernel
29 // directly so it must lock and unlock appropriately. These functions 30 // directly so it must lock and unlock appropriately. These functions
30 // must not be called by the mount. 31 // must not be called by the mount.
31 virtual int FSync(); 32 virtual Error FSync();
32 virtual int FTruncate(off_t length); 33 virtual Error FTruncate(off_t length);
33 virtual int GetDents(size_t offs, struct dirent* pdir, size_t count); 34 virtual Error GetDents(size_t offs,
34 virtual int GetStat(struct stat* stat); 35 struct dirent* pdir,
35 virtual int Ioctl(int request, char* arg); 36 size_t count,
36 virtual int Read(size_t offs, void* buf, size_t count); 37 int* out_bytes);
37 virtual int Write(size_t offs, const void* buf, size_t count); 38 virtual Error GetStat(struct stat* stat);
38 virtual void* MMap(void* addr, size_t length, int prot, int flags, 39 virtual Error Ioctl(int request, char* arg);
39 size_t offset); 40 virtual Error Read(size_t offs, void* buf, size_t count, int* out_bytes);
41 virtual Error Write(size_t offs,
42 const void* buf,
43 size_t count,
44 int* out_bytes);
45 virtual Error MMap(void* addr,
46 size_t length,
47 int prot,
48 int flags,
49 size_t offset,
50 void** out_addr);
40 51
41 virtual int GetLinks(); 52 virtual int GetLinks();
42 virtual int GetMode(); 53 virtual int GetMode();
43 virtual int GetType(); 54 virtual int GetType();
44 virtual size_t GetSize(); 55 virtual Error GetSize(size_t *out_size);
45 virtual bool IsaDir(); 56 virtual bool IsaDir();
46 virtual bool IsaFile(); 57 virtual bool IsaFile();
47 virtual bool IsaTTY(); 58 virtual bool IsaTTY();
48 59
49 protected: 60 protected:
50 // Directory operations on the node are done by the Mount. The mount's lock 61 // Directory operations on the node are done by the Mount. The mount's lock
51 // must be held while these calls are made. 62 // must be held while these calls are made.
52 63
53 // Adds or removes a directory entry updating the link numbers and refcount 64 // Adds or removes a directory entry updating the link numbers and refcount
54 virtual int AddChild(const std::string& name, MountNode *node); 65 virtual Error AddChild(const std::string& name, MountNode* node);
55 virtual int RemoveChild(const std::string& name); 66 virtual Error RemoveChild(const std::string& name);
56 67
57 // Find a child and return it without updating the refcount 68 // Find a child and return it without updating the refcount
58 virtual MountNode* FindChild(const std::string& name); 69 virtual Error FindChild(const std::string& name, MountNode** out_node);
59 virtual int ChildCount(); 70 virtual int ChildCount();
60 71
61 // Update the link count 72 // Update the link count
62 virtual void Link(); 73 virtual void Link();
63 virtual void Unlink(); 74 virtual void Unlink();
64 75
65 protected: 76 protected:
66 struct stat stat_; 77 struct stat stat_;
67 Mount* mount_; 78 Mount* mount_;
68 79
69 friend class Mount; 80 friend class Mount;
70 friend class MountDev; 81 friend class MountDev;
71 friend class MountHtml5Fs; 82 friend class MountHtml5Fs;
72 friend class MountHttp; 83 friend class MountHttp;
73 friend class MountMem; 84 friend class MountMem;
74 friend class MountNodeDir; 85 friend class MountNodeDir;
75 }; 86 };
76 87
77 #endif // LIBRARIES_NACL_IO_MOUNT_NODE_H_ 88 #endif // LIBRARIES_NACL_IO_MOUNT_NODE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698