1 /* 2 * Copyright 2008-2016, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Copyright 2004-2007, Axel Dörfler, axeld@pinc-software.de. 4 * Distributed under the terms of the MIT License. 5 */ 6 #ifndef VNODE_STORE_H 7 #define VNODE_STORE_H 8 9 10 #include <vm/VMCache.h> 11 12 13 struct file_cache_ref; 14 15 16 class VMVnodeCache final : public VMCache { 17 public: 18 status_t Init(struct vnode* vnode, 19 uint32 allocationFlags); 20 21 virtual status_t Commit(off_t size, int priority); 22 virtual bool HasPage(off_t offset); 23 24 virtual status_t Read(off_t offset, const generic_io_vec* vecs, 25 size_t count, uint32 flags, 26 generic_size_t* _numBytes); 27 virtual status_t Write(off_t offset, const generic_io_vec* vecs, 28 size_t count, uint32 flags, 29 generic_size_t* _numBytes); 30 virtual status_t WriteAsync(off_t offset, 31 const generic_io_vec* vecs, size_t count, 32 generic_size_t numBytes, uint32 flags, 33 AsyncIOCallback* callback); 34 virtual bool CanWritePage(off_t offset); 35 36 virtual status_t Fault(struct VMAddressSpace* aspace, 37 off_t offset); 38 39 virtual status_t AcquireUnreferencedStoreRef(); 40 virtual void AcquireStoreRef(); 41 virtual void ReleaseStoreRef(); 42 43 virtual void Dump(bool showPages) const; 44 SetFileCacheRef(file_cache_ref * ref)45 void SetFileCacheRef(file_cache_ref* ref) 46 { fFileCacheRef = ref; } FileCacheRef()47 file_cache_ref* FileCacheRef() const 48 { return fFileCacheRef; } 49 VnodeDeleted()50 void VnodeDeleted() { fVnodeDeleted = true; } 51 DeviceId()52 dev_t DeviceId() const 53 { return fDevice; } InodeId()54 ino_t InodeId() const 55 { return fInode; } 56 57 protected: 58 virtual void DeleteObject(); 59 60 private: 61 struct vnode* fVnode; 62 file_cache_ref* fFileCacheRef; 63 ino_t fInode; 64 dev_t fDevice; 65 volatile bool fVnodeDeleted; 66 }; 67 68 69 #endif /* VNODE_STORE_H */ 70