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