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_IO_MOUNT_MEM_H_ 6 #define LIBRARIES_NACL_IO_MOUNT_MEM_H_ 7 8 #include "nacl_io/mount.h" 9 #include "nacl_io/typed_mount_factory.h" 10 11 namespace nacl_io { 12 13 class MountMem : public Mount { 14 protected: 15 MountMem(); 16 17 using Mount::Init; 18 virtual Error Init(const MountInitArgs& args); 19 20 // The protected functions are only used internally and will not 21 // acquire or release the mount's lock themselves. The caller is 22 // required to use correct locking as needed. 23 24 // Allocate or free an INODE number. 25 int AllocateINO(); 26 void FreeINO(int ino); 27 28 // Find a Node specified node optionally failing if type does not match. 29 virtual Error FindNode(const Path& path, int type, ScopedMountNode* out_node); 30 31 public: 32 virtual Error Access(const Path& path, int a_mode); 33 virtual Error Open(const Path& path, int mode, ScopedMountNode* out_node); 34 virtual Error Unlink(const Path& path); 35 virtual Error Mkdir(const Path& path, int perm); 36 virtual Error Rmdir(const Path& path); 37 virtual Error Remove(const Path& path); 38 virtual Error Rename(const Path& path, const Path& newpath); 39 40 private: 41 static const int REMOVE_DIR = 1; 42 static const int REMOVE_FILE = 2; 43 static const int REMOVE_ALL = REMOVE_DIR | REMOVE_FILE; 44 45 Error RemoveInternal(const Path& path, int remove_type); 46 47 ScopedMountNode root_; 48 49 friend class TypedMountFactory<MountMem>; 50 DISALLOW_COPY_AND_ASSIGN(MountMem); 51 }; 52 53 } // namespace nacl_io 54 55 #endif // LIBRARIES_NACL_IO_MOUNT_MEM_H_ 56