| OLD | NEW |
| (Empty) |
| 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 | |
| 3 * found in the LICENSE file. | |
| 4 */ | |
| 5 #ifndef LIBRARIES_NACL_MOUNTS_MOUNT_NODE_H_ | |
| 6 #define LIBRARIES_NACL_MOUNTS_MOUNT_NODE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "nacl_mounts/osstat.h" | |
| 11 #include "utils/ref_object.h" | |
| 12 | |
| 13 struct dirent; | |
| 14 struct stat; | |
| 15 class Mount; | |
| 16 | |
| 17 class MountNode : public RefObject { | |
| 18 protected: | |
| 19 explicit MountNode(Mount* mount); | |
| 20 virtual ~MountNode(); | |
| 21 | |
| 22 protected: | |
| 23 // Initialize with node specific flags, in this case stat permissions. | |
| 24 virtual bool Init(int flags); | |
| 25 virtual void Destroy(); | |
| 26 | |
| 27 public: | |
| 28 // 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 // must not be called by the mount. | |
| 31 virtual int FSync(); | |
| 32 virtual int GetDents(size_t offs, struct dirent* pdir, size_t count); | |
| 33 virtual int GetStat(struct stat* stat); | |
| 34 virtual int Ioctl(int request, char* arg); | |
| 35 virtual int Read(size_t offs, void* buf, size_t count); | |
| 36 virtual int Truncate(size_t size); | |
| 37 virtual int Write(size_t offs, const void* buf, size_t count); | |
| 38 | |
| 39 virtual int GetLinks(); | |
| 40 virtual int GetMode(); | |
| 41 virtual int GetType(); | |
| 42 virtual size_t GetSize(); | |
| 43 virtual bool IsaDir(); | |
| 44 virtual bool IsaFile(); | |
| 45 virtual bool IsaTTY(); | |
| 46 | |
| 47 protected: | |
| 48 // Directory operations on the node are done by the Mount. The mount's lock | |
| 49 // must be held while these calls are made. | |
| 50 | |
| 51 // Adds or removes a directory entry updating the link numbers and refcount | |
| 52 virtual int AddChild(const std::string& name, MountNode *node); | |
| 53 virtual int RemoveChild(const std::string& name); | |
| 54 | |
| 55 // Find a child and return it without updating the refcount | |
| 56 virtual MountNode* FindChild(const std::string& name); | |
| 57 virtual int ChildCount(); | |
| 58 | |
| 59 // Update the link count | |
| 60 virtual void Link(); | |
| 61 virtual void Unlink(); | |
| 62 | |
| 63 protected: | |
| 64 struct stat stat_; | |
| 65 Mount* mount_; | |
| 66 | |
| 67 friend class Mount; | |
| 68 friend class MountDev; | |
| 69 friend class MountHtml5Fs; | |
| 70 friend class MountHttp; | |
| 71 friend class MountMem; | |
| 72 friend class MountNodeDir; | |
| 73 }; | |
| 74 | |
| 75 #endif // LIBRARIES_NACL_MOUNTS_MOUNT_NODE_H_ | |
| OLD | NEW |