1 /* 2 * Copyright 2008-2010, 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 private: 52 struct vnode* fVnode; 53 file_cache_ref* fFileCacheRef; 54 ino_t fInode; 55 dev_t fDevice; 56 volatile bool fVnodeDeleted; 57 }; 58 59 60 #endif /* VNODE_STORE_H */ 61