1 #pragma once 2 3 #include <l4/sys/ipc.h> 4 5 #include "accessing.h" 6 #include "file_pager.h" 7 #include "opener_context_resource.h" 8 #include "opener_interface.h" 9 #include "pager.h" 10 #include "paging.h" 11 #include "pages.h" 12 #include "resource.h" 13 14 /* Support for providing access to files. */ 15 16 class OpenerResource : public Resource, public Opener 17 { 18 protected: 19 Accessing *_accessing; 20 Paging *_paging; 21 Pages *_pages; 22 23 /* Convenience methods. */ 24 25 Accessor *get_accessor(fileid_t fileid); 26 27 PageMapper *get_mapper(Accessor *accessor); 28 29 /* Configurable methods. */ 30 31 virtual fileid_t get_fileid(const char *path) = 0; 32 33 virtual Accessor *make_accessor(fileid_t fileid) = 0; 34 35 public: 36 explicit OpenerResource(Accessing *accessing, Paging *paging, Pages *pages); 37 38 /* Server details. */ 39 40 int expected_items(); 41 42 ipc_server_handler_type handler(); 43 44 void *interface() 45 { return static_cast<Opener *>(this); } 46 47 /* Direct access methods. */ 48 49 FilePager *open(const char *path); 50 51 /* Opener interface methods. */ 52 53 long context(l4_cap_idx_t *context); 54 }; 55 56 // vim: tabstop=4 expandtab shiftwidth=4