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 : public VMCache { 17 public: 18 status_t Init(struct vnode* vnode, 19 uint32 allocationFlags); 20 21 virtual bool HasPage(off_t offset); 22 23 virtual status_t Read(off_t offset, const generic_io_vec* vecs, 24 size_t count, uint32 flags, 25 generic_size_t* _numBytes); 26 virtual status_t Write(off_t offset, const generic_io_vec* vecs, 27 size_t count, uint32 flags, 28 generic_size_t* _numBytes); 29 virtual status_t WriteAsync(off_t offset, 30 const generic_io_vec* vecs, size_t count, 31 generic_size_t numBytes, uint32 flags, 32 AsyncIOCallback* callback); 33 virtual bool CanWritePage(off_t offset); 34 35 virtual status_t Fault(struct VMAddressSpace* aspace, 36 off_t offset); 37 38 virtual status_t AcquireUnreferencedStoreRef(); 39 virtual void AcquireStoreRef(); 40 virtual void ReleaseStoreRef(); 41 42 virtual void Dump(bool showPages) const; 43 44 void SetFileCacheRef(file_cache_ref* ref) 45 { fFileCacheRef = ref; } 46 file_cache_ref* FileCacheRef() const 47 { return fFileCacheRef; } 48 49 void VnodeDeleted() { fVnodeDeleted = true; } 50 51 dev_t DeviceId() const 52 { return fDevice; } 53 ino_t InodeId() const 54 { return fInode; } 55 56 protected: 57 virtual void DeleteObject(); 58 59 private: 60 struct vnode* fVnode; 61 file_cache_ref* fFileCacheRef; 62 ino_t fInode; 63 dev_t fDevice; 64 volatile bool fVnodeDeleted; 65 }; 66 67 68 #endif /* VNODE_STORE_H */ 69