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