1 #include "opener_server.h" 2 #include "opener_resource.h" 3 #include "resource_server.h" 4 5 /* Support for providing access to files. */ 6 7 OpenerResource::OpenerResource(Pages *pages) 8 : FilePaging(pages) 9 { 10 } 11 12 int OpenerResource::expected_items() 13 { 14 return Opener_expected_items; 15 } 16 17 ipc_server_handler_type OpenerResource::handler() 18 { 19 return (ipc_server_handler_type) handle_Opener; 20 } 21 22 23 24 /* Return a pager object for the given path and flags. */ 25 26 Pager *OpenerResource::open(const char *path, flags_t flags) 27 { 28 fileid_t fileid = get_fileid(path); 29 30 if (fileid == FILEID_INVALID) 31 return NULL; 32 33 return get_pager(fileid, get_flags(flags)); 34 } 35 36 37 38 /* Opener interface methods. */ 39 40 long OpenerResource::context(l4_cap_idx_t *context) 41 { 42 OpenerContextResource *resource = new OpenerContextResource(this); 43 44 /* Complete the initialisation and start a server in a new thread. 45 If the thread does not start, the resource should be finalised. */ 46 47 ResourceServer server(resource); 48 long err = server.start_thread(); 49 50 /* Return the server capability to the caller. */ 51 52 if (!err) 53 *context = server.config()->server; 54 55 return err; 56 } 57 58 // vim: tabstop=4 expandtab shiftwidth=4