1 /* 2 * A context resource offering support for opening files. 3 * 4 * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License as 8 * published by the Free Software Foundation; either version 2 of 9 * the License, or (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, 19 * Boston, MA 02110-1301, USA 20 */ 21 22 #pragma once 23 24 #include <fsserver/opener_context_object_interface.h> 25 #include <fsserver/simple_pager.h> 26 27 28 29 /* Forward declaration. */ 30 31 class OpenerResource; 32 33 34 35 /* Support for indicating files to be opened. */ 36 37 class OpenerContextResource : public SimplePager, public OpenerContextObject 38 { 39 protected: 40 OpenerResource *_opener; 41 42 public: 43 explicit OpenerContextResource(OpenerResource *opener, Memory *memory=NULL); 44 45 /* Server details. */ 46 47 int expected_items(); 48 49 ipc_server_handler_type handler(); 50 51 void *interface() 52 { return static_cast<OpenerContextObject *>(this); } 53 54 /* Data access methods. */ 55 56 char *get_path(); 57 58 /* Opener context interface methods. */ 59 60 long open(flags_t flags, offset_t *size, l4_cap_idx_t *file); 61 62 /* Pager/dataspace methods. */ 63 64 long map(unsigned long offset, address_t hot_spot, map_flags_t flags, 65 l4_snd_fpage_t *region) 66 { return SimplePager::map(offset, hot_spot, flags, region); } 67 68 long info(unsigned long *size, unsigned long *flags) 69 { return SimplePager::info(size, flags); } 70 }; 71 72 // vim: tabstop=4 expandtab shiftwidth=4